{"_id":"@iadvize-oss/foldable-helpers","_rev":"512-3e3e66155ab7bbff7cc32a903cc8e494","name":"@iadvize-oss/foldable-helpers","dist-tags":{"NO-TICKET-first-commit":"0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.26.0":"0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08","NO-TICKET-first-version":"0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f","dependabot-npm_and_yarn-fp-ts-2.5.0":"1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145","dependabot-npm_and_yarn-rollup-1.31.1":"1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405","dependabot-npm_and_yarn-typedoc-0.16.10":"1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e","dependabot-npm_and_yarn-ts-jest-25.2.1":"1.0.3-canary-91942ee-1582100782242","dependabot-npm_and_yarn-types-jest-25.1.3":"1.0.4-beta.0-canary-5611e8a-1582141839470","dependabot-npm_and_yarn-fp-ts-2.5.1":"1.0.4-beta.1-canary-c0ae3c4-1582219516973","dependabot-npm_and_yarn-typescript-3.8.2":"1.0.4-canary-a393f33-1582533298714","dependabot-npm_and_yarn-tslib-1.11.0":"1.0.5-beta.0-canary-4918602-1582578422422","NO-TICKET-add-eslint":"1.0.5-beta.1-canary-d81ab07-1582618395405","beta":"1.0.5-beta.2","dependabot-npm_and_yarn-rollup-plugin-multi-input-1.1.0":"1.0.5-beta.2-canary-5ccb1fb-1582662109793","dependabot-npm_and_yarn-rollup-plugin-multi-input-1.1.1":"1.0.5-beta.2-canary-10da221-1582663163591","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-0.0.5":"1.0.5-beta.2-canary-631c20c-1582714034110","dependabot-npm_and_yarn-iadvize-oss-eslint-config-0.1.2":"1.0.5-beta.2-canary-91a8621-1582716263480","dependabot-npm_and_yarn-iadvize-oss-eslint-config-0.1.3":"1.0.5-beta.2-canary-3032278-1582790954544","dependabot-npm_and_yarn-fp-ts-2.5.2":"1.0.5-beta.2-canary-78e8681-1582805286545","dependabot-npm_and_yarn-babel-preset-env-7.8.6":"1.0.5-beta.2-canary-a4d6502-1582806451066","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.0.0":"1.0.5-beta.2-canary-4da5936-1582806719082","dependabot-npm_and_yarn-tslib-1.11.1":"1.0.5-beta.2-canary-408a3ac-1582832230592","dependabot-npm_and_yarn-typedoc-0.16.11":"1.0.5-beta.2-canary-ba61eff-1582866432404","dependabot-npm_and_yarn-fp-ts-2.5.3":"1.0.5-beta.2-canary-908f2ec-1582875554986","dependabot-npm_and_yarn-rollup-1.32.0":"1.0.5-beta.2-canary-1c3c525-1582877195028","dependabot-npm_and_yarn-typescript-3.8.3":"1.0.5-beta.2-canary-9b876b1-1582928452729","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.0":"1.0.5-beta.2-canary-b8922bf-1583140297230","dependabot-npm_and_yarn-babel-core-7.8.6":"1.0.5-beta.2-canary-15c0677-1583190863208","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.1":"1.0.5-beta.2-canary-71bf3df-1583224262079","dependabot-npm_and_yarn-babel-core-7.8.7":"1.0.5-beta.2-canary-43877fc-1583373907356","dependabot-npm_and_yarn-babel-preset-env-7.8.7":"1.0.5-beta.2-canary-565a7e9-1583397689607","dependabot-npm_and_yarn-rollup-1.32.1":"1.0.5-beta.2-canary-cac29d1-1583487541788","dependabot-npm_and_yarn-types-jest-25.1.4":"1.0.5-beta.2-canary-202c16c-1583546364639","dependabot-npm_and_yarn-rollup-plugin-terser-5.3.0":"1.0.5-beta.2-canary-d1ab09d-1583782623241","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.2":"1.0.5-beta.2-canary-0060be1-1584025901785","dependabot-npm_and_yarn-acorn-6.4.1":"1.0.5-beta.2-canary-6dba21c-1584136226784","dependabot-npm_and_yarn-typedoc-0.17.0":"1.0.5-beta.2-canary-ca809ce-1584314494871","dependabot-npm_and_yarn-typedoc-0.17.1":"1.0.5-beta.2-canary-0c309ac-1584504485325","dependabot-npm_and_yarn-babel-preset-env-7.9.0":"1.0.5-beta.2-canary-a1852b2-1584719264748","dependabot-npm_and_yarn-babel-core-7.9.0":"1.0.5-beta.2-canary-22417d2-1584719675321","dependabot-npm_and_yarn-typedoc-0.17.2":"1.0.5-beta.2-canary-3ed2737-1584831863290","dependabot-npm_and_yarn-typedoc-0.17.3":"1.0.5-beta.2-canary-2bc282b-1584852475515","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.3":"1.0.5-beta.2-canary-de55995-1584876889520","dependabot-npm_and_yarn-babel-jest-25.2.0":"1.0.5-beta.2-canary-fb10cf2-1585159376250","dependabot-npm_and_yarn-jest-25.2.0":"1.0.5-beta.2-canary-20acc27-1585160151291","dependabot-npm_and_yarn-babel-jest-25.2.1":"1.0.5-beta.2-canary-22049bd-1585215546778","dependabot-npm_and_yarn-jest-25.2.1":"1.0.5-beta.2-canary-06ca790-1585217152823","dependabot-npm_and_yarn-jest-25.2.2":"1.0.5-beta.2-canary-f57a314-1585240398562","dependabot-npm_and_yarn-babel-jest-25.2.3":"1.0.5-beta.2-canary-7e51d27-1585255190518","dependabot-npm_and_yarn-jest-25.2.3":"1.0.5-beta.2-canary-2a1d00d-1585264443746","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.0":"1.0.5-beta.2-canary-cf4c2aa-1585296548801","dependabot-npm_and_yarn-babel-jest-25.2.4":"1.0.5-beta.2-canary-13544ef-1585510991707","dependabot-npm_and_yarn-jest-25.2.4":"1.0.5-beta.2-canary-f27a7fa-1585511312402","dependabot-npm_and_yarn-ts-jest-25.3.0":"1.0.5-beta.2-canary-38a6c8a-1585560814723","dependabot-npm_and_yarn-remark-cli-8.0.0":"1.0.5-beta.2-canary-d07ec44-1585565607459","dependabot-npm_and_yarn-babel-jest-25.2.6":"1.0.5-beta.2-canary-abd454d-1585824420627","dependabot-npm_and_yarn-jest-25.2.6":"1.0.5-beta.2-canary-258da2a-1585828153485","dependabot-npm_and_yarn-types-jest-25.1.5":"1.0.5-beta.2-canary-a3bbe97-1585847743237","dependabot-npm_and_yarn-jest-25.2.7":"1.0.5-beta.2-canary-622d3b8-1585903929967","dependabot-npm_and_yarn-ts-jest-25.3.1":"1.0.5-beta.2-canary-7d053e3-1585926920262","dependabot-npm_and_yarn-types-jest-25.2.0":"1.0.5-beta.2-canary-fd0400c-1585947758261","dependabot-npm_and_yarn-typedoc-0.17.4":"1.0.5-beta.2-canary-71c560a-1586141191227","dependabot-npm_and_yarn-types-jest-25.2.1":"1.0.5-beta.2-canary-f99bd31-1586161660329","dependabot-npm_and_yarn-babel-preset-env-7.9.5":"1.0.5-beta.2-canary-a0c87dd-1586288335850","dependabot-npm_and_yarn-babel-jest-25.3.0":"1.0.5-beta.2-canary-8c3a4f4-1586358319419","dependabot-npm_and_yarn-jest-25.3.0":"1.0.5-beta.2-canary-18353c0-1586359928782","dependabot-npm_and_yarn-rollup-plugin-commonjs-11.1.0":"1.0.5-beta.2-canary-0ce0140-1586657527134","dependabot-npm_and_yarn-rollup-plugin-node-resolve-7.1.2":"1.0.5-beta.2-canary-b28dad5-1586658058251","dependabot-npm_and_yarn-rollup-plugin-node-resolve-7.1.3":"1.0.5-beta.2-canary-1370da8-1586714237205","dependabot-npm_and_yarn-rollup-2.6.1":"1.0.5-beta.2-canary-e4ae4b8-1586727912181","dependabot-npm_and_yarn-ts-jest-25.4.0":"1.0.5-beta.2-canary-03f8a47-1587117925886","NO-TICKET-add-default-on-creatFoldObject":"1.0.5-beta.2-canary-b92bff9-1587305609676","dependabot-npm_and_yarn-babel-jest-25.4.0":"1.0.5-beta.2-canary-b644acd-1587334257212","dependabot-npm_and_yarn-jest-25.4.0":"1.0.5-beta.2-canary-0ef4d7d-1587335275206","dependabot-npm_and_yarn-rollup-2.7.0":"1.0.5-beta.2-canary-551ed8b-1587499091290","dependabot-npm_and_yarn-rollup-2.7.1":"1.0.5-beta.2-canary-45b3896-1587502641849","dependabot-npm_and_yarn-rollup-2.7.2":"1.0.5-beta.2-canary-a5c42b5-1587582512965","dependabot-npm_and_yarn-fp-ts-2.5.4":"1.0.5-beta.2-canary-89f5183-1587879169541","dependabot-npm_and_yarn-typedoc-0.17.5":"1.0.5-beta.2-canary-3071526-1587921375286","dependabot-npm_and_yarn-typedoc-0.17.6":"1.0.5-beta.2-canary-499eb5f-1587949978182","dependabot-npm_and_yarn-rollup-2.7.3":"1.0.5-beta.2-canary-4701cb2-1588019545936","dependabot-npm_and_yarn-babel-jest-25.5.0":"1.0.5-beta.2-canary-158d3b7-1588103616078","dependabot-npm_and_yarn-jest-25.5.0":"1.0.5-beta.2-canary-636546b-1588104551336","dependabot-npm_and_yarn-babel-jest-25.5.1":"1.0.5-beta.2-canary-993f6b0-1588166144699","dependabot-npm_and_yarn-jest-25.5.1":"1.0.5-beta.2-canary-0745690-1588168158764","dependabot-npm_and_yarn-babel-preset-env-7.9.6":"1.0.5-beta.2-canary-a79e1f3-1588186871146","dependabot-npm_and_yarn-babel-core-7.9.6":"1.0.5-beta.2-canary-f5c6b90-1588187508003","dependabot-npm_and_yarn-rollup-2.7.4":"1.0.5-beta.2-canary-d07c5ae-1588188712635","dependabot-npm_and_yarn-rollup-2.7.5":"1.0.5-beta.2-canary-9f154c9-1588191427373","dependabot-npm_and_yarn-jest-25.5.2":"1.0.5-beta.2-canary-3de0e47-1588199358898","dependabot-npm_and_yarn-rollup-2.7.6":"1.0.5-beta.2-canary-c866fb3-1588273269619","dependabot-npm_and_yarn-jest-25.5.3":"1.0.5-beta.2-canary-5d419d0-1588285226250","dependabot-npm_and_yarn-jest-25.5.4":"1.0.5-beta.2-canary-2d14a03-1588407908612","dependabot-npm_and_yarn-babel-jest-26.0.0":"1.0.5-beta.2-canary-9579a72-1588629511435","dependabot-npm_and_yarn-babel-jest-26.0.1":"1.0.5-beta.2-canary-8f35144-1588689904843","dependabot-npm_and_yarn-tslib-1.11.2":"1.0.5-beta.2-canary-edfe6a5-1588722130828","dependabot-npm_and_yarn-rollup-2.8.0":"1.0.5-beta.2-canary-915c5fd-1588756377129","dependabot-npm_and_yarn-ts-jest-25.5.0":"1.0.5-beta.2-canary-cc637ab-1588769963663","dependabot-npm_and_yarn-rollup-2.8.1":"1.0.5-beta.2-canary-dbbb825-1588831937318","dependabot-npm_and_yarn-rollup-2.8.2":"1.0.5-beta.2-canary-89810ee-1588853070676","dependabot-npm_and_yarn-ts-jest-25.5.1":"1.0.5-beta.2-canary-b53817c-1589014737025","dependabot-npm_and_yarn-rollup-2.9.0":"1.0.5-beta.2-canary-0bbbfab-1589108638680","dependabot-npm_and_yarn-rollup-2.9.1":"1.0.5-beta.2-canary-9e2a9a9-1589199762525","dependabot-npm_and_yarn-fp-ts-2.6.0":"1.0.5-beta.2-canary-d429b78-1589207038522","dependabot-npm_and_yarn-tslib-1.12.0":"1.0.5-beta.2-canary-a95477d-1589307139620","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.1":"1.0.5-beta.2-canary-4cb6560-1589311738827","dependabot-npm_and_yarn-rollup-2.10.0":"1.0.5-beta.2-canary-326937b-1589350237906","dependabot-npm_and_yarn-typescript-3.9.2":"1.0.5-beta.2-canary-6ec4e83-1589352655220","dependabot-npm_and_yarn-types-jest-25.2.2":"1.0.5-beta.2-canary-12b4d2a-1589396248595","dependabot-npm_and_yarn-tslib-2.0.0":"1.0.5-beta.2-canary-b46e8e9-1589411464927","dependabot-npm_and_yarn-fp-ts-2.6.1":"1.0.5-beta.2-canary-a6e911c-1589485887209","dependabot-npm_and_yarn-rollup-2.10.2":"1.0.5-beta.2-canary-3e0ffb2-1589523577762","dependabot-npm_and_yarn-typedoc-0.17.7":"1.0.5-beta.2-canary-d25271e-1589687931970","dependabot-npm_and_yarn-rollup-2.10.3":"1.0.5-beta.2-canary-815c321-1589840893522","dependabot-npm_and_yarn-types-jest-25.2.3":"1.0.5-beta.2-canary-6007f70-1589844491862","dependabot-npm_and_yarn-rollup-2.10.4":"1.0.5-beta.2-canary-233e11b-1589870298937","dependabot-npm_and_yarn-rollup-2.10.5":"1.0.5-beta.2-canary-6e69371-1589924353343","dependabot-npm_and_yarn-typescript-3.9.3":"1.0.5-beta.2-canary-4ab6771-1589958928113","dependabot-npm_and_yarn-rollup-plugin-node-resolve-8.0.0":"1.0.5-beta.2-canary-f0685c4-1589998015622","dependabot-npm_and_yarn-rollup-plugin-commonjs-12.0.0":"1.0.5-beta.2-canary-7ad7516-1590059711971","dependabot-npm_and_yarn-rollup-2.10.7":"1.0.5-beta.2-canary-8ad21b8-1590128180921","dependabot-npm_and_yarn-rollup-2.10.8":"1.0.5-beta.2-canary-4edcf0e-1590214094022","dependabot-npm_and_yarn-rollup-plugin-terser-6.0.0":"1.0.5-beta.2-canary-3f65a9d-1590228758815","dependabot-npm_and_yarn-rollup-plugin-terser-6.0.1":"1.0.5-beta.2-canary-9e48ca8-1590233006234","dependabot-npm_and_yarn-rollup-2.10.9":"1.0.5-beta.2-canary-8e6c45d-1590302766098","dependabot-npm_and_yarn-rollup-plugin-terser-6.1.0":"1.0.5-beta.2-canary-6594d5f-1590359171584","dependabot-npm_and_yarn-babel-preset-env-7.10.0":"1.0.5-beta.2-canary-c5557b8-1590530828017","dependabot-npm_and_yarn-babel-core-7.10.0":"1.0.5-beta.2-canary-bbf25c1-1590531607057","dependabot-npm_and_yarn-fp-ts-2.6.2":"1.0.5-beta.2-canary-a4fe5e2-1590585435360","dependabot-npm_and_yarn-rollup-2.11.0":"1.0.5-beta.2-canary-c597184-1590611557015","dependabot-npm_and_yarn-babel-preset-env-7.10.1":"1.0.5-beta.2-canary-21d62a5-1590623145112","dependabot-npm_and_yarn-babel-core-7.10.1":"1.0.5-beta.2-canary-640d168-1590624206671","dependabot-npm_and_yarn-rollup-2.11.2":"1.0.5-beta.2-canary-e8a4bf2-1590646985820","dependabot-npm_and_yarn-babel-preset-env-7.10.2":"1.0.5-beta.2-canary-f019103-1590870386373","dependabot-npm_and_yarn-babel-core-7.10.2":"1.0.5-beta.2-canary-768032f-1590871295630","dependabot-npm_and_yarn-rollup-2.12.0":"1.0.5-beta.2-canary-82ac238-1590900361556","dependabot-npm_and_yarn-rollup-2.12.1":"1.0.5-beta.2-canary-080a0a6-1591132013942","dependabot-npm_and_yarn-rollup-2.13.0":"1.0.5-beta.2-canary-6ad4d6d-1591215224235","dependabot-npm_and_yarn-rollup-2.13.1":"1.0.5-beta.2-canary-a69b7ff-1591251306699","dependabot-npm_and_yarn-typescript-3.9.5":"1.0.5-beta.2-canary-7bf0eeb-1591304634904","dependabot-npm_and_yarn-rollup-plugin-node-resolve-8.0.1":"1.0.5-beta.2-canary-2f5f22c-1591569594163","dependabot-npm_and_yarn-rollup-plugin-commonjs-13.0.0":"1.0.5-beta.2-canary-1a0c653-1591657432696","dependabot-npm_and_yarn-fp-ts-2.6.4":"1.0.5-beta.2-canary-24104a6-1591741307343","dependabot-npm_and_yarn-types-jest-26.0.0":"1.0.5-beta.2-canary-7fe4cb4-1591827987591","dependabot-npm_and_yarn-fp-ts-2.6.5":"1.0.5-beta.2-canary-7dddfab-1591914034446","dependabot-npm_and_yarn-rollup-2.16.1":"1.0.5-beta.2-canary-17da0a1-1592176135470","dependabot-npm_and_yarn-fp-ts-2.6.6":"1.0.5-beta.2-canary-8d61cdf-1592347002946","dependabot-npm_and_yarn-rollup-2.17.0":"1.0.5-beta.2-canary-be0679a-1592430793046","NO-TICKET-update-libs":"1.0.5-beta.2-canary-9000b08-1592678417059","dependabot-npm_and_yarn-rollup-2.18.0":"1.0.5-canary-32e20ac-1592861509158","dependabot-npm_and_yarn-ts-jest-26.1.1":"1.0.5-canary-4636fcb-1592863621775","dependabot-npm_and_yarn-rollup-plugin-node-resolve-8.1.0":"1.0.5-canary-b78ac30-1592883534968","dependabot-npm_and_yarn-jest-26.1.0":"1.0.5-canary-de0b6e5-1592963549632","dependabot-npm_and_yarn-types-jest-26.0.3":"1.0.5-canary-4d8e14c-1593025324104","NO-TICKET-add-or-helper":"1.0.5-canary-63e3f39-1593065501640","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.2.0":"2.0.0-canary-79940dd-1593192408613","dependabot-npm_and_yarn-rollup-2.18.1":"2.0.0-canary-dfb1e38-1593200912080","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.2.1":"2.0.0-canary-0aa2a29-1593348661611","dependabot-npm_and_yarn-typedoc-0.17.8":"2.0.0-canary-4d5125c-1593394293929","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-0.0.7":"2.0.0-canary-93406bc-1593425572458","dependabot-npm_and_yarn-fp-ts-2.6.7":"2.0.0-canary-e1d50e7-1593434776199","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.0.0":"2.0.0-canary-eb437fa-1593586852128","dependabot-npm_and_yarn-typescript-3.9.6":"2.0.0-canary-620da2b-1593636940777","dependabot-npm_and_yarn-rollup-2.18.2":"2.0.0-canary-36f73c9-1593664103503","dependabot-npm_and_yarn-eslint-7.4.0":"2.0.0-canary-6b549fc-1593808118630","dependabot-npm_and_yarn-rollup-2.19.0":"2.0.0-canary-b44228d-1593927745558","NO-TICKET-remove-string-createFoldObject-limit":"2.0.0-canary-b793f98-1594019130179","dependabot-npm_and_yarn-rollup-2.20.0":"2.1.0-canary-c882586-1594080079649","dependabot-npm_and_yarn-types-jest-26.0.4":"2.1.0-canary-b9ec059-1594084903067","dependabot-npm_and_yarn-rollup-2.21.0":"2.1.0-canary-560d47f-1594165432995","dependabot-npm_and_yarn-fp-ts-2.7.0":"2.1.0-canary-56f9ce0-1594188141427","dependabot-npm_and_yarn-rollup-plugin-node-resolve-8.4.0":"2.1.0-canary-9fd73eb-1594587716004","dependabot-npm_and_yarn-rollup-plugin-commonjs-13.0.1":"2.1.0-canary-35d3d2a-1594594042023","dependabot-npm_and_yarn-ts-jest-26.1.2":"2.1.0-canary-240087c-1594664264571","dependabot-npm_and_yarn-rollup-plugin-commonjs-14.0.0":"2.1.0-canary-8670835-1594695343831","dependabot-npm_and_yarn-lodash-4.17.19":"2.1.0-canary-2019038-1594857573727","dependabot-npm_and_yarn-typescript-3.9.7":"2.1.0-canary-6487eeb-1594930649226","dependabot-npm_and_yarn-ts-jest-26.1.3":"2.1.0-canary-0b743b1-1594967040060","dependabot-npm_and_yarn-rollup-2.22.0":"2.1.0-canary-d66f277-1595047581397","dependabot-npm_and_yarn-types-jest-26.0.5":"2.1.0-canary-22939fe-1595088570923","dependabot-npm_and_yarn-eslint-7.5.0":"2.1.0-canary-6d7eb7f-1595100999351","dependabot-npm_and_yarn-rollup-2.22.1":"2.1.0-canary-77727d3-1595101738971","dependabot-npm_and_yarn-rollup-2.22.2":"2.1.0-canary-d99c2a9-1595398999147","dependabot-npm_and_yarn-fp-ts-2.7.1":"2.1.0-canary-d1c76ed-1595444289177","dependabot-npm_and_yarn-types-jest-26.0.6":"2.1.0-canary-f5e348e-1595527457942","dependabot-npm_and_yarn-rollup-2.23.0":"2.1.0-canary-ba822a3-1595536631724","dependabot-npm_and_yarn-types-jest-26.0.7":"2.1.0-canary-324f6ed-1595550667660","NO-TICKET-fix-union-to-intersection":"2.1.0-canary-59d6478-1595588889523","NO-TICKET-more-flexible-fold-signature":"2.1.1-canary-5143c8a-1595589218620","latest":"2.2.0","dependabot-npm_and_yarn-ts-jest-26.1.4":"2.2.0-canary-258220b-1595945949511","dependabot-npm_and_yarn-jest-26.2.1":"2.2.0-canary-dc23fe6-1596141893413","dependabot-npm_and_yarn-types-jest-26.0.8":"2.2.0-canary-5210260-1596173872047","dependabot-npm_and_yarn-jest-26.2.2":"2.2.0-canary-601bffd-1596249128194","dependabot-npm_and_yarn-eslint-7.6.0":"2.2.0-canary-6963d9a-1596280113158","dependabot-npm_and_yarn-types-jest-26.0.9":"2.2.0-canary-3ecab9d-1596674469964","dependabot-npm_and_yarn-tslib-2.0.1":"2.2.0-canary-31b1130-1596754604496","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.2":"2.2.0-canary-d97a3db-1596829192321","dependabot-npm_and_yarn-rollup-2.23.1":"2.2.0-canary-ec56f20-1596832343677","dependabot-npm_and_yarn-typedoc-0.18.0":"2.2.0-canary-9a64aa7-1596934254885","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.0":"2.2.0-canary-fc7d0f4-1597044126801","dependabot-npm_and_yarn-fp-ts-2.8.1":"2.2.0-canary-a209a63-1597044376107","dependabot-npm_and_yarn-jest-26.3.0":"2.2.0-canary-aa934d8-1597096892040","dependabot-npm_and_yarn-ts-jest-26.2.0":"2.2.0-canary-e3fe3c7-1597181180954","dependabot-npm_and_yarn-jest-26.4.0":"2.2.0-canary-c88e1c8-1597288407560","dependabot-npm_and_yarn-rollup-2.24.0":"2.2.0-canary-6e8fb4b-1597369511392","dependabot-npm_and_yarn-rollup-plugin-node-resolve-9.0.0":"2.2.0-canary-4f93d32-1597388976435","dependabot-npm_and_yarn-rollup-plugin-commonjs-15.0.0":"2.2.0-canary-32d7d9f-1597389206847","dependabot-npm_and_yarn-rollup-2.25.0":"2.2.0-canary-5d10095-1597400775506","dependabot-npm_and_yarn-eslint-7.7.0":"2.2.0-canary-f692689-1597454237775","dependabot-npm_and_yarn-types-jest-26.0.10":"2.2.0-canary-9f7f124-1597454832290","dependabot-npm_and_yarn-rollup-2.26.0":"2.2.0-canary-dde4aa1-1597467250690","dependabot-npm_and_yarn-rollup-2.26.1":"2.2.0-canary-42f3ebc-1597553710869","dependabot-npm_and_yarn-rollup-2.26.2":"2.2.0-canary-21c8dae-1597557827451","dependabot-npm_and_yarn-rollup-2.26.3":"2.2.0-canary-5d5e098-1597607676253","dependabot-npm_and_yarn-rollup-2.26.4":"2.2.0-canary-c7c21d8-1597832665653","dependabot-npm_and_yarn-rollup-2.26.5":"2.2.0-canary-c3f35c8-1598079876707","dependabot-npm_and_yarn-jest-26.4.2":"2.2.0-canary-8285496-1598101962927","dependabot-npm_and_yarn-ts-jest-26.3.0":"2.2.0-canary-83a036c-1598508052260","dependabot-npm_and_yarn-typescript-4.0.2":"2.2.0-canary-cdf4456-1598510794424","dependabot-npm_and_yarn-rollup-2.26.6":"2.2.0-canary-0ea6a9b-1598592452430","dependabot-npm_and_yarn-rollup-2.26.8":"2.2.0-canary-cd42db6-1598708271708","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.1":"2.2.0-canary-d5d7bfa-1598712128332","dependabot-npm_and_yarn-typedoc-0.19.0":"2.2.0-canary-75a8d70-1598814392584","dependabot-npm_and_yarn-fp-ts-2.8.2":"2.2.0-canary-961bd00-1598912112078","dependabot-npm_and_yarn-types-jest-26.0.12":"2.2.0-canary-a2d9528-1598968796196","dependabot-npm_and_yarn-eslint-7.8.0":"2.2.0-canary-08da3a3-1598975270543","dependabot-npm_and_yarn-rollup-2.26.9":"2.2.0-canary-b518123-1599031436461","dependabot-npm_and_yarn-eslint-7.8.1":"2.2.0-canary-ec257c6-1599067281309","dependabot-npm_and_yarn-types-jest-26.0.13":"2.2.0-canary-ace7e2d-1599145596390","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.2":"2.2.0-canary-eefb756-1599330130341","dependabot-npm_and_yarn-typedoc-0.19.1":"2.2.0-canary-5816317-1599339862432","dependabot-npm_and_yarn-eslint-7.9.0":"2.2.0-canary-d5361a6-1599936618101","dependabot-npm_and_yarn-types-jest-26.0.14":"2.2.0-canary-9a34bdc-1600350606914","dependabot-npm_and_yarn-typescript-4.0.3":"2.2.0-canary-cead4c5-1600527308695","dependabot-npm_and_yarn-ts-jest-26.4.0":"2.2.0-canary-75545ba-1600599376904","dependabot-npm_and_yarn-typedoc-0.19.2":"2.2.0-canary-e0ccf02-1600653945860","dependabot-npm_and_yarn-rollup-plugin-commonjs-15.1.0":"2.2.0-canary-9906e4b-1600676418407","dependabot-npm_and_yarn-fp-ts-2.8.3":"2.2.0-canary-8082b00-1600851515768","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.3":"2.2.0-canary-64988b0-1601097049923","dependabot-npm_and_yarn-eslint-7.10.0":"2.2.0-canary-1357c1c-1601158597097","dependabot-npm_and_yarn-ts-jest-26.4.1":"2.2.0-canary-424b205-1601460320654","dependabot-npm_and_yarn-jest-26.5.0":"2.2.0-canary-3a77e9b-1601949813195","dependabot-npm_and_yarn-jest-26.5.2":"2.2.0-canary-ff02a2a-1602085084447","dependabot-npm_and_yarn-tslib-2.0.2":"2.2.0-canary-0d89f0a-1602101056776","dependabot-npm_and_yarn-rollup-2.29.0":"2.2.0-canary-8ab439f-1602243060040","dependabot-npm_and_yarn-eslint-7.11.0":"2.2.0-canary-ba2d476-1602418459382","dependabot-npm_and_yarn-tslib-2.0.3":"2.2.0-canary-c641b9a-1602422666051","dependabot-npm_and_yarn-jest-26.5.3":"2.2.0-canary-b871c48-1602439602982","dependabot-npm_and_yarn-fp-ts-2.8.4":"2.2.0-canary-ca298cd-1602573899954","dependabot-npm_and_yarn-rollup-2.30.0":"2.2.0-canary-6a364c4-1602694630568","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.2.0":"2.2.0-canary-7c44693-1602796810890","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.1":"2.2.0-canary-5e852ff-1602829398077","dependabot-npm_and_yarn-rollup-2.32.0":"2.2.0-canary-712304a-1602919186783","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.28.0":"2.2.0-canary-0aac144-1603030968316","dependabot-npm_and_yarn-jest-26.6.0":"2.2.0-canary-4a36791-1603178101982","dependabot-npm_and_yarn-types-jest-26.0.15":"2.2.0-canary-7aca84e-1603293979478","dependabot-npm_and_yarn-rollup-2.32.1":"2.2.0-canary-f99fa2c-1603355675240","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.2":"2.2.0-canary-987965b-1603546411932","dependabot-npm_and_yarn-jest-26.6.1":"2.2.0-canary-ca8e2ff-1603616437859","dependabot-npm_and_yarn-ts-jest-26.4.2":"2.2.0-canary-90428c0-1603634447421","dependabot-npm_and_yarn-eslint-7.12.0":"2.2.0-canary-0cef614-1603647150372","dependabot-npm_and_yarn-ts-jest-26.4.3":"2.2.0-canary-e50bf87-1603829485955","dependabot-npm_and_yarn-typescript-4.0.5":"2.2.0-canary-fb9d200-1603838891344","dependabot-npm_and_yarn-rollup-plugin-node-resolve-10.0.0":"2.2.0-canary-0bd52c1-1603846782502","dependabot-npm_and_yarn-rollup-plugin-commonjs-16.0.0":"2.2.0-canary-ac56684-1603992700868","dependabot-npm_and_yarn-fp-ts-2.8.5":"2.2.0-canary-0bac20a-1604048513431","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.29.0":"2.2.0-canary-e1dbfe8-1604107228691","dependabot-npm_and_yarn-rollup-2.33.0":"2.2.0-canary-b5be44e-1604213897553","dependabot-npm_and_yarn-rollup-2.33.1":"2.2.0-canary-09e0d3f-1604309936781","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.2.1":"2.2.0-canary-34e1ff9-1604310758182","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.3":"2.2.0-canary-d001d8c-1604312736123","dependabot-npm_and_yarn-eslint-7.12.1":"2.2.0-canary-fa065f6-1604315359592","dependabot-npm_and_yarn-jest-26.6.2":"2.2.0-canary-602762c-1604322508665","dependabot-npm_and_yarn-jest-26.6.3":"2.2.0-canary-b820ed2-1604480543519","dependabot-npm_and_yarn-eslint-7.13.0":"2.2.0-canary-91e1d78-1604714937620","dependabot-npm_and_yarn-ts-jest-26.4.4":"2.2.0-canary-4c0ec6e-1604847720075","dependabot-npm_and_yarn-fp-ts-2.8.6":"2.2.0-canary-649f92a-1605296697390","dependabot-npm_and_yarn-rollup-2.33.2":"2.2.0-canary-0269d70-1605363907248","dependabot-npm_and_yarn-rollup-2.33.3":"2.2.0-canary-3a58960-1605689035938","dependabot-npm_and_yarn-eslint-7.14.0":"2.2.0-canary-2818c27-1605912879450","dependabot-npm_and_yarn-fp-ts-2.9.0":"2.2.0-canary-abf1fd1-1606127243448","dependabot-npm_and_yarn-rollup-2.34.0":"2.2.0-canary-e5f8a49-1606630334463","dependabot-npm_and_yarn-rollup-plugin-commonjs-17.0.0":"2.2.0-canary-03ae7cb-1606761947043","dependabot-npm_and_yarn-rollup-plugin-node-resolve-11.0.0":"2.2.0-canary-a4ef415-1606808719187","dependabot-npm_and_yarn-types-jest-26.0.16":"2.2.0-canary-34f02e5-1606855294419","dependabot-npm_and_yarn-fp-ts-2.9.1":"2.2.0-canary-4c47c9e-1606950885027","dependabot-npm_and_yarn-rollup-2.34.1":"2.2.0-canary-2a58588-1606983746775","dependabot-npm_and_yarn-tsd-0.14.0":"2.2.0-canary-0a39bf3-1606987459278","dependabot-npm_and_yarn-highlight.js-10.4.1":"2.2.0-canary-8bfac07-1607102133763","dependabot/npm_and_yarn/highlight.js-10.4.1":"2.2.0-canary-0fc3a27-1607111306546","dependabot-npm_and_yarn-eslint-7.15.0":"2.2.0-canary-fe4a88a-1607156320137","dependabot-npm_and_yarn-rollup-2.34.2":"2.2.0-canary-f0d04fd-1607234492522","dependabot-npm_and_yarn-types-jest-26.0.17":"2.2.0-canary-d7cba96-1607405150510","dependabot-npm_and_yarn-types-jest-26.0.18":"2.2.0-canary-ee6c443-1607461356691","dependabot-npm_and_yarn-ini-1.3.7":"2.2.0-canary-030ae72-1607626069233","dependabot-npm_and_yarn-types-jest-26.0.19":"2.2.0-canary-571044a-1607640295951","dependabot-npm_and_yarn-rollup-2.35.0":"2.2.0-canary-8ac9166-1607945250186","dependabot-npm_and_yarn-rollup-2.35.1":"2.2.0-canary-6579ec3-1607957930068","dependabot-npm_and_yarn-rollup-plugin-node-resolve-11.0.1":"2.2.0-canary-f6c8ff0-1607958461953","dependabot-npm_and_yarn-eslint-7.16.0":"2.2.0-canary-8c83479-1608328920954","dependabot-npm_and_yarn-fp-ts-2.9.2":"2.2.0-canary-eac3287-1609165037285","dependabot-npm_and_yarn-typedoc-0.20.0":"2.2.0-canary-7940737-1609181462419","dependabot-npm_and_yarn-typedoc-0.20.1":"2.2.0-canary-94baacf-1609219702885","dependabot-npm_and_yarn-typedoc-0.20.2":"2.2.0-canary-a4106d5-1609264839516","dependabot-npm_and_yarn-typedoc-0.20.3":"2.2.0-canary-d56044c-1609272411001","dependabot-npm_and_yarn-typedoc-0.20.4":"2.2.0-canary-eddc81f-1609286731039","dependabot-npm_and_yarn-typedoc-0.20.5":"2.2.0-canary-76f91eb-1609363008090","dependabot-npm_and_yarn-typedoc-0.20.6":"2.2.0-canary-1df0042-1609465244060","dependabot-npm_and_yarn-typedoc-0.20.7":"2.2.0-canary-1df6210-1609491543593","dependabot-npm_and_yarn-typedoc-0.20.8":"2.2.0-canary-c94b676-1609541250701","dependabot-npm_and_yarn-eslint-7.17.0":"2.2.0-canary-d9a7289-1609557116418","dependabot-npm_and_yarn-typedoc-0.20.9":"2.2.0-canary-04c35fe-1609564213563","dependabot-npm_and_yarn-typedoc-0.20.10":"2.2.0-canary-b3f7e59-1609638935934","dependabot-npm_and_yarn-typedoc-0.20.11":"2.2.0-canary-6acafef-1609791562033","dependabot-npm_and_yarn-typedoc-0.20.12":"2.2.0-canary-d2580ef-1609806752672","dependabot-npm_and_yarn-rollup-2.36.0":"2.2.0-canary-f24c29d-1609854120453","dependabot-npm_and_yarn-tslib-2.1.0":"2.2.0-canary-7d91076-1609889808530","dependabot-npm_and_yarn-rollup-2.36.1":"2.2.0-canary-12c6a04-1609943996350","dependabot-npm_and_yarn-types-jest-26.0.20":"2.2.0-canary-4ea6e24-1610012193119","dependabot-npm_and_yarn-typedoc-0.20.13":"2.2.0-canary-d0756f5-1610061447005","dependabot-npm_and_yarn-typedoc-0.20.14":"2.2.0-canary-d09cab3-1610223918629","dependabot-npm_and_yarn-rollup-plugin-node-resolve-11.1.0":"2.2.0-canary-d12f7bf-1610710690993","dependabot-npm_and_yarn-eslint-7.18.0":"2.2.0-canary-a8c4dc0-1610752676343","dependabot-npm_and_yarn-rollup-2.36.2":"2.2.0-canary-7702c87-1610778995736","dependabot-npm_and_yarn-typedoc-0.20.15":"2.2.0-canary-42d0b11-1610820742268","dependabot-npm_and_yarn-rollup-2.37.0":"2.2.0-canary-3fe7b14-1611045800944","dependabot-npm_and_yarn-rollup-2.37.1":"2.2.0-canary-c171b5f-1611145520301","dependabot-npm_and_yarn-typedoc-0.20.16":"2.2.0-canary-2ae1c10-1611270905893","dependabot-npm_and_yarn-rollup-2.38.0":"2.2.0-canary-8186b41-1611333161103","dependabot/npm_and_yarn/node-notifier-8.0.1":"2.2.0-canary-4f2b0a5-1611333330663","dependabot-npm_and_yarn-typedoc-0.20.17":"2.2.0-canary-2c8f18f-1611433272384","dependabot-npm_and_yarn-typedoc-0.20.18":"2.2.0-canary-6476295-1611517165323","dependabot-npm_and_yarn-typedoc-0.20.19":"2.2.0-canary-71403ff-1611586337939","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.2.0":"2.2.0-canary-3e3bf94-1611591136236","dependabot-npm_and_yarn-node-notifier-8.0.1":"2.2.0-canary-c5b1c8e-1611616463756","dependabot-npm_and_yarn-fp-ts-2.9.3":"2.2.0-canary-685ec6f-1611616501032","dependabot-npm_and_yarn-typedoc-0.20.20":"2.2.0-canary-989c4bc-1612125201183","dependabot-npm_and_yarn-fp-ts-2.9.4":"2.2.0-canary-3ba294a-1612355534064","dependabot-npm_and_yarn-fp-ts-2.9.5":"2.2.0-canary-30424f4-1612365022004","dependabot-npm_and_yarn-typedoc-0.20.21":"2.2.0-canary-f9ebbda-1612548396362","dependabot-npm_and_yarn-typedoc-0.20.22":"2.2.0-canary-35f44d8-1612628918941","dependabot-npm_and_yarn-typedoc-0.20.23":"2.2.0-canary-3b45dc0-1612652123363","dependabot-npm_and_yarn-typedoc-0.20.24":"2.2.0-canary-46c85f6-1613014649080","dependabot-npm_and_yarn-typedoc-0.20.25":"2.2.0-canary-c1377eb-1613360907645","dependabot-npm_and_yarn-typedoc-0.20.26":"2.2.0-canary-256de64-1613791336345","dependabot-npm_and_yarn-typedoc-0.20.27":"2.2.0-canary-b31ddb7-1613865691863","dependabot-npm_and_yarn-typedoc-0.20.28":"2.2.0-canary-f26bb6c-1614045955609","dependabot-npm_and_yarn-typedoc-0.20.29":"2.2.0-canary-5b778d6-1614835210295","dependabot-npm_and_yarn-typedoc-0.20.30":"2.2.0-canary-29ac99e-1615048126690","dependabot-npm_and_yarn-node-notifier-8.0.2":"2.2.0-canary-2513454-1615504600091","dependabot-npm_and_yarn-typedoc-0.20.31":"2.2.0-canary-d9a038e-1615694071013","dependabot-npm_and_yarn-typedoc-0.20.32":"2.2.0-canary-70de224-1615752334748","dependabot-npm_and_yarn-typedoc-0.20.33":"2.2.0-canary-8f0b3f3-1616376550832","dependabot-npm_and_yarn-typedoc-0.20.34":"2.2.0-canary-a89c80d-1616643435843","dependabot-npm_and_yarn-y18n-4.0.1":"2.2.0-canary-c367dad-1617042142885","dependabot-npm_and_yarn-typedoc-0.20.35":"2.2.0-canary-eb1d297-1617481021285","dependabot-npm_and_yarn-y18n-4.0.3":"2.2.0-canary-ae79651-1617833650983","dependabot-npm_and_yarn-fp-ts-2.10.0":"2.2.0-canary-71f85a5-1618395738992","dependabot-npm_and_yarn-fp-ts-2.10.1":"2.2.0-canary-5aef52e-1618482936504","dependabot-npm_and_yarn-fp-ts-2.10.3":"2.2.0-canary-29a0468-1619119223211","dependabot-npm_and_yarn-typedoc-0.20.36":"2.2.0-canary-d532bcc-1619146278394","dependabot-add-v2-config-file":"2.2.0-canary-0c45632-1619730309288","dependabot-npm_and_yarn-fp-ts-2.10.4":"2.2.0-canary-36faa4f-1619801372643","dependabot-npm_and_yarn-fp-ts-2.10.5":"2.2.0-canary-d07768b-1620027891379","dependabot-npm_and_yarn-handlebars-4.7.7":"2.2.0-canary-81f63bb-1620319295257","dependabot-npm_and_yarn-lodash-4.17.21":"2.2.0-canary-127b16b-1620327188957","dependabot-npm_and_yarn-hosted-git-info-2.8.9":"2.2.0-canary-10a8e8f-1620412847644","dependabot-npm_and_yarn-ws-7.4.6":"2.2.0-canary-c6e2fa4-1622413518151","dependabot-npm_and_yarn-glob-parent-5.1.2":"2.2.0-canary-765488a-1623104179194","dependabot-npm_and_yarn-trim-newlines-3.0.1":"2.2.0-canary-f4188f1-1623190564730","dependabot-npm_and_yarn-normalize-url-4.5.1":"2.2.0-canary-16cd6da-1623276890212","dependabot-npm_and_yarn-ws-7.5.0":"2.2.0-canary-7e703e0-1623881824404","dependabot-npm_and_yarn-typedoc-0.20.37":"2.2.0-canary-e4df928-1623887123897","dependabot-npm_and_yarn-typedoc-0.21.0":"2.2.0-canary-25a9c6f-1623984619996","dependabot-npm_and_yarn-typedoc-0.21.1":"2.2.0-canary-8fde444-1624591472307","dependabot-npm_and_yarn-typedoc-0.21.2":"2.2.0-canary-a640381-1624761508981","dependabot-npm_and_yarn-ws-7.5.1":"2.2.0-canary-7382957-1625005249074","dependabot-npm_and_yarn-ws-7.5.2":"2.2.0-canary-998f404-1625442492287","dependabot-npm_and_yarn-typedoc-0.21.3":"2.2.0-canary-24a1fef-1625946529106","dependabot-npm_and_yarn-ws-7.5.3":"2.2.0-canary-76ad6c2-1626046903611","dependabot-npm_and_yarn-typedoc-0.21.4":"2.2.0-canary-1be33e7-1626053094415","dependabot-npm_and_yarn-fp-ts-2.11.0":"2.2.0-canary-3a9371f-1627289711123","dependabot-npm_and_yarn-fp-ts-2.11.1":"2.2.0-canary-e0ff522-1627470570858","dependabot-npm_and_yarn-typedoc-0.21.5":"2.2.0-canary-e70bbbb-1627751535874"},"versions":{"0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2eca996186282427c518456c6d436e3a67b0f6df","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593.tgz","fileCount":30,"integrity":"sha512-QCvlCZOkJiI6o6wu3srmrNHgp9d4cTfwDI2OJJoyoO9sYpK8wNvul1BkPe4OD9EDoSPRbgSALO7IarAx+3asdA==","signatures":[{"sig":"MEUCIQDle1yuPtODwbUwRE7alU/JMe6OVzl7B2YpfVlidpjA9AIgSFxNhK5KPoqSuxa8nYUFZzNOato1AjoZ/uGGcy0hoXE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33957,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQb0UCRA9TVsSAnZWagAAGfUP/iFf7Es+PqkeAZleaRgi\n2s7PrSiAF53cEAVwPprBj0N+/ysaAf8kWdKYjjzdwY12nuADCmZjn5AS+zLg\n5UB2w2cLpZXYsRAsvZWp02te2zax5aOjjzzXgkN8eER+f45HdRmluY0W18EU\nyKDJv08gnlMvNHBH/j7SUOApCw5XozQTSUk1V84YI9NmRGyKIdtLSBD2Fpv7\n7yJCh5nY7xz9b9GKh8womcCh66BcUKcWBlC0C4ajxdW5m15KtTqHSJIto9cr\nX+BwIpwWdiX6u4HvciGmAMovm1erq2XJrHQ6iENoh1Y8RAy4qHL7DX69SRYa\n8vtE86pDNHSf9n7VZy4O1V9uqieeeNSK7aGEw7kBaCjStwlnFYtYD1Rt+8my\nC3x/b8Aucg4IoA0sQd41I0T5kUH93skhr6PKlj34rjKyLJKEi8TXqxgeyyQb\nXwNwFOx8sTGlCFqL3esUPLIBu+MDjiBzLClcpbcxmEVRLZczmO4URYhMKxfc\nbsDIetBhW2SogQDhF8yfhoch9dn/opt6q7hEe/w1yf1HfzuS2PKXXIa/i0eH\nyUPBURXcsUTHx7DpqGiS08bZV65QhFW5nYZojm5qL/58y1oiwaHAfmPySUTa\n+GsdComGsAPeG6jCxVdCGI+W4RWT9g5oaZZRBDqWx/MsTdolKmeKhUSyrBl1\nlbKJ\r\n=hcID\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"85a2cfba0590eadebad9336e29cfa3fe7798d416","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593_1581366547934_0.25959917073120575","host":"s3://npm-registry-packages"}},"0.0.1-beta.0":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.1-beta.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"003d709bbb4e7068e43d98433fe3c9f47add8d44","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.1-beta.0.tgz","fileCount":30,"integrity":"sha512-ya+/ImIT91Pkzfnzpr44fAf02/9mRTDVKxIRTHS/Kxb/gZC+4cyqdFucET6jQiSVhvFguUx+lvOlNWi2nBbXjg==","signatures":[{"sig":"MEQCIAweki6gn5bXsvcmiXpmMKD7PKeNiAYxILFiI3Bvmy00AiBG0zynT9fSF+sSBI3TwXSGYmKHJupqv1JIyiK8msNDqA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33916,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQb4cCRA9TVsSAnZWagAAHQQP/3XoSeJj8QzibLhoVigQ\nMejrr9hZWmHRcBgumS4Y+7pKirxawwageuqvSJjKa6CfXCo7pNbOZc2qBa1O\nZOoG/rckWBZS12bTkmP98LL6GhWM74V9DEHuao0rNXvpWSL34ZMHFEMyybQR\ndjfiGh51aHsBwbdTylvOGcbltJugWCUI4i9HU6EBsv6M0agHxCJPfERecnTH\n+ZnMkNtRpZ2KFNcnackwDgCssm1OnHHrfYv+9aTF9TmAgnWPBdgmjHtjX+OI\nuzWaDfr/ppF/kXZdcZSrlKg3J2ZKp+ckQR00Wqg5ZzOs+cxo6SVaQpL4QnQI\nJ1FiojyyhfJ7HqrHxJt4HaBK619AGvTm+ruItJbDvnYT1m4DGeIQYJBLFJ6m\nuBxCUYITQvrTfh66O9ky3dh2BCHkDME41XhOdqrDmIHlZK5ptUaXJm9DwHNF\njjB6xA67LkOYkLv8sJroxnlVNBur/EqtuckkDl33P9ShJE46MQCCTiZYxupU\nZX82L0tio2YT/unjOzZLXkNVggR6QJtw7Q1jn95+lDsUKMz7iK7ilDb/K0Jj\neXvs22JnRqmWJGgi93QV7qX6WnVKPylkBnI7k9JLyWemRhVO2V8PJIfUGYUO\nF7rRCnbU37xrcVSgrz0FAevRMApKbGJGOVq6FX6BsY4FjGIDSJjnwQHqzTZa\nQmQ9\r\n=AbbM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7b95f3be8b6050e85f1fd58df5c9565730307c8b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.1-beta.0_1581366811957_0.9498820029633224","host":"s3://npm-registry-packages"}},"0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4c823c0f786d996dc2e3fbb265eeb920931f7434","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7.tgz","fileCount":30,"integrity":"sha512-fDV/o7VmEtUkQ3Yx1OgE1BqlN+nYUxQE4/4WmjUXUqGOSoyMUXWxmLdQcEH1zMFuT/yIK0OkA9Qwlbhd5x+UzQ==","signatures":[{"sig":"MEUCIGGzqP44fcM/TXeF9REEtvi+NvYCatD4tLUtzL9RN3FkAiEAhQKJV0IICPbuXxc6SSjRlgf9whB3IWAHGTNFktrqlTs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33964,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ0gqCRA9TVsSAnZWagAATX4P/3BCOQ2vD6ngymU73M2l\nWo+6kzBcxm2DdUTUNDdMYKrXmf60kPV/JcPeJqCr0BB//6OWw2T9hhks7+Cx\nxPNB/RU8oDvTNPjkFbjB2ninuRrCKjFSTeh2hV3n9wyi4rygT/Xv1Wwg1az3\n+llXHSuS3yHBepEH1e0je0bVmoio8bth2r/rtZFJWV9Cu/ASXYnusQBbktTk\no1ySK6mEp6XIo2WliiVbMsI/pMmIkDw8ASLW9O7ZQa2prBPynyk7cDzkjq+j\noVK2aRx2TRYWGUHyHn3eCHCmOdiqlvuAQqu6nZMz6315dZlsVsIvE/bNdpEm\n423kjJkzxL20vecvXq4w6Hc7Pd6FNTl227xWVix84vma1R3lKcMAv+HgACX1\niaiBbt7hTyLAinpu4M/XPX64F1eB1SDn0qtsB8vZAaX2JdY/FNW9u8y2I034\n4zpxGSJUqMuoIOQ7L8eIibDWo1Hp84YlW7E8BZetaSjOwMlFOmyWky3kYnTe\ncz8ggrTJMICGn0C97biwwHqNyqtDkwtDsVRwSJ8iX0hDFFdba1z5CsGOBNgz\nxTkVMU2G8YaQzdNAHc+b75b5GpCNaVkd1sBNiXPq4bbyAip5eYnXDyiYWjct\n538KpLEcLFa2BI/c2vyYAQk+9iF6H0ICgosHb7vfKKdIkMp59kU6XiOEmWvN\nl6Q6\r\n=VMMV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"db8a2cb07f89a9ec9764484b971abbd569977915","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7_1581467689939_0.15832070298350787","host":"s3://npm-registry-packages"}},"0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"14e11128d2f71e50d4795759429b344a57de1124","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08.tgz","fileCount":30,"integrity":"sha512-RWg9stFbHO6a7C/wZDxiVVw5Y/8xDsHwhITrR/Brf3pivtWnArc+1GPdTkqhL0MG/B6KQsR5D8C5vrR+MzM0zw==","signatures":[{"sig":"MEUCICi3oPQdXH3y9at7eZg8HIdnA/eawhLtW6Yhin0/JcXCAiEAmT2TadRkvTUyVIEmo+afseSeX4WOyC7CKlL52yW5MCk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34026,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ0hECRA9TVsSAnZWagAArOoP/RHixu3ee4S+0TLP1ueK\n0OxpGTRWj7I3ORC871vnNuckqNrGqoosDjDcTt+SDGR2LzHUmTLEixWoUC2H\nAnii7EMgn9hzcnzCj1Q9sKQ102zmZPLQo7OcafS52woiw/mjyp9ACV/eOvMi\nEckBDqnnhTX/TBYenkVkB0ToPooStG5D+YZnmvplMTpu35dG1pNC7haoF2BE\nUm3oSiUyIvLi5MicAnv71JiyqgsjumraWKTlDGEC8zdm0CD3MMZv1w1OAkFz\n/0n6kQALwyt+66bX0B1W/lhOPzmWvGuLwyehK5bqWvaCTlykI7T8W/GsJ5OX\n6l4MU0tqsp1fYrWtUT5gCm0ZDW4Aq764q8QNm4+V5SLuEzMUW3eGdM1LbVQV\n6ivc4MqarCmdPco2YWtU4Bb7VPMNRy0cR48IiHDlzjZusMGmkQFeTpb1foUQ\n1NOUL3LmLTSq/FXiGuUrtfl6arCF0Rv7N1sjL+glMjNAlJ5uGFqE0JvmpKbv\nReKYDM7ZqzKFj4pZlqo1A/DOX2sG0/dMQEYBFhsaGIrRIVSkl+Eba4OSJark\nU94wxKAYoOQDI2tsyqVNrhjlfbgn8Hu0ExQWqqJwXH82avp+C2GJC3sy5S+X\n3TzHl9el56MofLNf8RKuGXxaVLpAHfMesMIIeN3hqq5vZGBXAGrMZSjPeuk4\neoyo\r\n=Nzfy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"44d0e6e3ba3b505543156ce8e803f68e131fdf02","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08_1581467715884_0.5919431034584783","host":"s3://npm-registry-packages"}},"0.0.1-beta.1":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.1-beta.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6b2d71d5844b8ea84d277c8beac1101015af016b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.1-beta.1.tgz","fileCount":30,"integrity":"sha512-RumRw1eYhTtD399QmiFgJQv8LWYaaoS5rc9spEt3LLr85NObqvJKhmHAAbe8e095ykdIbsf/PoXLTIlrhqCHxA==","signatures":[{"sig":"MEUCIFTXa3E+l9bdI/Me1L6r+f/hJ/ubgOj+f1gNWTUpHNR8AiEAhs4Xs3snVdXVED4rH1XyR4l7pZ0FHnvhikcTVNGYn8M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33978,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ7CFCRA9TVsSAnZWagAAZWAP/11tH5D265oIC3eDlS8F\nx449FbFcqnGrj2C8hGRfSz1lPkLLO1A9W4bnYBbfvv+OBotevQBv+Wvr3oem\nOgvlGlFbj2LYWFscyJTr9IIxh/vNt66RJL10vUP8JB/Z9q1hEqCvov0v9c48\nISUXSLV3lUGknetae0eMxhIhCVske1t9vsPuQ98o1J5MRBW0vC8Fs601vMSE\nbXc5WnJCu7oCRFV9ENTS84UmIr2Sabvt5/4XSdjdw1JINM4HlZyp2RdzbfdE\nVA1t1e18NZSmWTcZTkH1lgWsqLlKqtSinwp0flfVjPkfuypfbN8VXTxb4Rou\n4DvAbvHxTaFyCAdCUaHC5OczO6zQRuIdPSQdHDhlFWoFOpsOxEf2jWwmoyp9\ncwEl6Cp6101PudrSvRdEduu3FSsV7Mf/n9XV45+JB1/m1xkXeoO/vlZTVq3d\neJ5WBRj9IG2HpAf1eCijo0L9zZ2rI+u74SOFoxDO5s/Tae4NhHToQagdFd7E\nt+SsLTGUY/w+h9kCFrCTNd8XFVjKissWB4r6k/QoMXJzpV1dAMA3fDdAOwoQ\nzLdfJvMgBbMKte5SuNpVOnpSw5L3vvpxcVTv01VgDVTJ18+jlO7BN1ALYgNR\nFc3K6SMRl5pQu6GC9U4InqFGPWi5cDG5RhdtRf5Ma5recn6sth3rOTeuvjBf\n8nW/\r\n=C69Z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b08cfad62213dd1472a943cc242c997efe0875ce","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.1-beta.1_1581494404945_0.5577035537887591","host":"s3://npm-registry-packages"}},"0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f":{"name":"@iadvize-oss/foldable-helpers","version":"0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ee662e31afd6bc9aceca94bc69d0e40e2689a8bf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f.tgz","fileCount":30,"integrity":"sha512-E1ND21WS4581aubjEtXBgqRN0w1Zsm0da9MFdTPShzKvElCRkRhECfyal1/wrx20KNDydAhkia+NnqdigKpqzw==","signatures":[{"sig":"MEYCIQDaqJazUBAhvx7EBW5fYU8cswlHqxLmoxJJOBpH848bdAIhAI7dLqueb10AP1x77D/YVIoLC7tHu6XP7kODpHQV7Cid","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34082,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRGLxCRA9TVsSAnZWagAAsf4P/jSl6rl5Z5jz7F6SpiwL\nuQjq+8YWDlDnYUSVM4fzp3Tfs40IluK1MOQ93ZTCrzDoDj1oYQD6vPQ7Q7ks\no65ZCrXQkGar7uWg+c7msOFB2DIJ590JHwRKSIXuJUJEskrho4lvsbysLIoA\nXAysM8KmOV6Q802sheI8AgnHnwrTeMPWAKOn3fp5p+uuq4SD/Q7rghs0fqyK\nhNoF3gEQmSJ1FC68zFpNyUjJ0LQaFj6cB4h/39mt0KQhChISDPDzebDqjKfY\n5GsJBC2ZbG8FMaO14/2L6aemDuZMH4t9SbjnrvTzb9oCei8czBVkI7Feg6ao\nIV9nILv8kZcJc3T+RMmQ3cSuLfQ1LxrgQjyIKw5Q4g536I0rkMCR2Awy5QRM\nH2yMlqG7gRbDDIVP+5R1beTBf4Ijd/npsYg3Fz5wz8QG+fTJp+tQNSS83U/Y\noVuEf35MA/Fu2xE8n+JQLjUhgehWVhSXUK9vFl1OoThy74UKx7OstbN2NlnM\nJmRBHrCerd1XUpGQkDwZeX6FirsKfGN6Wynip73h0LtlhzRNUeum6SHBQBuz\nXhPwokym7/7zbYW7EVcGthY06FWuYqJfYYsmsHBBZ1vy/5H7dOA8w+WucN4T\nj45JC03NsoiVKkStCvm2kUKcHcxkVvznhYxDB3yi4OHiwYnA8j59FfUnQcT1\nxvdF\r\n=vXQC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d6f1f33596351d4ccdd3cf02254b53666b4f8d42","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f_1581540080853_0.3587452705516132","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"65d0f6a2becdb24f869f563a45e33e7e001b3f09","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.0.tgz","fileCount":30,"integrity":"sha512-ynvv5DH/Mdh6AD/L1eDC5Q0dG6T+Dc6urElhi1Ykkg/fS+YKqABDWOtd2Qupri6vtEyq5EEmJujsBDfF7ast6Q==","signatures":[{"sig":"MEUCIQDMdxmIUjUggh3NsTYJwlZ/rbZNo9+AhckSfxRxmz0AWgIgE4pb1MhvXdE8XPs5v7kTATVjUjrkdMTeAchobgWZSzU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":34129,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRGOBCRA9TVsSAnZWagAAp0IP/iZrBlhoqIbmNnzW1eLy\nNEmrojbWhbcUdbbuNy6L1av4qNNDw2LXHD0B9SLzTmkEJXDhDTnnxk55rBRY\nTek2yZpNSDTjtiFBeT6HQ+7lhJgh5AdrERxcd36F6YwotbVLuDlKKjbduNlv\n6JdRiQ/DXcXnoPpFMjHNAPNgz1mI0rKAIxflhQcBqQWTT4SqZ6yShFxS+zZY\nHFCd8rqEP4rTV3MW2PDXIxsK1u51qzOeAnx4I+8CVYRaHPLrCvMrVvWK4Koc\nv17+hhBPu2RZTUO1/RqAd3w/4x52MucXjqPf78yXLTP/L9XfKZ1C/KJR0UDI\nWVnTW59/JHUhKqVYUN4/GnzPCDhSXGDoDA4e41DZfjn8Ty+KXW1WNWi8Ooyt\n+EHQsiFWR7PzvZiAFvp/MqiQNlHlx1xgW/NxMSgek8ulf+PwxEHjOzjvJaGJ\nG1gXU+K7raPHe9Gous1qViLYCb72zZLrLGVBSNIEkxX8jtIOT1I9ZZTMOrM3\nUqq9HdrCfuomeEQT/oN7pFZXBxVnNUVCT74NHKqa5yqC7MWsw4Hw7Z+G/xJJ\nbJZCGG1+q4SxFhCBBIOwari3qP52WM7l60Q5g2ZY94m4SdkPV20NzNPEbgbP\n3vM6T0cOl362N8UJ5m4e3Dv1uLQprJaU4Jc3pX/L2HAn603fir99JLYfPt3p\nsTc/\r\n=lozK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"314d777a289064bbacb8f79e44768490ace79d23","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.4.4"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.0_1581540225077_0.982538563262586","host":"s3://npm-registry-packages"}},"1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"73016b9a39c24272cf6f5eb86aea496f83ea47e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba.tgz","fileCount":30,"integrity":"sha512-dMVVSEjbFy63DALd1OCUUk3XQbrUnxts9DcnAtZlodBmUQ8uX1p26z9nr/K4tVhUPMz9/wN+hbUv85mX7rOW6w==","signatures":[{"sig":"MEUCIQCClnm5dpW3IVHgq/1LJxzQtk8cOBHjxziiYlZcNnKrigIgEMCiSBCJYYBUL8m5f5VFH+eHXR1Xx6hirkDjlxy5ONY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35672,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRYN+CRA9TVsSAnZWagAA7pMP/RLFdjYoTGzm/fSiI09V\nOBNmHxxcpOv9m34ah1nx28ZamLylLzw6rJcJqjkoMNFbIF0yHHyyaO0bHsIE\nXKDhT6yhxmjPQPLOTeo7Amb/Sh9Qi03TAw9jlWncN4BE5Qw7nzdx1T67Urrv\nLZUErvSet8pWmojHGbAv49t8kzCCNHPDYX5nvopglGP/awrZAho5BOfN7NG/\nATzRKsFARofG66pW0McEqrYMOvXiWCWy8nKprOu5QAVOuhTd4htS0KOgQwv+\n04Yllho5HGyaO3RehhX1t3FZnU2C4wzYmkkzqjAXbO5/UTZ+h0dT/ogFDxoE\nqtFJGb5greCT0d6mQqlaCF5LZZLm0HlnDoUiHrtVLPLUH1qWQFwAt9+Lcez1\nWodmvc2kOXGkXzZJWulLAqEA7FcDAAU3sI7MzB4BXcNhVUNI4If+6j35V2i/\naujLEKMeSGvk9qpneLtjKUxaMry0k3nf67anGuX0CzG5dcHVbYv0d90yh2yC\nWuCcD6x7tbUT5hyozlEu480RBFNy9a/ZQxyZQhi6rkgDLE6GMemO1UQh4qCh\n0K0NyWR+BWfiLepa9yGoHj0B9Iqww4Hl2gtj0aeQJawhOC07ZsxbXlf1daWO\nVPkLEqtCBxXV0hCmXDTkMTOhJiu0ms64vbvEXuOm2labhos5bB5PSW4zT4u+\no/WN\r\n=Uu+M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9a7ee04e7e3899f10b24bb0667354e37c4720b47","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba_1581613949431_0.9353487643916605","host":"s3://npm-registry-packages"}},"1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c3d1e19c33d4f9be0c75365893f4fc547424371f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637.tgz","fileCount":30,"integrity":"sha512-3ZVmyZc/RwqtSQGPfWGgG+yzqdcRirzmhNpGZJ/nMtjhMyWXIoATzbj4FBqPsEDhSPeaZ52AQH65yhzzQkZWHA==","signatures":[{"sig":"MEQCIEKn4Tb17P03hWv1Fk68ppJ+vu2OX/B3B5UiGaf593cmAiAf7n51oLz/ZcVgLmwcqkGyMW7ji4Zl0WK+pzd4VFBihA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRYOSCRA9TVsSAnZWagAAprEP/ilE8ON+BCeajcYDOReZ\nYcGo0B10caVEpNLCwWRn/DzPAoEAoPeURBaGHhX2akP8dAPGPk0/PuBghmEP\nwQkv3OPEK0XNMIfAq2794k9ZHYfJvluqXjnqD08tKA+tMsYsS6qff9U8Sow6\njA94vQ7aKyE7q/tsz4qZJPo2z6YYn4ggoQAQJ/jjFYkiWNvOJegTqi4U4tAE\np2IAa4OgvPzlP+pVlkGgPIfqU5mbBZFI5UJ1Lt/ks2RuYbu5qzApIZfTSGv2\n8SotFWqVx9bZj1Jmsmhm97zzr28WTVVIgy0A/oN1vE6l4FSM9/bMzHjg6/M+\n6eZPmA+33TeUUkrcxMgHxeMOePbfeIgmqf966S8C3Ir4crF/NZh+sDKqnAV4\n+KGJBOXKK086cxSoNGUIO2iM2bEzqUZFW63YAnZKMMuGt3jsrW8ocTEO7JfO\nmu75cXeS7WtUfURiMykj263YeHSjmFEck6Wh+O9gi+K9HP43+9jkLtaQACCW\napSBhR82DNbK+m2kLkKW7T0dvIK2O+BZR7o5BAQo18NWCezG7ZuiJF/1HWvH\njjWIMXAwBQUbMiuSAAVMKJZsCtAqN9FFQsVkyWEav5D4tLqViobyUQxgsopS\nUSN2xsYLTxQ4RrX/ReesTaVmoBNgXBdo0jrIw5F9G5Em4hdMJZ14JiK7+GlK\nMhVS\r\n=MMsm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c720cd8eb86be1e772fac965633d64be347afe2a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637_1581613969991_0.5274127033568083","host":"s3://npm-registry-packages"}},"1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3ba30f01af1243de4e25ad8eaa54b2a257b4cb6f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145.tgz","fileCount":30,"integrity":"sha512-YY6bchP5E6pxisz1kJx0csD4o+G+f36dODt8ny4L3+7K0Kk8csBITKnj3BKX+KNfPNe1Sdcj7D2zg5Pmyl3WSA==","signatures":[{"sig":"MEQCICs1Axw+wd3st955vSjEM+GUsw80CGIvsdRnChW16uczAiB6PURV22gkXeTzVRKn9E+GqbCJTjKu9wVQGWtLqfOlbg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35725,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRa4KCRA9TVsSAnZWagAAipQP/2/7QqOCVf6ponbjXvEV\nRitGg+7LjYqT4y6M8y4nVQRguuaoqLVETKr5AG4NcaAmvfCsbJiBtljdYeVI\ngGzO1Jw+FVm/JCd+/kI57KwrH2TpVPYYPG1EWB60B4YzzcmDHVDrxkD/yVaj\n9R3YRCqq44OEOkN15MIAM8zP4o8WOsc3jAlqzdryKEayHSynXngTwhbvI4Nz\nlleUKMZUW3M9rtuJo85PvPkRQg3dKN8wt0+1kvi5igvQwDNGY6UrYpyj8EQy\nQo14/HuaNmjG/8GdNrU2s2uQQzZbtfIZkh/O5shvLDUndwDprHw+AjVHCoH6\nfBB/DyxwHruM3lHo0IllAAiEgGaO6kixIInVcLyV5XHeHOvCdryOVmmLCyxe\n6vy/vcyjcb4UWLXBIT+BD3kkvmhlUk9+dx10pfxQQBbL6th6JzAMqqU7hD5F\nibKL3Zk1n2Lpe4ZlGD1rPQ8ruJLpcHYcOsjgpifav10syrpnywDde4eqw+7r\nk2Mm8oM/YS0/tZOkThssFgzXAqELDhj5+y+wwQWhGtGuyIBEf4E1UpFILVCh\nkmnpAqxsn5AlVcRgHylDmP5elKuhfMW4tNBaIr/jQTswo1hzaWO3cAs3Rix5\n2H8SNo38YCs4UwYLkbKgUN9lLGWkL/FX+pzzWkPQtHNTYEhvEYawtiJh8n7q\nVPia\r\n=BrKp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"301f2cb6718f08816063b57ed02bdc49dfa3864c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145_1581624842029_0.8918053737714653","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3cff9d94f5c152dbe1cb40623fd9680b2fcb5bc1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.1.tgz","fileCount":30,"integrity":"sha512-nM1U6hY3a1l4xAPg6CLNB9Qw33psqgaLayVLw+YwcCa623/ZRHy/M3uWxpD+SBOCsRffwWB5cMv10eQj1Z6tVQ==","signatures":[{"sig":"MEQCIG7fNzPAgTyZbwtm4CS4gth/hexdBa6luCChpGzLnNinAiBS9HQhLxvrPhzEOmgkZ0DY2RebYZ0EysyQjWf4uYGD/g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35777,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRa6hCRA9TVsSAnZWagAA01YQAJcgzD5t+8xotUMJT1c5\na+jJBox4zFNcNQJW7aIgkZxNN1hTUIA7oDCw7ytyEJO5KKb5BXVOPRl5EvcB\n4v8iFwS3zYWKRRnXoTKAfsZ60BVsb4DOyQEjNaJ/taCuhawJwvD1ZA3w73FT\ne1dwZVaiW+/eHFHZLw/RFuRmsSK67Ct8PlrG0eB+HeWWLbMzbU8nehPDa+Yw\n5gxACUfV9ZJBGD/izmDmd0GnZpHrIT0JJC/YS63bFq/Kt95humA5eulR4evt\nN3OWC4hhmnOFvT5liISBjyRrDR3cqGpdgmMjAM3lkM1CuHq6LMA5kDEHtLUT\n+kSjtPFCm1o2fjGQC6MBe9irs1j1occ3DZZGeWXKTho9fFFS9nRCpJ6GOUBC\nEaqkazmvm7eDI/YUkirESbc1ahy4sAr4vZo9UfvDRmsn6L1fdKz2gX4KbsQV\nLVhSlcGQmBOm2fhWVovfmM24GWLw8q4lvz4LhD6B+3nA0zhmjYfQSjMT861c\nJp9EhM7JreIm/1eM6oPc9J6NW+UamJI1pRFlPy//S2+5/O/9URFeYcM8Ywuv\ns7XeuikwuVnuiB9tTt2sj2ebAwVtApKCkaU1JmsCnrKiSWPat6uIOVphgYhd\n/naXDCOEg3O6WPZ8FcQNA6AeuC28biyu6HXz/K70JYQwdKglFB/cBFk0TZEu\n9Kyt\r\n=U0xf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"c28e08eba55c12f160c5c8e41ef358062e35bca5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.1_1581624992711_0.9858893159173123","host":"s3://npm-registry-packages"}},"1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d32e26fecfbba01acc300bd5e48c3316d454a18b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc.tgz","fileCount":30,"integrity":"sha512-t7yHBd4ADNPOUuGQxmI1/3t1U9QQfZRqAGwVb2a4CWEpGUE9XW3Ic+IHd5uOmGlIqtJ/IFnPI5F+HepQVKjI+g==","signatures":[{"sig":"MEUCIDu8eeYlPZ0D3AM/dKC8be+Yc+ZczEhiniP5v2YjfYEWAiEAmV4id/NQok760cSngDU6BPeAVFvVjtaA3eWD3ZFTPKw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35825,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRk9WCRA9TVsSAnZWagAAW2sP/2wTwun/fdsbB6YYkOiH\nC/2hIzQF0SWmpYro3Wq8YVqnPhArtZ1meCiQQVajQjafQF5TvTZAzRQxzYLE\nwYUT33g/ZCXxGkMzAQXftYiIgXXSxlF7RQL1TAXlfGbIBgTDy7+OTwZh/Q/T\nTNfkJH0I96so8FVmgaa4SLcnSWcp5nJKYiqZ4Ksmt0b5cbGryxZRxfW+SFB1\naVoFOezJGAbKzPTg7WxzmZ3xs+P1BMPu1oyNdo6S5WLTdMpQrE5vYEdGWqxm\n9fMZjyC/T7vVK7iDdbXm4Vi8JH8l+nQz5scml+/N7EmMuyyT6s/PRGYrvvkP\nk0zT2T0FBLIdpVV4in5+BorE0GGXGvoXGgko+zs4NRn9P6hhS0WJNlYBgaOB\nTOjGU1CpjnAHrUAJRRESuRlt9PUOJyRfGNCBOiCDEso4NbFun6gV0XCTvZmb\nuTefqzuB4t+zr04sJalqWJY8miHLONLPJLo7n9dM6ctkPdo7SIDekSjAT9fq\n+5mV7BXUqBG1eb055BlEi4We3qgAyoXvsFlPwU4UXZl21HPunzJ5S8BDT5E/\nXWdveCdqj6A8L26stfYA6PpY153GNsXVrqy3UNs0bUiDQxXn28BETFHVJihR\n1may1+sRZdJYFY31oWqgRdhJ8EmYG7kG0iawRvG8OAtaoC1I2bWHchXKojnx\nxeMw\r\n=bRfI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d9429927c801201b030cc4464fdb214cffb14e9e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc_1581666134094_0.32704490008426657","host":"s3://npm-registry-packages"}},"1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7b6c138cdb1a37447445cb025850581f97da77e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405.tgz","fileCount":30,"integrity":"sha512-uBlsaSHpGlp2l8cY4wWIf9KfjzK6Qucz6+9aQ49YY0SbhVJRPTh6XPp1AUAKagMUyQAI1+pmjOU+hGyDQFqg/w==","signatures":[{"sig":"MEYCIQDPRKn5u4umGS1AorIOcyOVlNEkSX8DvZUMzntQSgBHWwIhAIfWPWkQp00dm8xPw6cPQ8+4b2XxtYfW7HsW3TJ3RlyO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35880,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRk9pCRA9TVsSAnZWagAAakIP/AkuekjJtZYEKrmLmXuo\ngxdUhKhxWSfGoe0EyufWjNV2lbu4/u1QtSHGGPuzt30SuqCAVR9rZXI6biJ2\nzEgaA+sCYp9snUFwVO+ob5UGm+F6R94dK0wpOgrtGX/9v+m+UjR72JiF0Avt\nEU9qlRqEYnZ5msQ1+Uj/qdd75in5KfjQJq87x99ohMzPAVMN1q3HsjjezJ/8\n8dKGipWu0BRfiQMiUHXs6A5JAGh9LdJm8RT6yWUY9MuA8QDtxlu4ElqA1hbR\nYztKUy/Xa/IasuQr0/lRVUtMuQmL+8kj1KNLmABGJbyQEiipd6KfP73Fo/YK\nrT0ho08mkexSEMmEXDQ9Wxub/osfdGS1Duhgis0xiTg21O9XGHfdhTP76cwM\nfa5E/3zD1nPL5CxnYuhG644oW+vPfTdU+aIqP49UKwhudfR+XGRKYo6Z27pB\nIlnaBgO+fVrP3gNGCY0DmjsP93jDveZ+U7thb5guMox0tejLw7euvBvIhx5K\n8tQuTturdrvou1s+2Y17LSVgaOC/XYoXcObRVC7aNmst3IajLusKmod22eFX\nhYU8NEuuRRSOmNdVGx9X2GEVK0T2HLYQo5UrM2kZF9BXy7xXpUdRJhzuhPKB\nvMKFRbQPlsGurW1OiUJqRA6hFKAq9flGvQqjmgFMIvca5JhiUsPk5QQVlfTE\nmdrm\r\n=MrYp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e86fe070920d3879dcec704b06a1cc3224abec5d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405_1581666153148_0.6792935382856005","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.2","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.2","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"594b1884f6833bc05c6ce5a5280ecd39c40c04d0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.2.tgz","fileCount":30,"integrity":"sha512-VjLewF2KA9KzMbocZrqigwHvMIwJ2uwDXhN+7A5VrWlV2avDcvjmbcwnrr0Mb2s8d3SZQ0rMPwQmHC0SNbfg7A==","signatures":[{"sig":"MEQCIDgMhvtdUV/DmcLkbkgvOMc4m4sJPZItVzZEPUQZ9hINAiALg+s3V1iLp8PfvlQ0R2rtsXnki9RoHsFkUSpDU0rKjA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35933,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRm7XCRA9TVsSAnZWagAAXb8P/3UMX+lEGU/2U2UnToyy\nB0MZDKkMxMIllJXVYhVMb1swIm5dXcijMOXuRDw3b0f7IjVUbDEJk9iy118R\nYlZRDxd/oi1IHUNF4eAh2CEC21OdiA626zNRb8iMK/1ktG6/4frUS31n1dUi\n+ChboO85SGHUl3E19vhd4mTqT3lNYdH7XhU8WgLSB+/xHN5QpX1yxxu8GR9Z\nqgsYgTzwoqmbf+DeRi7M3kINmMpLGJZSuEOrz1XTgGaA4rELhRZKnLedL0DZ\n9gdqY+yuLbENGM3TrXmbiL0DPjAUGRB0CPnoAAES2AUR9KMJ9VtTtnTwXU1j\n+b7QS5hThqlf+ZmM2gubTJsSxpMtJoV4YoAdKs0U/ip2SOO+ne1ZWkdzuz68\nNaMyf+ed/G2+cz888EFMvw9YrwJvcnnym4G11/USwOX7E+FyqU7KBaLIxbwi\n4use2jfaPn5aXlIozBHbwoeyWx9arpQJHX4WcFTLtucjFTFYAVvtCqbjB0rM\n6kVDxiaHR5jlbucUxwm+Z0fpXbMyXBKPUz/bxRppIT3sdwrZFYwoZ628zzPG\n4QgcQgqZSx1olMaF77GalCsF7e5FBLJBqgCUijNViJFMJZ9l/VHEi5SuudXv\nn+y1ctIKSXKnb+EahaBKxx+onnYCtRQX77Sb4nOvrNZ595Ak881I/S48tYqq\nTTjO\r\n=QHRf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"88a0f7a2c6730554912583b4eadfb7223e97294f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.9","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.2_1581674198819_0.4799436408447415","host":"s3://npm-registry-packages"}},"1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f62b33604b46dde65dbd3e49a75c343afb9851bc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd.tgz","fileCount":30,"integrity":"sha512-qS6exjWAQ3B40XQ3+Yuf7k4B4bN8zOLt2Mpms+pz1Az2liaesTkbzbPjfgYxLd9XF0Fm4bmoAfajHHdkaJDQZw==","signatures":[{"sig":"MEQCID6nu0g5UCGHLq2aG6fTtHCRFzW/4zrDVdFlEiv5TiuRAiAHefWBzux8MHtOsC1YoqQJO9wn7JLg5O6XF/oCDLDF4w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35982,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSM/HCRA9TVsSAnZWagAAUdQQAJUbMFT8H7awPTh29I5f\nonCyu5S8odU62ehLRFChB0Ay5Y8Fs5QQgCsbGMt7vNsdDgdJ6bYJtuhOts7n\nFhyHzGNioyHycaUIYWdeFQ44PYjztr6p7ukJof/3H4zZqF63UkgU7BEPtY0e\nUbq8H4A0ksDQ2kUGbX4yLi2hymwt6arBdnKAAJDF3eIQr/2se2ZX6BGfGPbg\nBgyrvv7dxw6Ev1le4Sh8YZQdRwTxD9JG7j+DgPyUUmU7ZLbiJLCwpxxL8ZCW\nLI2WCnds700/bc6ZDL4nQHJWipxsWwRmhd9R/lWsW6cFuM/tgLFptCDtuGms\n7d8wFf654Z30f1sWxhEDBH+tb5I4gtB8vLLbHbu9Ev8mcCNOB5vJkOAFPbBY\nt2+jqMbRFLv+G57fZJNltCaC7HrxgznkiK7PiiFYRwg3/XJ2qIkrWHhOL1jS\nxcHIs6KgvTpccMUX66t16ul2QgJbzMi38jYRG11Ji1ZZo8B5mO89tmeq6R/u\nR9tk0QDVmiVs9o8muP4S72La2obIH1RynrrxQnvZVK4xYqj9tUvgyBirB8B4\nOjQITOuy/8DXVIpCNEGXTqjHUROU5+eRM4MLdLuUdmaIYtz2K75AXRnkQeGs\npuKodmnGXB/hngmmdNU/jn2DHTIxyUy0S7IEXK0JThCvHfHiMEGy1zK02Mpl\nUyzx\r\n=6VVA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"98675beb2dab9903b1d16fe0d2a293a0af6db549","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd_1581830086935_0.11039056277962267","host":"s3://npm-registry-packages"}},"1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c975f60a910f0db6c0fdbf3aad250cf20412f38a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2.tgz","fileCount":30,"integrity":"sha512-7ZPTp36sVWfAKU5QRmb/cZZEQd0GZ+mgX2Wso36s3t9R90UiKX62OPbn5CtoP/oacQD4ZTWZdzZ39wt8AVSvVg==","signatures":[{"sig":"MEQCIC4o8AFRmxCbsgFjsu7WqBgz4hSAI4Rg7PjzOtLnut1UAiBciYlN+DOEdApDBbTzGr6w3VFbUYYNgPODzVP5bRj6dQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36039,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSM/nCRA9TVsSAnZWagAAuTAP/RkiMLgEMaNqo8oJbTol\nTPykIQ12K5eLGSwqrEyq4+24lBIrt8c5KZYKDz0nQHbJB7v9R+N07IZ6f5VR\ncrXFqo00ndffmJBDuTlAweUSVY7ZR+LYZLDfDVD8X2IkP0Nag6NQ1jJW91Yd\njsojwOLUyT8eOgYsokTrgTu5/EiUU/4Y9mivK80AMIyjmTLDfBXgVFRHXP3j\np8kjM5peTgXClJiHUaMlc7hqOpEqkdQrLlnjDsURDylFOwDGo7ca90W4rSr3\nY7CGNeDPO2MGe41qTc85EIchbjWmt0m5i+nrmx7EddTyE58Kbaisud6sg0yz\n/52WWmxopQnI0rqYkyGkq3LEQZxtDvtYRWty1lr196BNqrsTxGXA22vY3Iui\nlE2KUguv3nKOUF2d0pxNDoNH+eUnfukRqc0wDDPpz5w7fcrFe5M7Tz4FV4V1\nGs6hb/wGoyW8wPcf8b+XzZTbomPX8K6ADrJX/jC/qLMXhzy3wE2TroKVL594\nga/LLa7EWgnQytGuQ6Rcr0d3M6EDpMsa/w99ZatlRCFdU6yCAdHDmcZ7xFST\nWEXbH+ugM0UEgQJVNM/R4bZHu29rnEMt9fejHy17gFTph6BHSaGEsdgpfrc2\nBM9qOegvMaQRiu2hmfH19FvXRBiFTTMmYgpg+GE8IQuYdz6eL1gXx+IGnCNx\nypKB\r\n=YGP3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9929d517610d454eabaf155d1872827a1bd87ebd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2_1581830118768_0.9761184656603668","host":"s3://npm-registry-packages"}},"1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bd1cec1590e51f6e6b3565cc3df3176d7596ac7d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e.tgz","fileCount":30,"integrity":"sha512-i7vneNUpHN+29xhrkK/HGRz3R14Cfp4Y7QntA5TdlLF+DMUS2LbDqfQ6ZJdHbG7EgasIBzMMrPDANSy4dGEQ3g==","signatures":[{"sig":"MEQCIHXHZ+xe6nzObZpRB5i1pXSrJh3Acv5PTgSGEppzfaLNAiB3I3Pbs2xbpMpchUxAWS9TuO9fA7gbSxXQSfaqiDN87A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36039,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSlVNCRA9TVsSAnZWagAAoWMQAIEpVwNW3cFyd+H+MunA\n2pUvaXD26P8na1UW6ms1E3/9ELrMO7QW7YizriWI/3NAILdyMbXQ8AmQFOvl\nvphFbfbljtHa2ktHRnhlGqkU0quLrAcqD+alOJ1/vTFEWxlw+iL4J8Y3D87U\neTztFpWwZ98HYf+dKwSRYG92uFYVOY2p3XpqTlQj2ks+0jiNpzfuEbdyBydl\nwsCuRFTn8LL+ZV3zUad3q3QClceTdaFiro/MoJSlioqCOpOMWtFXuGsHHsbr\niTEMUbPB/W7N7ppepXPtlh65r73uZ0sdsm6im6z7hnOzfOQZPHRp+NX/H2AA\nn4dnWqFLKjaMCAJ1VQjDl5TRZdMBEFyoK91GMpdhcaNUI04V7fxQYK21FCvT\njF0bowgkCdeWgp9bbdwTBQ0yhCqTMwXjnyejLNSHB+QYco3K9zey9Vmb2tY3\nBspV+FoEHAaZRTeihtaaRQoKsFpU2eCNdki6lzh7/6JDuA5dqaidyLUmxktZ\ndnWAmFuzFzlpAAjo2amr5KN2AGP7kfmzslGd9OlAbky1dP2eGuUCHwYI2oCj\nwsV/Vei90G4CqNngaDgXmSyHeNDlS8z5L7jEJ7kGgiOehSho/NjdfIsydhJG\n8DHb7xDqg4YBVS2tUPIjTLjX5j0bksUnQH35b5qoj0ocyXO2zdGhOahfrTPg\nXmYL\r\n=9D7f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e9ae2694588071749c9958f5ca0875054c6b4dc3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e_1581929804290_0.6777564851120703","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.3","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.3","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"78af942c5a10b3d5aa8d92986a8703a44d8e8eb0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.3.tgz","fileCount":30,"integrity":"sha512-M0GBlU1JCQoD4pzorZ00OgJbW+QU9YG9oUKMutdfrZpWTI0SwG6aWmU+KjndhJKrxoFDXUlE4wKczHHgkcTzoQ==","signatures":[{"sig":"MEUCICFB4rfJuQQGZTAByyxVzgZMFNds+9qGjfo08nTdhdYbAiEA+Y1Z7hV1EVq8xYDMIHd4quPEdDPyXRimLuJ7k8IinRU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSlYqCRA9TVsSAnZWagAA2H4P/iO9KY0WGyGG0P8jahBJ\n3rEfkEzFjYpOm/tpW/2SihD5Kxlj3Ma4+9OIReAoIHGUgRC0xWuHEh/LuJdQ\nNdFR0OSBVg0oxIZwjON7+EFCp0x1P7YrGt+9i+tXuU244PanBwf6e1qA4Nd6\nw4qmGFY6RO4RBmHex/eS4FF77xdDsJwkj2j28vPLM22j5wAWl5q6VIfFqEWv\nS0j5EvWYsRR1mBdZFhSAnKOy8z4cKAW4NEwi4W6PvuD0f50sVcyL1zfrbNhD\nJfEApSLJPlr+VX+6DBlmxHvnMckjrpul02D7iWv0SJpVHTAcJlohJgYSieDG\nEwtOllAH1SvzH2EyOi7yDc5DjgpgzZ218zM4PIycmxzxcpjmOoTa6+kXSS+J\nxjYJUaLS34gn7nb3PabQBH2up9I1y0dHnGv7MUjkNawJ0pNMTAcuOzs3SGLA\ntKM7PQalT5rZmYfiNFBXQEu+yvsIRIhOtoann2CctY2qNmyEZaGQXljoQ6nL\nbGYWt3dn+av9Q81mJ8onWITh64YIwV000Yi1C9Sk19WPp1wqEfovm3671j0G\nYeeNPQF+1N+snnKuqId1/MmuApDRCd1pHorqbUO5lOLqlugpEjWe8lPqBidG\nmZiS023pNSd02IFWVYFpP9i5UddCBUnYXOFMH0kPh+xbbKpGMlJDpB2hXte1\nPHxS\r\n=P1O+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"89c0505f6f188e3aab50492ea96e1d2f9a2f7b8d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.0","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.3_1581930025974_0.08418918201359693","host":"s3://npm-registry-packages"}},"1.0.3-canary-81bd91e-1582100757595":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.3-canary-81bd91e-1582100757595","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.3-canary-81bd91e-1582100757595","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7427ff07d36ff25dce07700aeed0a0884ac824e2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.3-canary-81bd91e-1582100757595.tgz","fileCount":30,"integrity":"sha512-Z3+6G/erowQCt47iIM940kA6qAqoByArdk9/+5lEZmNEEBb+J0fenTN0q6L7VuO/auKU2GpI1W2e5tH1lnzSUA==","signatures":[{"sig":"MEUCIQDGU/0uqYYLdkwq9KV9LuHzc3cLy1cBtnuszS9mzvFQtQIgZkzIieF5TB4N/qKIrsd/LoxcD6zk/47n+AJwoGMktro=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTPFhCRA9TVsSAnZWagAAmvkQAIfUQEZMpNSkJUA6srql\n0FhjvjAF/MbY7Z1v95zgs2YUBP9IdcqjVGXFTzm5qbhaajg7SCH2QGHmwUvc\nQtoLTwAKYd9Z/eLBp2cx96gunuO+6Wi4N1yjaTb/S6gZas61OC6ORyjTneXd\ncplcfvK2meHlsPYRGj8/XEwn6BKeAn2bhqqgoWzR5dJb3G3veVUSGVWmElUY\niFzxGcnq1kQS3WqKjGmzi366ja/4DQT8r13/8AXyTkPNTFSuy5JPuHuKTFZ9\nUMKijDwuqv2P2LWGeMe/UdMdrJ4kJDn0F/mz/v/QpcpS8rLIywn43sbag/Vh\nI1ADwoJHCOipky6J6Ld30L7p+FO12YJpJ0bwAXhcFNZelBFv0PH6MRUMtU6G\nxyDvTzkoECSEVZHC2kaKuZAwybCruynu5rJ653eZMIQE39wpPyfDVWwN2ysZ\nalpYI+lBWbtrvCdTIWP8SFppnDV1OHawqnLFzE6NsphElP+nI9ncpr7bQ4U9\nTcrnjr6cBpfdSvZSDS0UveyYiM5lpJIZ0VigEwEb6kNz1WdVMCsqRgLgKedv\nqf5xVl7w+ewGmu1qVgvS1RB9pPFS8w4VvW7292QInO8/SE1/9KUjLXIOmVfo\nZPHl/ShjmUbohIzTOYehhhbdHkIKJL0SMJlQ1LaFAAMWnryVHgoPtZL8THY/\nSE9X\r\n=DkWo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6af687e9acd1ea5581f518383c3a0d16a0982ba0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.3-canary-81bd91e-1582100757595_1582100833441_0.8641088545969202","host":"s3://npm-registry-packages"}},"1.0.3-canary-91942ee-1582100782242":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.3-canary-91942ee-1582100782242","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.3-canary-91942ee-1582100782242","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"96da3711eaa0e14c6abf62552eb0f740bea6995b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.3-canary-91942ee-1582100782242.tgz","fileCount":30,"integrity":"sha512-+PghL/oqlj+J8P78wW3Mk5PHphQOJiKJtDOa+i3rHYrtc8QL0oWo5m3AnPpBtuDORRWyPcDT/pFFmeE8lIKq5A==","signatures":[{"sig":"MEUCIQCC0hLqaigsHCOvpmatKlIO3D2LVlP7KrlifnDhk8yvdQIgUdArstzI6/SHqPcHzUy+pqOgaNzP5kd8n2LmVhHTtbg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36177,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTPF2CRA9TVsSAnZWagAABxQP/34fGYwH4WxFT7ahaVLJ\n4swgFekqr7IOGMYIrv80IcJ2cpkfxAIBooF1iX9FUszWl+o9Gnp/dY0PmuTB\n06xmNu7KPh8GWYdOPXZ+IaRWQss4Be2EyWv5mefLf9BCLEpLc9CVqWecfdW4\nbDbFVDEqatNyfiHxK1gbtxGa9TCRJkGC5KnjP+Gkm6JT915xp4SsX2P+ctx5\nFlDhiQ6/wUtqOWd+9ReawugFptDkq6CUjROjk7qnwd9lXy4tOHOg5RbZSfpa\nO8M8EzHNM9Zt+XfQvp3ZZ4HH4bLULD7ggALjlIKsBLMGkw6J6bkgtscy9Tmk\nK3JjnvNTIcSMZsudj6bQNaDxxmuDEL5o1ZwW/cH8GyXQDqUe2jmX7gy955mf\nexVKksSD8uk6FLKjZj1hfm0EjgNA088aATpv5grjIoBdg0bNB66+HESdoxJn\ntL3Rb2nXPx9JVWb6ooHc6yaR4Lcs5/co5S+cEaHZJerdhSiUnptthibVki6n\n6YKFk+8jvcsmsBycU6oz2VOMXVlUyaTR1P88YrY8SAeXgwAKKwubTuklwN5k\nuj8qjgjEYTbD2GEzNhRcLKIJNjQMqCZ4h2xyTeKF/4/0z5jlJHhaYYMvn1NO\n0WFg/UoVreWZMQHM3Ce4laLizV0fj6BxnA5rjqeeAXD8iqPYdeCV81gGQExf\n4x3d\r\n=74hF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"204006e158ba247e155400cb43518f9b99090fda","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.3-canary-91942ee-1582100782242_1582100854248_0.05934407201316105","host":"s3://npm-registry-packages"}},"1.0.4-beta.0":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"439ac3873d77f7c3bdbdef2ab36e8ca093d4730e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.0.tgz","fileCount":30,"integrity":"sha512-06SS+BSW66Q7SX/9fVyY8oyjeNQlr3sSvU4JqaviqeHu85MUx4fFHULYQ4WIO9XGKdT4P5ceKiRkIOsWlTOlGQ==","signatures":[{"sig":"MEUCIBPDiNDJOjoD+a/z45rK32bLdvaI4GAkIOHnzmnfsThiAiEAuSkT23ksN43nHjApIWmESemimwmtcnIqLpBdeXc44Cg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36155,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTQ2dCRA9TVsSAnZWagAAnwAP/3NfWZBrc7cD/6K4iHVN\nw2z81JGrG+HU5MbdZT7xNhReFZrVncTE6kNHsF0P8Kc7FG+M0WiwuJ8Bso/x\nT6yFuCkIev5+vJ7kHAA6KI2VpSRYxUik61XJ4UW/qoXrZjjd2lQJULenMC5q\n4xlFrfTuOmJ1V4vnPgnyiW0bwJxCwEh9jn49jgAjiVtP/+FjaoQJjJlxeDrF\n8YtNJnW362QVWOke2cXCzh+YHAt4VXNHt/qW08036Sz1EKPFUEUJMb29Iz0m\nkxPi/qOU4Pu/EjceqplBkDcVOcun5F6ON/HuXJYK8MF+f3Lwa3Fh/nmNPOq9\nTkS8GWQ5Z6n0ucMAbD/NqDUVBPpl0Reo+TvD7UaO+bkIGuG2nvVQ/GYUu2VX\n8sIAqRohOaPBJJRyr9P8qt3aPDaMjNped718IgYktyk5tujfI4mP66fQVHWg\ngYD7zMoFe+2/P0Xxuh4fFw72qdJkxvPeRJxNdD1IKSPwphUBseLlryFKcDlb\njyhMetqugdSolcSzb4mP6toK7gGMz4WicHK26qhy79m4jE932X7o9CB6teJu\nEjtDJTfiNgX1ewhQmr0zHvNA6HlRqeqYKZIqxawupOS1cYbJizgzkQoBq6Jm\no8ClLguStYJGeeDVZeiT78evVS3s0rIUWn4hYzCu1WSkbKacWOGtxeKnp7pZ\nGRUy\r\n=AuhJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b9200e60c7b32d8e9a5ee90d447781965b89d196","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.2","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.0_1582108060592_0.98178350398479","host":"s3://npm-registry-packages"}},"1.0.4-beta.0-canary-37990f7-1582141808574":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.0-canary-37990f7-1582141808574","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.0-canary-37990f7-1582141808574","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"403335639de45803ff53d269e53da817d2178dee","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.0-canary-37990f7-1582141808574.tgz","fileCount":30,"integrity":"sha512-c+0jO6gSI6yA4GC6njkVc1eTiEaoCPkpecj0q1pZrlXFO4WIogiTGFWJSJEkRRm7d1vpZOBQxkdlyGxn5akZGw==","signatures":[{"sig":"MEYCIQCtrOrb3CVlj9tseEX4A+4wb9JX7wmwmb6GtOqeTvQsEQIhAPwa/3qyAG00bltUNqEKREhOuqvuYM7hTQHLjXbI3D3y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36184,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTZG7CRA9TVsSAnZWagAAidgP/05Wf+MNReyyTGJfRqvI\nqBppY0SlNoGHxProFfDhzJVHmWrRdnW1EeoZLRfCGO0TLqT21uCs4IuAui0H\nKyaoD0qv2IB7QDDWEMjzODeExeKUxuZlQom7BnSwC6SVhKWQzMvW7blTpuvf\n8xBOAnZvie3p9O5TJQgfrfNWwNLuq6IPQE8kzMAHxTATjOzDF4qDU93gipEJ\n9jipwUsu0I7Dw3PSYvsHjQMJc7Yjz1CLrEiGcTRi4EpzKlV9UsJfqzXLQUSv\nsZp7qebl+s6u2yV4MsFX/TgC4GReTG3AGtoVP22HmNuW5sn1957vmaA70ouc\nNk4/xy9pRwFr+r6Q6Bl+IQ1atZj5CZ8hig79woEyeA2b/HohoJSXxzg+XatB\n7HiKqewXK/5OBQvIC07sdThO9WP6re24XaYsSNk3bqk8fJK/3Nzh8m9iR1Zl\nkZvajNsSzgou6IIqTEb+4KfIJAte8iuAQqW+ss7/YwRvxCptUVVd9mO5xDwq\nUigfqOOG0hln6XKf67FxwF3oYbGKV8bYrP0tjHIhVJUOwbHrIj62orE8QTPM\nyd+XHgFOjNu3yi+BYi/0B0fvsx87EOzJJvDWV0NXtOFLbPwy+gT1aSEvo45W\nHs8mVJ3oHbW9Ti+cchKIO0TTHPfJ/Nq30VFyLaARC4kliU2EGm3GZuqQ1+AD\nsn9i\r\n=S3bf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"649f40b5c14826f776460803e3548653c45d9636","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.0-canary-37990f7-1582141808574_1582141882839_0.27835277230041267","host":"s3://npm-registry-packages"}},"1.0.4-beta.0-canary-5611e8a-1582141839470":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.0-canary-5611e8a-1582141839470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.0-canary-5611e8a-1582141839470","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6c287b9489f7bbb207b40ab1a8d65e41292338e5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.0-canary-5611e8a-1582141839470.tgz","fileCount":30,"integrity":"sha512-96novHOejnoMuPhJo1vgbf862KOhEJz0YQuwXyGDLnAP64t+Y0U4PseNSFWELsGceS/MnARE1l7SGlnP2LqfKQ==","signatures":[{"sig":"MEYCIQCWg3WYdTTEXOKNESLRElTRZEVolPFP1TyVdNnZp5UnnwIhAMOXxUPdvZxZ+3PnUgK1/frKZ/EGZ10O8bh+OPR9a3mu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36244,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTZHWCRA9TVsSAnZWagAAcTEP/04L0PLvFmFNaUKqmItz\n0R6RG7oCifg6brGIlcadLxRFRjnMSNbZYe940BMp1/aSlvAMjFnCjtZV0lGr\nQ3+oRjEcQenxaYyYCo5S+f28h9n5P+3H4Bk9q/Ao0bjBuFVCe5bF8jIIJW3k\nz2hux2q48iuRdCibiPhh5dnuyJ9034jd1vE/nvRD3tr6968v+sNQ1z0ojS5n\ndChD+EAQnLk8Mih4V1HjNjTe0GQ78EG2oQC08disWK75jkKw5yUheFPVWBfA\nM2IoJ+9faBH8vlZgW+pfmcg5j3+bXBt0rh+LTI4U9riZz7fD4AvdIWA4mTYY\n4RWzR+IgTKwLNgFzf11yhNUIO+J2S9Ag+80jIsF+xFaLvy1h+idhJsELIJb8\n63q8d13Nu2Mw+Nzl10zxiJV8Xj83262qAOOiGPp/zDqx5HZLg5YkUyhJDucu\nWq7MQGMkge+2Ecxj8AKYMFbM0t4ctJNjnvBQNA5a8GDZRLfipy+8omK+5F2K\n2Q5wffpg7MACqNIfoaX1TPyvIO3I7kDQ8gDoHUYFK6eRj8bWM7vRmZEigvFw\nWsdmtc4ViWjdRYZhcVJXyGfeZyvCWc4fnGA3msHgL4uvJWvfJyxw/ntuwvz6\npWQ2BpagosmVDNAO5O6Ic7IwporxA3D1bqDzHDYJ2u5bhYlMme7oGnSi/dog\n9FEs\r\n=7qeg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"616824345b5b468762f4f75091dcf23a7da0f1fd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.0-canary-5611e8a-1582141839470_1582141910089_0.3434363178816435","host":"s3://npm-registry-packages"}},"1.0.4-beta.1":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0686aed4fc5ac06d30c06df092dc7e4773f605c0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1.tgz","fileCount":30,"integrity":"sha512-IBoL4wC7UdsdSBo27/M2JRL7nNwxuJ9U0F3agVzOLCfzAAdFDH4zrGpIK4EIlQJv5Xun+KglyDce30s5ZoDpaA==","signatures":[{"sig":"MEUCIGEZk8xLI2MBfxAgyI0rN3+PzljcPXAvVGexCglOa+z0AiEAyutalGlNUTX66RWlwO63VF1YOpUqPHjgjPq+AB0HWGc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36215,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTjGvCRA9TVsSAnZWagAAlBgQAJdjyiSsYk8RQv/3z/l6\nG7W95tWLjG9fW5UAeu3Klc4/Vk/qPLWz4NA15NwrMCL2GE9iNv/D6DQHxWFJ\nGQ+uv+5JHyIOdOX+feuXGKAzRj/pcUDERCkVgM6tDlkk+9XTE6Z36/jq01tq\n8HpRUkpdu0n6fMEaYQmQcqR/gPtpgkmpziyQlbF/pyQPPOjOiBTqFo0Zvr34\njPjCwnwGL5mO58ZVcXFIfOY8sTx+TwUMpKSHqOvbPWBYjmLLJ/A+WUi54+Lt\ns0mWKMP6/C4k374oQtq4jBT2Mgs5lrrcfvZ/fFcRkWMGnjvqs2abHF1P9vsN\n3BuJWjkOHunCEY2dI4yVDfmmQ4TM4DcCOOkE+oEC0YsbPdudmuUdWfFWe3vj\nfrlgLyG+4wor/NVCibsaSGxoTeJ39I9sVosUcgYUYdmFQ6ZiPep8KUDmnXuN\nH1gomQ0rMKVghPbVqgciesNRpoXfJ5CoZh3BvD+oNJKHwPcGYxtnQYWLdeBZ\ngo4zCMd+8KRdqyLN5TXKEibT1v7M++pLMj1Qlt/G/3rawwU8PqA6j8XJmmkM\nsVoX3FsNhNAuSxMy1XCMeT8bdHAu14FvJyFTd1fOrPw4AsU4WAn1CIt/dZB9\nCiIP/A+zTxiZ0Kzg51uecLzHE/+WB6a5VgmQ+TdxL2B3oBci3On9vF5rtRIm\nD/JU\r\n=2P/M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ac4ea24bbcaf6e4fd6e2c06831df2e13c1fb41ba","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1_1582182830984_0.6016870654777868","host":"s3://npm-registry-packages"}},"1.0.4-beta.1-canary-694302d-1582219494663":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1-canary-694302d-1582219494663","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.1-canary-694302d-1582219494663","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cd76fa9cc47f3fd182bdc04f81b081937769f3d9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1-canary-694302d-1582219494663.tgz","fileCount":30,"integrity":"sha512-CFNUa761cb8Jc3MQNFYbDcl6iTEWh0a+xtoLFiyE9dFHF3ta5lQfmwC5bW6CoTcYjmy3fkg18gIAkoQbSbnT3Q==","signatures":[{"sig":"MEUCIQDKJx85kwxpO4x47fTNaDpU8k1AL7T5tqJ1yMuHNjDtFQIgS8fxXuUA7GKz+eJmJGPqP+TsABDdplbuKtTl1O51890=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36244,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTsEsCRA9TVsSAnZWagAA9L8P/2yYpBF3QvH5TG6z0vip\nVjPCZ2xiu4pTavFpgNS6n9ZGpQ0TWvlc5kLfVYRa5k/fgpkEHvggBga5p/Ju\ntj44nNvStpA8UevWCtT2Ts0Lia6eYtxi+fI/M/nkBGcSlxcQY3V+r3kL3N8r\nA/xF8+2/7qoYx6Lqr5oHEHeM5F8wB0rgtqyNVFBMbVi5lmaxZA1OYFsKhMPJ\nU5AjTXQ6dAenIy6H5oTLpDlJ7ZVfCxsKb6oNBUFcrLsPFRk6uzFYj5rkJnhj\nX4iIg/0s0CadXBPTe3ctkSt6Xc1GnoBAGROr8HSmzhnu1ZBCPZh2cY1woS5l\noNUiVG6gLl/vKcSd+/MfC0/t96cAJUneUjMbXjwDHnRWb5Kl4l0ZATZ69vAq\n5hbYi+72gh7EoYaVYH9E7poXDZT9LcUcRWUOf03zjm3f7/GlwCFBXPut9q6B\nskjbFBtit/CnokL13u+prFpqAIcpXrSaYfVscEQTDCVU2XwTw9mPFKvyIFFQ\nCEI8h1efi1Wco5N21Npjh3FVo+YIQ57UP73s/T2zAQyTRtINxRlBjcTcZtks\nL8QTsZlPz/QFRYZXtA6SNk4Pg9sfsbg47Rsti1IsS8WH0QLzbUanrvGMGARQ\nsKu2FMlLA7o1rQSgbvxWy4e2dKu8l6hRqRIG8fZiZHZyzhsJpTsLg2rMkAHg\nVSND\r\n=8UbE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"83e28db4ac1f3016fd7d517b0eda9529fe84baa6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1-canary-694302d-1582219494663_1582219563895_0.7318777486039609","host":"s3://npm-registry-packages"}},"1.0.4-beta.1-canary-c0ae3c4-1582219516973":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1-canary-c0ae3c4-1582219516973","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.1-canary-c0ae3c4-1582219516973","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"980f0e28270f517b387f7db2bb43ffb6f09dc9c9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1-canary-c0ae3c4-1582219516973.tgz","fileCount":30,"integrity":"sha512-Bz+NCRMOmoeBXpA6LMtBzYEM9BjWrvDyrQCCefTEKKLsTJY5aiAuP+PCFPdy2iWZx4vbO5cRfccNYvjAkwhlTg==","signatures":[{"sig":"MEYCIQCjk36MRURfUM3AQjcqmr1OZdAyDncsZuX5Ch3eaPBYGAIhAJyz7wPoMBnI3X07e+RQfv66320PTvZ9qMqq3NAkpBmB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36296,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTsFKCRA9TVsSAnZWagAA5eAQAIWbB8bwV2y0trKy4yCp\ncXimOZ7Hkrp57hr7yebYHdicxYSievTrGtY1pCyevUO3m/MkWYruc1if9h8x\nkcpTWY+IrwBBq1kDLTVkXxkL6lMx5kEYtaHQi0CRK4kRNMSXc1hBeHn1x5uj\nOCwUzbpIOxBqvD/HMZCQfsBlWzdqZPU026Is/8lknCtUNxBGecys7B1Ypp60\nPkgPhQYw4KGPkhP66UTd9Qs9oJF3o/ExG7sJM2Fsag3DJCatBG5YAy7bBRZC\n57AgfU/aGjhwyZMqAJ+M+W5fhUt+eWH3D9yAjbPaG5SSe2rifw+jOUZXKh54\nsxZ33YIxwaIaFYH2OCJa4wlCn5FVSoGbFMkZ496q9OB49blL+t47lpliyDnk\n3iSTCl43QXuaqE6flIy9A8Wu6DZ+yRINn/ABQQXQyhrbGYG3x6uiSCAj05Pa\n8JITIc7v5kGRfaYIpSyHLUP2j6jboseG89STu/j6K5Kz+vdESCkVxUp6Q+Po\n3jfJvapvGr73HiBdf7MsVTK0A4Fyd1U6f25Jq2RyDmt/xwhNnWi44XAqzPj3\n1mFx9QP5WT9wMsX9CDK0NejcOpXEmAsTsRbybhLrkneHUc6lvKbBV/41O8Qd\nzv2DK70oYGbOj0jpD2atrQv3rE1sS5dculIaKcBolCFrpKbfvzFt3QIPQIOJ\nKnzj\r\n=zAav\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1dcb6d37c7b4cbdde325c802e114f3a5944458f7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1-canary-c0ae3c4-1582219516973_1582219594334_0.9994189593956235","host":"s3://npm-registry-packages"}},"1.0.4-beta.1-canary-1bc84e3-1582234206513":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1-canary-1bc84e3-1582234206513","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.1-canary-1bc84e3-1582234206513","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8e7e2c9cbf72cf7679d9f5a4fa57cefda0d2c6e2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1-canary-1bc84e3-1582234206513.tgz","fileCount":30,"integrity":"sha512-l3FRaX2fHbbr0xgMtpvlS8JXSlF5VLb9wAST8pVgKJ/9ZoZDCCi+QljquniBC2PuD+i7N50ljJ/UFMNFHswYdQ==","signatures":[{"sig":"MEUCIFr37JKjduBQ8CME54MuEa+dnraG3c7hR5cxMxdFaJLDAiEA486FzJJ3/jwjfIaTZbYCjGhYIt17n2lq5iLpWMPS5GA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36298,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTvqjCRA9TVsSAnZWagAA8qIP/iey3diPUVGGffiaLJrq\niD8EkLhzNeWDWtYRARcm9u5nqXmjy7wTDlcEUiUmzc4Sw0DlQeJ0tSEYjKBN\n5lzQ5yvM/UQ+ugQDRwh2K3ugZnVykWQHM2+Yxp3etMeyFLgQGrR0/+tjaTG8\nlSBy4FZbFvngzlECBBeK/v47aAqKj6r/Tk2ScG1DRHmXkzuubcT3/8N94FQY\nr6dEThga1njbVdoocKw10BntzNNmsXAyVvgrZn+eEvuzYO/zBJKr+ygcsMSn\nSIXsK2o2mF7Ir7FYpKKVfs6kV7yiYjASRv80CBQansa9RCr0ehF0Tiav86iq\nUFv/gLm27Y+p4zLTTl9QyR0BbqGCSiGciouhh0U0OQ0FVFVFLRnMtVGqR0ha\neAAM8UHvXXcXLrDmc6R3MTiaI0PKShpF+2XhbKFQ0znkqTlvfHdzK5SzhpXN\nb1RJXkUrel73uVE0EtcjIQyA68sSVnaF5PxD8dKMXk0KJBsUjhZvO0xYEhnP\neCdUhUfxVvV2ML/+ol4OQYRG1/jqGT37Q6QbJwIf6OzXkVLV974oj3xIHUer\nmOHeLEwlTdvpyQP2st0jj/B4dx/0reCtbs4kQG+CGbBMCNIMjZC04twOZNEt\ncEZYMOxRhorXGTW+21H84F+6SL1SDt9M/EaVzMH6tP8uZe7x0KQ6zQdoFfZJ\ndB59\r\n=LH71\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"92b2e9262250b4ee6c4869e0636af59b026f25d5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1-canary-1bc84e3-1582234206513_1582234274660_0.5320089097799718","host":"s3://npm-registry-packages"}},"1.0.4-beta.1-canary-1614b75-1582239093146":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1-canary-1614b75-1582239093146","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.1-canary-1614b75-1582239093146","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fcade84d9b07ebcc37b12201c2544965bc0214a2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1-canary-1614b75-1582239093146.tgz","fileCount":30,"integrity":"sha512-QPJK+XpVC0udIunnOdniHOYTuI7STDRlUCRoKtQkruTpQQ9cSaPCwhV8+XE9o6pnY7EO870RduaQgsxUICeEtQ==","signatures":[{"sig":"MEUCIANRVqmRO6ikxrQ24x5BjjvGpbdwFWa5qcSS9mJaY3hLAiEA1pD1QZX1u/Wg+QeNiPwtKC7MPf65KVR+w3o8LFuf+rw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36244,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTw3ACRA9TVsSAnZWagAA3PkP/0MT8S1dEgp86WJuHkm4\nTO/8Bm0i8ssF9jqPdElYdbQ0oa6pAuap8YsyZZT5mISSAXBOtI/UcZ92nexH\nLs8LNDBKb1eQVC0zEVy/pUrBjsnTvFd8TFfC8QscfPcpgddqSn8y39TpTrDi\nads1LXZgMV3f5FEud3haiqAzHgEw5VJ7PUBKFDNXA/Se4Voo65sg9UB4brbd\nltOUMUsPSdzPDrFjjpspmT67+sO3KmMBCcKpNrmPKW3Jd4TyKfI+fP3V/soL\nLLEFTSgZzqoPrjrfzjlPmLgmq05ZE3EL25OW4GTlbmd605nwmMSKileHh0VE\nA9OzEtG2mrd5r3cHFMrF5X5JQOESLRw50BRFN6oyhApZ+vGeJFKisNqJDrWI\nJR/x5Zsj7T5EgTlQeNVPN9bLMSurYOKEDUsvx3Thw1qLPq7iBWPCatV7JeKx\nB/b+lA9JBbiZAKX6aMeVlYBtigQTmNnSYfK5L/XdxfbNIicOg9U61f/EVUby\nrBunt2Ct6Zz3SglShloPE87XJKeQY7SXADPGZBz9qGsGijQH+vhOxc8YcMbl\nt5Kop20Cc9wh2VM+9MSjYAJwXfRG+HlXkFPjTUQXeSM+hDcaJgrXX567W7bW\nZFJikmkRZsCuxChjdQW6/Ycjz4hiJWryQGuSgRf8NvhVEtFfhdsLloe0VnXT\nLyYQ\r\n=30YH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"339b86435725799c9f7a0a9ae3858d28dc92725d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1-canary-1614b75-1582239093146_1582239168149_0.6544201924202622","host":"s3://npm-registry-packages"}},"1.0.4-beta.1-canary-b56c68d-1582239130679":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-beta.1-canary-b56c68d-1582239130679","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-beta.1-canary-b56c68d-1582239130679","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c94839425af92d6e9028a06f0db7005f914e3432","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-beta.1-canary-b56c68d-1582239130679.tgz","fileCount":30,"integrity":"sha512-vb4imi/TQmpA4CKU5OWLXlv2hpzF+vmQ5+PiPIgdkJDwXoTzqKXeukibP+6Bz/yxLtuzT7nYhxnQ3W4oF0CHcA==","signatures":[{"sig":"MEQCIF+So7ZIbE4w6OHcC5u9vME62azGTiFhzCGy5ggQHvKQAiAgBfuTuwbzAN5Xn5ItZIjZ4JPIBmDeemjzCxtpilfRUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36301,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTw3jCRA9TVsSAnZWagAA2b0P/0leED9DHirMxgYmq/1g\ntz2yTVyWZJrbw4DFqnBRbbxr/RQKRO+t6xc3JQwtlEkpl66InfLV7CJ5q5TL\nNYq8LXbBxwT/oVb30xHyuKbDnzlBYJw5k/yYnBYSmF74MtrYfeIICapGmKwF\n2WJCNTa3CNbI8H5QwzcHRA5Ze2/MPfe0lmsTvkjAoehj88chPL12gKC83YVJ\npTM/6OJEyVUYCqsSAfAFdkd3bTy6LUpWnR3DmX40MAuUkp8xx+wuKaq/KM5K\nmtf026qYFSaaaJs9Yee0AJSJb2kOliXerfVF6gKO5wv56whxlC6+lr7I3mpM\nAlfUx5Qjlqyx04fbTRy+Laag7a+OyyneuMdsmhx8moJ5SZFHFVJ6MmtbKaCd\naH64xs3m9aFwDmpZsZ6WesKW03gte91sXu0oOuRh1PHIDA+Z5AH+ehIVgv5Q\nv8uvQ1/jU1sd0l6+mlwTWEAq+K2gsBXx6jfAf7ZXAbYkLpAoyGLlgvM+cFMW\nAyvb13HOAPhdpOh0PL8389cp1WD6LsEyr1N5wiBlbe755K7zAAb5QjNBHZJf\nE/qpo/b45Uxs7LD/6YgtP+oIqaKqy0AjLrG/rng1FDmdvx+o84F2wltXTHGl\n5ZHB2pJKscF1btnpQudn9MYPR6UM5vXSdIxdimP6dlRmpH9SwmGRAdHG5Gau\nyDja\r\n=kjCo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7da0da424db2490f5149b0f72e29cc56055a2097","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-beta.1-canary-b56c68d-1582239130679_1582239202226_0.7237770204722813","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"65d0932f96161f9858b0e1ca93762bf8f2c717a8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4.tgz","fileCount":30,"integrity":"sha512-0dkxR8MaJKVAZ+Kgzhrw0KREsml/ybbbF6xJIDnQ/p74R8TWkqNmnJXAA9+iXBUj1BLAkqKa4Z1bwGtHKtk5Pw==","signatures":[{"sig":"MEUCIDKRRv3arOqY2dgUx8gY3DhRCcd4aR5r+9kZgmtA67bmAiEAyQBnvhuxjjgR0TorW7NCgfqcswj6CD5Mm2kcKECog6o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeT5ezCRA9TVsSAnZWagAATcsP/0BWsD9jHprxtlBqD/9j\ng0SpSlZLKFCRqLJI0eHW4B5DB5xOfQOnac/URvkF53wvugdbNZxfgRMjcc2S\n2eJOWV4hyZ4USbVWi1gMTxJcnFAAfQo7Wr2cKRoajb1uTySSQHEaN0Rn6diG\njvqWN0A8U6mAYryI/T+kvN9fqGJNPnLQcAwVn67VIwt9iyBSmMFdPl5tzroc\nztB1FVof1b6cdNyjP8vLptQAHjQhx9Phfv64d+OjKiuiBtTgSDL4foUSoVOZ\ni+2wAjIVKcVXCu1qT7Jd53RDFOW67ZAloyeHBsPvOlSqEFzfBCpl1OTc8f7d\nqXIpIdQzP/lNq3sL6HphC7lZSE91Q1tSv6kgG9vg63hRj1L9LKIXfNetzXMV\nWAQEjpKVwy8cx/Kf3l7mPBvuI3zloQJ2yF8cu6UOhHZ3pzvvYS7PLLkgAfvW\ne3AlCHjuUG6+J1R7f0TpPcKpkhS1JfCT9bag9aer69Uwe09Hr0qQnVx3muFn\nAOCEVVS6fk8najz7dlg9g/EvGsAUvjARmdWziODWcJbfRZgGL+LhOWKG6cFe\n9Laz1nEBcsscoXCadrRFnw5hacWgBBK6VLGQQgvBU1rLfjMtwAiU1WiW6l4a\nSzR4Ev0OzjY73Lu8I0YDc6zQd29zb1QWg3eP7u/NB6aTcEca9O1G/BoCOVHZ\n2kvK\r\n=raG8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"7fffa9fa3be3f8fb781d928e5915c80d4506b49f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4_1582274483325_0.8417909400243728","host":"s3://npm-registry-packages"}},"1.0.4-canary-a393f33-1582533298714":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-canary-a393f33-1582533298714","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-canary-a393f33-1582533298714","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"16565b9e83c9487014d9215de5ba6f282a7f4308","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-canary-a393f33-1582533298714.tgz","fileCount":30,"integrity":"sha512-rECG36C3xiqElpZe5s3YzoocA6dQ/yBELhGNysxoBuLH+wTFWMYj74EjzB+Sif3fp1hu1WtfavmrTpJ2Wu3FbQ==","signatures":[{"sig":"MEUCIHkHQOI5/aAnLh0TS/SY21S+smPApyHgDfjOcfeTT4r9AiEA5NiL3qwl6R21lKkkeSysBXUlpm5ARVq8vOAPyTKydU4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36396,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU4sFCRA9TVsSAnZWagAA6ZgP/Ap2rmMCmBHMMT4tkU4N\nXs+BRghS3hfMLnLNZ+z5tC3fmN5BRiQmNoVG5Bek+Cr1Gv09xztRjEbQ8se4\nQEEuXWMj1A0eFW+Wb9GJrPLDYQhGd5WYP9QIRbDCv1McrSK7mZ/TUetykp9f\n8ax7dQKSm9n3DGZg8XctHpa+FA9r6wk0W5BR+MhTxqGbbPm7fy8Jy9Nl79rU\nd+aKDUjtFUjvXZ/dFsGrARhhCzK0Izif5I+3SGLv/ny7k3RSLZi5u6tvJC4G\n9nKGOGcsoXhM3RDEtwCtzhYcnS98hCWN7YhE4ksjRtic5eBUauZWBCr2SKpu\n18KWbA2sU+1bv/0pflZP3gN4jphsmEBBv6hwAA4kgmfbUH+U4HzIJPqVOT2K\nu0i0hqV3XfKfHNZ4Lye6a3ADWdmfgpMucvsD/wPtvuJRqYo1+wH8kKkac577\nr7tDyr7mVAySj9xhVbtV5BWz712A7NkFvu0R8nLoW9OfF7f3tMhpSXIIrmGI\nmfu6gJJdWVoxryoscj/sELLvxr2fWn9L0Tin2wExQdLFDZ+sOyPDKu1hkjS0\nATgsXwV0haW18DfKtrZGLIAyQuNYB/uqwa9jk3Q/XRS73P2OV80xz1yi9VqS\nT732bGOjVKzxXXfQ362ypFbKD7B4TixVqYxj/NKVC7h9SOKKZ7rKK2qmoigo\nzzGw\r\n=IoR8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"80396676d5989c1d7646e9f1498dc2b222d8dffe","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-canary-a393f33-1582533298714_1582533381299_0.3361342829320271","host":"s3://npm-registry-packages"}},"1.0.4-canary-46c577c-1582533404313":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.4-canary-46c577c-1582533404313","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.4-canary-46c577c-1582533404313","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d80dc9c209f2a5b73c20ca8f197b4d0d17d47c21","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.4-canary-46c577c-1582533404313.tgz","fileCount":30,"integrity":"sha512-2+F75D/rzrHsEiHmwYyXOEa/Id/EhN60uTKna8xwNu9MrRzCaihuDQiwVJ3E69Puun2zm3396TdT2C1rp6zkOg==","signatures":[{"sig":"MEUCIHXDDLUA8f2H4q/APpK6IEpzh2UTNPJ+Fp8EZUP6/0vsAiEAho9+Cvz7++HDF1VUS4fcqoC4WDi00vrHEBJkejpnv90=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36396,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU4tnCRA9TVsSAnZWagAA9yYP/jj+ZOOXqKDngPqiS4VR\norlJoi1WdKWyWpXtTD2Td3Gg3TqlR+vZHx8MrxTpfTA5rfKNxuyDMvuHthIM\n7VVpAWxcAErQouJlPMEhORbYwVwwSxRCdrL4/MhrTQSlOW/wNZliotuJlpR5\nHPcDD8GxBlg1eEN/Hae0TEoGeicjAvvn0Q5STCQ9A2WNONlyVQ9e5YpZDwNX\nYHglYe/gqHVqL/3vG2VJzu6CwbacxmtyjeDLAqhKqrid4tgGGsEv3MYn6GUA\nl+jqJyf1auyoCXh6A/WpMnv9YX4IsfE/UnIqXbVVHAAGxmgiwVOzAILQf6xW\nodHN/y8FMia+LHoTDQk0RQCG03vd3IEOVvBSIjI3aWuyh9+qaqSzxdlk+uRj\nc7kxLPyz9FCfXxxjYnl5c40dX7RZ7WDBkXMocNAT0KHBRI0wHtuKCCBy2Q9o\no8d4khvW3Hqw72bNB5kRi1v/L614/h7EaDesudebCL0lv/pnaLDywLA9r5z2\nFk3SCQAHIC26XTB+VvjkUwLhrJ5Of41fLgAWn3PF+ZKNJGxCvq2IAS+YmzGm\nlvpEQ1UsSK0BZToALQBovD/xAfrHwdjD9MWDhEa9JC/OaHcfTgQ3DVAy0zSq\n/ZcTYUX5g2TGV+lVE7xfRvzadNLOCROCz7LPxy3kIy+A/VzwSXm4dLoTouSq\nVG0A\r\n=UjIy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e540c938723fd12317df1962fa070aad0a23a646","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.7.5","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.4-canary-46c577c-1582533404313_1582533478572_0.44468418670128207","host":"s3://npm-registry-packages"}},"1.0.5-beta.0":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0493f23f7453d9b9ad00a9a9bdf159586a2b5a43","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.0.tgz","fileCount":30,"integrity":"sha512-lihYG3qsWCqC02I7jbVm9LOYk84hS2TPRpkl6rm5BKlQG27xCOpTjc7IS+WV8ml4L5GoL9IF4SHDFjvJIwBGRg==","signatures":[{"sig":"MEQCIE0r0D9e/5gqOo63hx27OSYNDvE6ds/FkfPJYs+klDJ7AiAPgYPJWCCelU9WoYIibwCuSWjuz8LlZA/sJGHrWIAXcA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36374,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU4u4CRA9TVsSAnZWagAADgMQAJmih4xvXMvJt+cu6Ra3\nydh5lonrtGNvbV+H72AHzNoLzRe/RZUsyYcGhDj4lj591zMCwummou5w0FoZ\nVXu4NvQLADPNC57oSfXzQZX2bLKWSPLz9+58DyXKZDWGpSTLiG/5j8lI8Zw+\nIRZqfO4cnYokT3AjXO0FnK/SbqiJ/S1TR0Rb4QT+G44VuqZzklOdpTvcvOUO\nj7DBOdN8wJEofQtLd4lRDnUV07a2U7CUZUFq8drsLFawKXMvoVXIJrnI5S//\n4g10LWR0rnYfthgMLeHbyQb/TN4NKFBndR6d/UVdyiDHqpotc9jffPHWZYkV\n1rHYM/mr1GkxKVwX1SfmoZ9629mNkGBBO+fWsT0E561GGggDGsPXeQDyiTJP\nZsQmQrIOjuGMRSBU264Z6NyBa3uV3dYQl2s0DUFts+1egrhuxrcK1KfB4JbP\nEPzUiC0UKAXB4g7fnmYkgJuQJBvV7XuC8GVQmbeNEM3dWRjR+2U0Y26LyQWq\nhwrEuDCxCBLnYYi0OUffmwmBP+/BYkJIxAZM71oFSIv9uUlDMDGEdaKhnood\n/w8KkJFCYrDhvG1otlsl0NJ3Z4RJsHdJgKgiUjbuLIiAP0kHga/pN2hIWHvB\nesbNGuY/Ti8alf8AIsmqHHl2TY8PrFaAJmyNAWbZu9/rXASjZkpq+4cr5AkU\n+0W6\r\n=uI60\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"177699f9effd1cba88ad74f58cdbdec480177210","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.0_1582533560338_0.6774274466818901","host":"s3://npm-registry-packages"}},"1.0.5-beta.0-canary-4918602-1582578422422":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.0-canary-4918602-1582578422422","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.0-canary-4918602-1582578422422","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"42e4b58c055ae9cf25f2cc76c6aeb6fbdd50decc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.0-canary-4918602-1582578422422.tgz","fileCount":30,"integrity":"sha512-pLucfPZsDxXoh5zPscGwUJIx1ls1wJNqQaXSn6f97fjtgv5803KqTitaEfzOR+yyhLxbnjQ0Nnb7PzDttVNA1A==","signatures":[{"sig":"MEUCIQCN/rueq/Q5FcK6WBgMz4l0MjZqAjK2HSqRRsfVFR0qlQIgYdPUJ1rTgcL4OqKvOxY9nrUhGFGTbRggy5f+BFvpmVI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36403,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVDtACRA9TVsSAnZWagAAjd0P/R7rBZI1CL2DvTQD+QNb\n/VonSP7nAuzNOm2+LK6t7kuhALHsZOyrzBpbIovqh4o+E8JPqa+arGmGKiAb\nXlVKXU3M0pabFuKJh1vWU2jBh11PIyLQj2DE3F+6J4PYYgVw5BFhewqcsWBG\n3Xhmgar7mXfCtDxv7Atyl8+g2ylTJ0fw+5mMyxY+r5Icoub2fAW+wuwaalZV\nlTqPs6JmA1h5p5ZSqkQoZ2l90QJq4FZ7mKXxSE7w8c9k4bXnJIXPsSbOW1no\n6eNTfuEuXEETBwr9GFZAiiHtlLeMMiT5nuAe3TRd/zeQrIlKXlwpuwBOLKQo\nJHtw7PfgWvTKkihv+CVp519vrtgFi3Xqep0y3A6zvf5fdllNy8a5V6SVGgqM\nAHLMYAOz7EhkouK/+9TRkMTxkMZWu246DtNqaTwHBDHYXFIYPohBirLN9LRx\nYT+S3dxEnV6k8Rh4gBmNZOT7iqEVjSrK+hA1xp6CxoLtjjJfm2ZMUrWTORdg\nxvFIyL2GUZxTmxTvXqemDGGuN5kcpGquQgHkfbqeTGNKpESYUCRb5mhBRzx1\nashi2JRiPmYDZHVB/q9zMNKrYsiETwql2bzVzDloYiZZ3aDRMpzAmi0oITU5\n7YXWkGdKkWr2C1XHOtA5XHXzXEij9kpcH9gSpX6FbxHHMkp9dxXW3gPttacQ\nwvET\r\n=bEt0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8bfaa83c1cc643a6ab859b25e2f33bfd165efccf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.0-canary-4918602-1582578422422_1582578495567_0.6797712538878165","host":"s3://npm-registry-packages"}},"1.0.5-beta.1":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ac7735eb118b243b63f3c44224e2a6e5d202f238","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.1.tgz","fileCount":30,"integrity":"sha512-eDZrJmcngzbxbo+y8rgBMApKZDtH5UV+UQNgQxu+0Jka1dTLI/+s/WqbAzsQWyppxBdJZM+Z3j0AxbBjqYZkcQ==","signatures":[{"sig":"MEUCIHKjsXdI1a2YCPRK2rz+V/2bJVfWcjNE3RSgNMjPXHU8AiEAxOrLbzWSc5JiJTKD4AH0l49djZPwm+qPtR5TFUtt7os=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36374,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVDycCRA9TVsSAnZWagAAaGEP/2zpCJiIya4oXnGh01FZ\nupYBNrvtECzymrqD1a22ggHhPTakgJG1oIr4QoPCWX6TZ7TRzbvUgOXHDmiW\ny9UoibEilu8jH649lWM8ukXYyvjm5svZTT4SJz7zKD4/05UWVWxinTvABZQz\nkZwW3VtQ3ebeiBYlKz4Fu0E62dKlvw5d2ET7mjzKQT6R493dH1V62Qh32c3g\nsTgT5wnGLL7ao3GXAb4gi11jonUlV5Dtat+pA575yW4KGW08ImdkUmYb0GGK\nGAH1QOBofZ6Jv/YHzwDblFudVV0D9D7WLCMTpXLcb/7LAorktlFXxcFOng9W\nniOI0Gk0FBYBAWHu528bnrzJeF1SxSflw+JbBkclZlVWvenEqtXhHmm7vYY8\nI7CVt3bFxeJJD7KDoW5wjX/o27z0AI5sS2GhQ6koB5zdhuwQDPSY1kM9JYR7\nck5hjcLsO2B1itidRduJSmwGVAGSaJ/kPuvHezP1sQU1/Y63xtyLR6uSpDVI\nLWRhOZ8GqvyQPde9eZgVr4uwfvcBg2JkUzT7trWT2ehaiW0igQprM/2dDJvP\nPco6WEkfWSgl9jzWTOx2RJuJMFF2Sovshz28vUjgBIIfq70veG0de2o+Nz99\nRXG5hf1J39jzy7k8Kx1wolPl7f3SltBkbuzTjBc6g6y7AETu7ujdBMMssT0n\noG0W\r\n=57yc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"df032fed8727bce3fba1f934ba45db5dc30956eb","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"jest --coverage","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@rollup/plugin-node-resolve":"^7.1.1","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.1_1582578844090_0.3383694258267482","host":"s3://npm-registry-packages"}},"1.0.5-beta.1-canary-d81ab07-1582618395405":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.1-canary-d81ab07-1582618395405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.1-canary-d81ab07-1582618395405","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"67165216c6a552258637ee1f6042899e7dc1007d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.1-canary-d81ab07-1582618395405.tgz","fileCount":30,"integrity":"sha512-NGOwNz1SUnucsbhCSw8N+mh86xlD1rDzVkjToBdgyoFxX72QSzE9+FRYWloYvyXt7dIpXU/PeRTsqEXtAVsMMw==","signatures":[{"sig":"MEQCIGytTA60eoE5c0i/vg1JEXzOKp0OArrIBJgFeK1cNZqIAiAwdH25TDKyL2T7FCB2Yg+jQmXjLtLO1CPmxKCisI14/g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVNdqCRA9TVsSAnZWagAAK7cP/355bW7RQfuocBuDYiqM\n52uVyzwi1vzog8DlStJZ+5ey3wnc15jlIIuA7WHcTk8YacZhxGwBu5sWRSug\nYdGg5JDivXxfvZI4NM+RCTWi0pR4OWeIcO/fwu6lTYZVvEBc2ax2m+bTqtIe\nqzJXbhDzZlmmJ+R/EZd5pGA+8KtRCXfqFGhcjnfzep40y+p02RFZNBbKltmK\nDL4e8P4aFJPj3oNCzwDyUvqpQcg0SuFNlAVGIf9JD7OiZy1cQBHmBBS7Z71s\nJdocm4pDO7yhqXMX3B/6Wr/Sk0LPzMKDChAQddGTvMJGPKuGN+SSLVpe+/kQ\nx8ruwjDq2CmyBBEANo0chbcFtWd3v+Qup7rnRJvgrLVOgooNSDYBm12vbOzp\nvq3DJCTKH0iWl4jLM7rtIL3mTtrdRKhcUk2LXE1pjGdjEgOXo8HJsYposvjn\nQ9N3wdd7OTdSouvvLngbjydRMA5Lx4aIWVL71kanJOOeWVK+6aFvt0BNFKbs\nE8MWLZUOBszdp3rbPKHGlbm4Js9I8e1JfQODjEP4AGjR/uX37hBPzEIe8rsF\n/IfxnZeRV3MtslYfzXTsBoju8mcJ+3TtdFJRUDnXw2Qe1hM6MfsOttpwSIRV\nF2JExCYYghexoqUeiGttQCtVPPvCjOTLPfdPJa8g3hXVPvyy9lQhT1UBpq6K\n8MzM\r\n=m/UR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8e710d504ff374cf21bd032dcfd7048c820fee7b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.1-canary-d81ab07-1582618395405_1582618473952_0.4486168524763503","host":"s3://npm-registry-packages"}},"1.0.5-beta.2":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"85d43fb13e846a8067f6b8df4ab0f5bd9789e2e7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2.tgz","fileCount":30,"integrity":"sha512-QDMlTe2SWQR0eXIQD8ezk3m3upyBlBivJphdPwNzk4ZV9cYzLcPZfb1WtrbPp+FRyciYexGQDtfRGI96gtTkZw==","signatures":[{"sig":"MEUCIQD5KjsbI+ZoCSbqru7Go6nbG4e2mOyIdfAqQhHe/F1wZwIgc5DAqh3rXmp/auXJw8Qe+7RTI7g+iL2gK2W7DXLuDGo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36526,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVNnOCRA9TVsSAnZWagAAShkP/jfyM3aGcg4roOuz9OC5\nsUd2vzUiCnogjFRQJc01urmeVirNd8jz8N1N3lYs1JAQB4umD1Gpgmkb3MVp\nLLOsBKoJPE8Mc32EHjBFWwzjuEGnHPzsOrhHro/YfdqdXPfJw/tkKyKT62CR\ni0m2Wmt5mUKhDksk1pAy/v34rbCebaYQ36NKSoisjeVDu8yaMoC1pdVsqrEf\nntkKUfcUxUfUsAg67r6u72SDOxdUKH12ExBsp+OPwcRWfl4BKP20h4mDbtpq\n8+gsM1inJP2SuWlZa5uvIGi67TMQfctYJKhRMQZvFYex6VhAzSLgkC5Ta1v7\nz0iFKwsLQTF3HFJ4Tp8PrYeQzoJhcTpZTJElWeaPhthbSPZfzIIEukmOha/j\nKfEpI5rpGUmnBScOAZjRtMhlI2kpM8uPkwnAepJO2xyHQFPdj9nN1yCyAT5R\nPuyoek1h1iG/2wzBrfD+E8cqTcsab9MlGy05nD5dCnI6OeJR89kt3FtBM0NZ\nGkGGUhRU0wkVrY2Mdu+3Mzy2e0+jWHAhMRRAikLqcSFQYnouf2G9+3PeQsdc\nS83w4e4m4W0bVQU0k6nx6xI1cQ8FVqzGxRyU8Cmt51ormq7odE7R+PuznLpP\nF3OYaXgz9bHlIkexvkHWBpeMYRcv2jrNR5Zxz6gmf+fWDyMJgTH65tocasf/\nQFgr\r\n=DWrZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0a6a422e537b21f801d72d2184271a4861f00aa9","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2_1582619086006_0.7380083120822725","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-5ccb1fb-1582662109793":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-5ccb1fb-1582662109793","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-5ccb1fb-1582662109793","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"07f5aa1d4b47b080e9836e6ee792917c23a1dd15","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-5ccb1fb-1582662109793.tgz","fileCount":30,"integrity":"sha512-laIfd26chT4jGAKQ1BkCJ3EnsGrZGJ0BHAb5/WE1NXday52RANXOu41stgPM5/FgmDtj9vIxpWL6mIs3miBWAg==","signatures":[{"sig":"MEYCIQDJ5oC/PMLpbh64UX1EpwvrNsgqojT8pQQBcDcQ1i3VBgIhAN3WuEiK1xhWVjgqY8j5Jy2Ra/lr37DSOQ5wMmxzaz/F","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYIkCRA9TVsSAnZWagAAUPIQAIdvKYpCjzyiTiZGni7W\n3iuX+7xU+/kEi5N4ux3ewqB5d3Pwn9tGU1D+7G9HnHNdZGtWvNb93VlvYPY8\n+U5wCOvAlkZ3gjDH+GQhZsQgHgdgZlmegv2ioe/p2bo0PZ8OxYaXXjyzREIi\n47cREz4t4DJ0n+k997BO4MHKzl5wFS8UKBAWI6Vf6SX23lWLZKJds6dSNWC9\n4HCj+CdU3ArD/yAFgq+c5ZPcY+uF3NQx6RRWxmq3G3XK0cmBy7rDW9ldQGrX\nEmZvF1pa5j/JEncmSTDNyaLDrT6QXXZMtJSsWZ2UaWHP8yFOsZ6sFeiebmg6\nCrBbfEiRGuAAjpplrZEf7TVN7e06QpLEEtLULCmiRWLRcLSI8ftZeM5LALKm\nrjPFgkH0Hx9LosjS0davNVRNFXPaKuyShWOZ+bJLD5fJCMwfd069avIzwHJl\nfi9YBXBRNLJRBbRciGlg1ss6GISf3qJP1nfX7I6iw0SXJmKWCLOsMmQQsnz5\nN8TkkfxeIFSdoVjfYq5o6fTIrnGF4z7SZWGX5wn4ep9Ot0+SA9WhydKaGAsW\natE/8GCGaObTzTNObBxBvcyzmWm7rq+xG/20ZJnwI3j9Kwa3NGzUArFFDugj\nAmKCwFunsbx672YETMttLj7CWZHIrmEltMkK5o1dPpqld44LDFuwgusdwjxz\n0m9V\r\n=Ut5n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"51405f58e5dc55899be6437062e54b044c6aa8da","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.0","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-5ccb1fb-1582662109793_1582662179989_0.44264549883386617","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-033c634-1582662477182":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-033c634-1582662477182","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-033c634-1582662477182","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d19fb5d789fa204b6319168070d422b45a2f476e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-033c634-1582662477182.tgz","fileCount":30,"integrity":"sha512-RHnLzRJF76ri+wiOYD4zFXDSqLQsQMpKN833z+yw8uXdtvDN6S5/NMPCOkzPb8YbqTP4DBjjnpMownktyLOAMQ==","signatures":[{"sig":"MEUCIQDosVuP6mWg9rx0YMh2dYjVEuCB7zotPr4yWuHGlxUMVAIgPWiblAXlHCpYcuBWS/X8BgOLfUhh4ePHVv3ducBEMOo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYOZCRA9TVsSAnZWagAA/o4P/125MlRXTwUVv58S8U0h\nuXsCA5gBvTxOKS8MHJeXLL7VDivXtwtsYGf8WPi4Tf64xXYeCmfFyTZ4s4fe\n2zeYgOw8HrJttQ2p562idQH4kLhXFxE15eqk+/fbWLRjsucp9TdSFKI0aIeO\nZt7cAmlor415/iVrSROzrzl7SBCnWU7Xz7E0r8nngsgH9C6+iKYSKD2/Q69k\nkADlcncU/EYX41w5U0/TDtvClyzZ2yWsr+yG/mflqc1gIrobtUWjeX127sqJ\nGMIe7MZGGZEZQGv5Ki78lZdQdoULAW7bRidB7jGNci2aVo97Er0B0bMepObC\n4e/t2InRAoPBptT81L8XrQ/Myetw2hIX4lTD+/d5nj5ru15la+t7j6WeuOLK\n0xShH5T8gq/ABIThdCS55IZAelJoIatNw+Lp1WQCA7P5m5YXXArSCEbi46rF\ntjskODan8iygs78bCBw8igNJU71b1FQn3fklChML/LecdQKckTR11D9Fd4t4\nlvMFwLHhiS0H9l8i+eAhC9wNE4QBeeFEo0Xi/7vKeQjCxnA4PYLLYFcTdywv\n8bFOCpMMQ863J9GJ0uS2o77xGm7nCGlnfpgK/+5j/Yhu1hFwMpeNsWhIu5IX\nhkh3wqRhOJFY02LRncr6D9YvGjh6o2aSkBNCCzxBKUSp5+BRu7YzhQU3woG+\n9Nx4\r\n=7/aL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"606a0feb3b5c4a8e4c849b7892156008fbc929f9","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-033c634-1582662477182_1582662553139_0.4843402822147178","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-665be44-1582662500778":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-665be44-1582662500778","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-665be44-1582662500778","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c3c9903e39f7bc915cf9a76b792862dc1aac374b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-665be44-1582662500778.tgz","fileCount":30,"integrity":"sha512-+A57GeQUH21v4aHVUN/nERC+JzB5FZKbRSzpGGzenIVeO93CYQhITEZXJoNUsCsXord3DqmtdmOKBK5HL0SWpA==","signatures":[{"sig":"MEYCIQCvreVcWeHrXgazzF995jyVYC8igwmF46rxwhMuOCwpDAIhALybjALDOrYvrh3UATz4hZcqC8U1BwPCu8bGwNzTY4wt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36615,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYOxCRA9TVsSAnZWagAAnogP/0Ru0J6NniVHn844sGcA\nl+4xQh5rqwwLyVJn3VonDJzgO45ND3xoGJDbb7Zku2dD+AKQqNB14rEoxGCt\nOeHdx8LP8LltUPHu68GRcelfbVYBAUt/WwVKbil/EYzkzvFE5ZYFM4ArXo5B\nqMmTb+sta0yRbBhLDK0lIYiWPOWw3REt1F5G7mwOhkX0mFnekIOrnUJwgdRJ\nVfMBSf/OJc1MwSKy1hBb9A39y9QnQTGzVqy5AYjbQPfyipn0ccQNRr2Wmi/Q\nvrG7hWp4Bod6HWB7F6WsHBCZFj59Aa76AcFPWtUBLKJFR6L3BzGqyxORqnB/\nuQs6WhEPodertuyV4DeViI0vWG+iUJALlig4weGRdOW7ddHURsz0jeA4Z9XF\nbnbEP1InsLxuLqHXfUP4tEDN4sHR7EaJUlXdx7YpHnFVPcGyHFf7N98gtIgu\n04Uz97KqShE+4A7+nHslNxAjMxAuihUtoLUDAqrexNDShNFKUesIyCUr1K/N\ndg4UJGFWNYByAETiWmbW6IZxVPKAntKc5XBh0hODqQYIG+ZiEMHYLz1wHj4/\nGfe6CcftW9lfKWHeJ3sdOSsgnLScDihbJUf4MGLCTbQBoa6WD/U5mXEJnD+y\nFzfFW0zPS6HG0lvgV70D8J8z1HFf3eL303nfNzAPrY7wHjSB7TyLlrvhs1iE\nggu0\r\n=WbRI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1b4b85de2af8cc9d805056a1b76833670142265a","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-665be44-1582662500778_1582662577041_0.7074255750732414","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-e2d5547-1582662771238":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-e2d5547-1582662771238","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-e2d5547-1582662771238","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"790f0d6bf75110aa113c943e42b85d5bfd8e3449","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-e2d5547-1582662771238.tgz","fileCount":30,"integrity":"sha512-9pHCxVbN148lBjNvQO5Ux0gnhohsxJINbMJh6zUMBp0Z7KKsmxl+RwdS+mULUOoaUbzCPzqiX5SNmehtG6kdsA==","signatures":[{"sig":"MEUCICIyOFmJ6VbDr4XBMZQgiW8F3OXEPzi/j3wG+tIxW9rjAiEAwbq2J8oqyB+XQEYwEPYstr5XSxHQ7aAd12UzfgvqI28=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYTACRA9TVsSAnZWagAA71oQAJ35W1pY76QyUuZg7qBe\nZDGtOI2jgo34zvBQ/gtJf7xEZWavR7wPQyMnM/nJ1mmShh+OT/njxOL35e6C\n0ghC4D0qZrp6bRhwMVF9RqotxrTnIV9yyj6D2QBseOBxJQTpHuwBIqzSfhaV\nqv3QZ3nZmFLMWo8pvQ9s6Bvq7UAKZADPd0vOBJSUmfyRadnsHGNgFqZJerZS\nHA4d8miqVnjPZoESQezNvLvK7+7cO5mRUdLpsMdgescQzc+N6FS73cRG3hrT\nTWDfupMKKtNEzJqcLTnkyiUm/VbfZvWjB+dcr4IhYck5du1vI9oNIauhlGjp\nS5pORcHbyRmuO2OUeDyZzH9HPXz/geNhjuT04xCwwUjz2FaiRGcuFD9O3uDW\nSZc2C0RoTvWViEokyGAtKVasgO90WC7+83s3H0qYU0ueDkGBy4pRetTgcL3Z\nvMD7aubLoKKcrjrgHTToL2bd8or07UIbTlh0C2gwzahXdRipLdyMGJ1poPu3\nmWHdsgU8g1s22gtNnnjpRLPnsfG5w7qko+wMNgaj3Lb9cW1tze8hdcpu0qyD\nDQlaEfi6jKkM7iHVgzGPELHx2K/4zpJt3mmEFVFs/quq0m859XINGFRgdDBU\n5F7QeeiHAIZEOmGgdO4Q9/9I7SZH8zHf+WsqZUKJB+GLwZM3T46Q4+LlJ0Vb\nC8bn\r\n=m+yL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d3670e7d80b7bfbbea7c40e97055d9433a3c484e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-e2d5547-1582662771238_1582662847653_0.6934699855610746","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-10da221-1582663163591":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-10da221-1582663163591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-10da221-1582663163591","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c53dc0af1c1d883f52824bbba6a525aca2c61ad2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-10da221-1582663163591.tgz","fileCount":30,"integrity":"sha512-daH0lL0f4zcDXBtyUYoEoM6kosf8gePqsFLai/AILmnLp1SZnIkD4HbFOsa+IfGToWdyMjYI1wvjwCKkqa8X6Q==","signatures":[{"sig":"MEUCIB3clMTq40279N8HPMMIt+7pnoDCXjXoonBxvAHHdsWeAiEAhQmDCJ4Y8Fgsaq3170OKvLeySofl4uQy+/RUG8VsTEA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYZZCRA9TVsSAnZWagAA5gcP/R1C9iJrVTpKI6L16EU6\n1c4YzPPBwW0GGJZGf0G609VRVrMGYJWQQdtsTKeQi/OfD429eQyq54nWY9su\nXGtZ741zINGcrhk8R0A28us7LWfII9rF5ND/8WNZMaNoceadF0SL7E/BT6pf\nNgjyO30YS0UtAiCUbxfotIdgaSfZP1xegwhxEYk1rbbf8grSIhRbK8F5r+aI\nasskpUjKY+eu4Dcmm8Ctr2lJqlTc/xFI/IxIgI2t5UCz4jZfFPS7Curf5Q6F\nSA1JHgJ1VAHqVFLLMViPZG8Sn8ziYBq68ajZYIRr6hbQV+GRUjQvw5siJix5\nkFvhvxmxoyYwZj5s0WYi75r6No6v/E6idFFgo8hf8j3mC/JnUWi3QfGNAlO0\na9CIoPNZup9vgFtw8ADbIsyBvoHJr9AOtlMA19JO4doK6Ltc8X7JoBkuWx2B\nLNm8xTa1l1i6Lm7A0b44/yJT5+MAT8TsCkmbn12NuMoq+2qbSSBGWSkir4C/\nkinN5rHNBoHqtGqQUvxkwhSp7lEF+NcnjYAPGq5d9Lut4iKOksssHSVwUqFC\nLzsefRj6KD7IIr63D6ZdrPJtYR81Agu2SjHZBTFDxvCZ6TnUrao7wnlgT0fk\nG0Wphj0CH0aZYbZ3aX10fSCTBBAWLzo6MCjNgZgYQp7/QBMU/R3z9jQ3Fjyr\nV2Dr\r\n=EB8O\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b09f95c959f541e803f5d37dba0aecbb9c92e476","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-10da221-1582663163591_1582663249469_0.3615679259422777","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-da09837-1582713835321":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-da09837-1582713835321","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-da09837-1582713835321","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5803f7f36cf2b3fe6edc2607e7f17d44b9262872","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-da09837-1582713835321.tgz","fileCount":30,"integrity":"sha512-XHgYzX+zC9cNAphhAG/6RHmWtM33gbJvp20nvXGj1hqCUetOjuraqWxrG7qginY1sD1I0nkDWFWHgtdKnJkDyg==","signatures":[{"sig":"MEYCIQCQNWcjl8lAZNVO0yzavuTwVCJ8r4EovBgkefRLuTOnJQIhALn6e0OlAOhv2VKFuflhVSdDmuEhSLiu8YD389UCD7JO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36555,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVkw3CRA9TVsSAnZWagAAD2kQAI/DuYcpMMWODy7O+i/P\nBhMjWttEDFdEdulGRyiDeZcxgjBl4sEAfTMSlUpNcAo043CYg8THLolPOtU5\nKwynEB2WFaaL/Izc+n6Z15WWuYpZv/5DBndF5y8RxggkthnxxwtTl7ih+klz\nYgpTVTqtbdNmD79v3jDj0/wetghYeoZKmlIK/epnenQwEpHyQAkdbemj2gZZ\nT5En7T95E3JjronLiQScFZV4B15BPR5msND1j7ZS0pATkAwP4tnA09AVYCnq\nIkmnTFARNieOczFNmSeFj+aQUDpi8o0rjr4/GWB/i1fjB5Bgl5eidD7KlbmH\nyBtu4Fst6w0Cnbt51uqDx/ZdAjqb7+REaS7NKHuHzYHoKqBpWNASKl0+Chu3\nNrTJLjRB/4GS2ZWUxtiezi8/C8/r4GnOCoPVgAQrNg23nE8a7tur/zAg7HKt\nASM7IpRrfU7uJV4AHeVZJNhvPLExxGJE69Zkcwj6432qA7rhEBMtJtXQ6thk\ngIdhaM8AQNLqjIWT4R9j3xblFlKVbTCv5Z+ieeMJHWJDz4l+HquBHXrNw9i0\nHsw6Ox1fgUVruQA+XuzzaGr9lOld6MDokeHVmOpZS7PvdQtCjHRXggMYTG4Q\nBZqHXpFPqfODGLpemYS11IfP0N3vSd/rwS7T4fV0RLXjXUk5D4QaMhh0qksL\nW25Y\r\n=4IZt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"32f4a83785ba283d459768e6dc511da64c3ebfa5","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-da09837-1582713835321_1582713911446_0.7812839448222209","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-631c20c-1582714034110":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-631c20c-1582714034110","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-631c20c-1582714034110","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2e1ad6b44513aaf0789cab2c7deb9a38d3c8bb93","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-631c20c-1582714034110.tgz","fileCount":30,"integrity":"sha512-KUashMX3typTJxbkb/FJtsATqdzBjUBrl7j1wgciA4cvZjwxPO7IjrZccwQhT5J3TSElNjj2mS2tt53GgmOgHQ==","signatures":[{"sig":"MEUCIQCBEsViu9Oq4mxNrvUNs0D9Ky0YV8KvxEUNJ/blLA0hWAIgDLKaRun6pslN4PvVr7iNZIDw1RH+4WLwFUmgEcpIe28=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVkz5CRA9TVsSAnZWagAAREAP/0zs8auBOi4MVwOrUkhT\njvF19/mfgvFWvLCYqsc9EArJP5MmQKhZACyJGQdZxJb5DCtXCFdBnE+pDQf6\n0d0PEEMmXl9Ze2ETiiYYw7r0oL6nsk2OOokMJGU/RbdYEhe9GKNYNMC6YqHb\n9yBSWhmqe/YN0mW0AIrX/oXKtqG9DgoSEm18lWj1zbB+/7t7uTQdJBuD04cV\nKz5dSaZq3VQWgYb5rQBOKOsz39kiW6vO+yh76AB6B8ajtn6lMKD0IQSLKxTG\nG/gi8FSeXYdSbLx7eGfIkcipr1YV5cnDH/pXofdhehDEYmf0V6z4SGOQaeJC\nTeJJ8rU3JB5XVfdiQiJ4j0M2C8W19VM214HSIR91UpB8YTE6PPvospYu8dyk\nmiAoaCLUt9x07exJJLgKrMS5rzImb2/bVG9fx0hOkE8ThoE2ylZ+4fmt5S71\nznxXdFORiK+9jhOfSufIENIzC0QxosC5GGl1InA1LYgYhUH+CSgYqwgO6azq\nnTIQj1cUqCo1cq+sJgmcPAUY/AyS35lE0K+bDAwq06nble14QGBNDgNWoa6C\nFviPxdtXD3+nLxhL2lydfkwj3RyintInlS7YHiAmKLjLjdidQeOUwc/6iDGz\n6ZS1PoUvTT9feodKfY3OCKRLYogkkjof6bGdI66QTGEx6MjLMEdu28V7JC5Q\nvzld\r\n=z2cS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"09a7f15d5fc02e2248f4ced154b15b3cf3940271","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-631c20c-1582714034110_1582714105118_0.6865412784898695","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-91a8621-1582716263480":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-91a8621-1582716263480","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-91a8621-1582716263480","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"32156a9c61f102b15cc7550b01151628fadb04ce","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-91a8621-1582716263480.tgz","fileCount":30,"integrity":"sha512-NzcJ1j8ZNSp3iEpCfjSf9BbhDM1m36au2LwnerrpiL5d/ao6S0mG3AzL0Vo7x7O3SmrrAQm5nimNqffRQ62xDA==","signatures":[{"sig":"MEUCIQDWhi1Q0yMtspjJ8I+AXLxThIUDKpGHRIyOlsIMvACtVwIgFBVuB+H/d75KB8mOHp8G9X4Sx9C7toH5KcN5Bzkvnqw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVlWsCRA9TVsSAnZWagAAw5QQAKIN671fj9tF76rIMlhx\n+iiMkML59SN1W3rS/6JadRdHv7SUItDirQkb0ZqLklwBd1HDFRi9YavlqKmV\ninio5AHN0SiQ2W2Q0fc/27NHTyuKvelUNlOkICNkjl41jSTnaaZstKxoYRCb\nOiyGxUc1xQEJRwlSZrwgS1SyY1EWlXq83GP6LfQ/rMgKhFdYsnCx5y7qJ9hL\n1vFzN0r03tecm/gf23xucg4NQ4oEytJvnLK/ZHaRTyqO3+MN179aAmhzrrGM\n+30HQ00YnIrpIoxINOGikR4B+ry1jnkeh1G3jnb6C5plP9YnKqv70+2SzCdl\naUfg5gNjUb1lQi3Wgg+brQBRmFNGhKA1HcR/pqQr3f+iDt9xig+i/fP6lmiO\nupwU1l+kw8nZ7Oj9y+ZPU/j5TJBGQgqDsr1jUJWw+osWNrOpKIuID6sVs/29\npQqBiZeFiVGyAFBYjdfv3BtkWDg0uAQiACsW7yXTqoESbaBcaVNHZ1cv3nQO\nLSYrhKbL5d6WAC4FBTpHi2SkA9K9d7z21qw6rnPg+S8gQuAJRLEq4gA8F8Nw\n9cKOGF6rJGETmn+wSFqP+9YUGPfcJBjruvxA84I83DLp9waMs33PYjJ54x2i\nvV+wckO/wmXUmL2Wy/QcWHQwwlXQ5fADaAJPP4N+tDA/SyYtApN/bw3gKfUD\n/IEN\r\n=wb8X\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2dacaa41ffd0a53013c5a8164bf61bbd7abe8246","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-91a8621-1582716263480_1582716331806_0.5198041033534226","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3032278-1582790954544":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3032278-1582790954544","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3032278-1582790954544","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e25a31100973e4923d93f705f93ba4b8ab332bb1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3032278-1582790954544.tgz","fileCount":30,"integrity":"sha512-NSH++Ge7Z+fo0Pb12jt7DUgdCQMEkk2JdjtqrvnpQDQbGOQpP8O0P6n6GaZvgB2lNpsnwwtpnxLjPH/Ow336xA==","signatures":[{"sig":"MEQCIB6eobTuCd36yAUoBkccfxj2QN/XNZ944FTj4F7XwqzPAiASF3eoW7vUyLCjCjdb5bkQ3z3tKw0D6xCNHvcvwNdBvw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV3lrCRA9TVsSAnZWagAAvWYP/i0MbjUewBp4PuXbR9Dq\nVIe/+8NTD8kvvY48YGj1GUxEQuKVSYXPuw3yH5+uL3RmZSIQj76xXMx4uwpu\nocd/cmcwSuoAFfbN1YOhAyD5U1nhiLO5seUwKMKHM4tENqRn1ATl2I+k53lo\nsMEPTbow/M43x1ihJRGvQDS6DKW5+7D8tH1oT0DLi8fCdi/rfvY9c+D9m/ao\ntuRR0gdWw7WHK++6aHO2byz9jQ4R5OHZYTHDXvZcsgsvbD4hry/hQrRmqzpF\n8mK6MP46rbED7inBmICb0MZcGCFqrZZdkcCtAqJgN1klj98roUOz4MpNVNLg\nWLogfKGOB53HrmVmx/joCWGrM4ZDemj2umLVKPj5TBKiK89P3DJDy6qY3ysX\nvyFrJA7mRU/O5Y3RDwRxsNgD2wT8vLVFeJvNkYNxVQvTCVbpwApJH80Sw/yU\n40dZzZElnCegOhDDF9lcFhpe1kYESsC+5GMUgTg1BDRbRBv79v1Hw93nZVPb\no6PQMSAo5PLqB1zoaDjiFPQQ5+lu0U77TaizIVjqHY5DokzuF/zwY3uPIBEP\newMkOiGL7CzTYmObbD+tf1nF6Ue1n1+qQL8ncQUfnX1VHXAQngs03eW+1BPg\nzNnTyIqyIRrac8dBCNK++v4m6TD2NJ1Y+nfnZpkZ7ePqMGm/WXk0ewOynT0T\nSmDa\r\n=Cyl+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"12a289490380561a140a650b5e987c9b2503d202","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.1"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3032278-1582790954544_1582791019003_0.7309784726363706","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-78e8681-1582805286545":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-78e8681-1582805286545","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-78e8681-1582805286545","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"346a2cc3be58497f6061439c781e4c62e7318ef7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-78e8681-1582805286545.tgz","fileCount":30,"integrity":"sha512-gElagmrYM2ONTHYkT/7vOWE8GAdFb2kexrMmWMP9r+B191NXG0COmrSQAIsRCFED0C36dUOeMRI8jkzzx8IkZg==","signatures":[{"sig":"MEUCIF6QUYHbQxntdv9rV375z2D7ofj+mCnGo25BLhScVkzrAiEA1VWW3T08nYbTA2tRvxmJzdvjOCaRvj7XVcNQILyW+wE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7F6CRA9TVsSAnZWagAA80gQAIkIZQ8gl95C/MWlq9Xd\n7iH7TZwT2uVn40ySgjV0xLsOR3d9eg/38lrya9NilULO5WmTL1+6f8q5113F\naBuPsRQFOntnEYBz4myMfLUbVjtuqRimh158y90L2gjpnIcYr9kikbO2AEGI\nUxv9tgvVcIvyV0UnTll0ONcfVIwgAL7yTAeVKVYyC1gBsivn6bh/SRh17TJS\n8Wo5L9nh2cIKXfZT5zRWt3DjYMnKFOa0BtQ3PlCwBvG1KgVjNhGkjNFzKfFi\nK/hOTQVA2+MdDxUPaPzoKjI24lg33D6QNR+quEPbh95x2AsLFSl/zIFdf7rj\noE1wWtEyEnRQ7HeBkUzDLIllJQJFWoB3cgocE97Zocc6SliYrNS9PHk3Qtfu\nNOs2IWQEgnw0k3cHQSKlOh5cNPOdkSax0o/cqjuyeY28J+o25fX5VVYSEWE+\nvnNsEHzr32prrV/TYyF/UH4Zlx3dZItkTDovgsaI4HcprTnBGyJFmXWwLyrK\nf+NMpxg8dzQKewUf8bX+b8/Pdwv3fNvaqnDJ4vVpPgYbFV+QVr/E9o8NDBRB\nzB3rwpwN+JQkStidUgPLieoK1Ra+2YPVkgC+GUOxVTvXpmLinzG7NLaPsKQo\nS1vKvAg2CXiPdB+XZ4NS3MF7vxIaPeKd+TnmxXhB2jQGigwiVbzRsgyx0t1k\nV4H+\r\n=/2lX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1f7a063651566851497424b09572c022ba173624","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-78e8681-1582805286545_1582805369324_0.01366977927605828","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-813d6fc-1582806426579":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-813d6fc-1582806426579","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-813d6fc-1582806426579","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a8bd3ff65304324882dfe8eae7aa85c4ea54221f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-813d6fc-1582806426579.tgz","fileCount":30,"integrity":"sha512-SSQ84mTA5sr+7h3m7omiKs+rPpkvAcaAaWLhwIqWpREfzaQar7YOcPoQuWSYa8aXDGQ5FOTvT1QmYWtNpwxzNw==","signatures":[{"sig":"MEQCIFbvuiBckpb3929FYMnLBH/UJ4XFkexatpFZ6TkFYB7fAiB6S33liBGpm4YjvBWKGUI6kUUfJX999Z/Tp4Un3hltMw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7XhCRA9TVsSAnZWagAA6PgP/RdbxPWSXx6NSLg5fBtc\nF4TEJEiSU2/E5zkauA5YLuA6mqKs9NatxZeOS83nhSGVeNv/EXQaasoAPk1P\nnJ8sNAOHW1qwKZiiC6cwpI+/DbauAD3sc2CYfa7CMEKbCQs+d3WdxNXcoX8H\nCBEiV/VjuR71xt6zKaV/bDK2QHTgUl5zzt9YCNWvm+15hyIGvOYo/8N0i4cR\nYTOn27NiB1IBNvcogLDEZwIzX9hyi2KDpkJl1vwhpS1x4YM8UHpq3T0R3QaU\npJfsFKcpmWN4Jd9fyt2q0O3D6Ha0cE54g5gS5deIOA7QIjYl3kD4ve4EXpIF\nd/v+rgiSerH/PTC9tvawl35By1s7fa3TH7o0KivBKZU/CMe2GZSmume8S6Jw\nCRzFs3oxi061Ma0tOYNo77iVdrDh3W/Doa2z3/sp6tYzRgvAY6x6uHgsXzCC\nk9FqQmyM4Q4JXgQGqbywHTAZsi15gBhJ/bNfQkTBwH3AiVGdILDozFvDg3LN\nsX1D40y37GRZCgCxdJwyK//ULW90e1daRK9xBSQJaX+4HeyUI0V6OBAC9lyU\nDROCiD+Gj0vHwBqzLqKy3l+mlSpuou8XkBHWVMRILb5R5yGuDRIw/0ezSyL+\n3H4Dm27mdzEnWXYk8zKk5v85Jix89CPXiH+ZA01RxzvvUqlrZCj53oBM6GQ5\nDYxJ\r\n=g4Oq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"35944c91076af5cc5cc41d370bac696805963deb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.0.0","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-813d6fc-1582806426579_1582806497104_0.0484053746719757","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-eac6866-1582806429279":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-eac6866-1582806429279","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-eac6866-1582806429279","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"06f09bbcb93883a52bde08b53361c3d8fecf1ad4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-eac6866-1582806429279.tgz","fileCount":30,"integrity":"sha512-zYKLnXaC0wgzBTJaZNZXrxENuCtqbl0K0XQqbzfbAevRDwJWFBAqFlrt6mKf8en7CfPAGrbfKZ+y5SbxUgk9Ig==","signatures":[{"sig":"MEYCIQDFCdftMxP0fV9Se51S64JR/whDG73q5fWf//C+1KRYSwIhAN/T5/Sa1xTrLztmkU/HCk6oYRBEAMZvoJkq4tj5ofr2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7XtCRA9TVsSAnZWagAAaAEQAIpNWn3IhT957LHuTqAw\nAfMmWr91aOOQulFETUexVMSguGaE3MVAvGR7lPgsAUoMK5qMN1laUZrbM5ZC\nzS9Fwmtk4F+3G5BVspSz0Gc2YpO1Xzyx2KKRwkXxFUIrs1Ay8GVRS4uLYjNW\njLJQVkZ2nvERX5y7tUS6DaW6fuGiW5kRijucAT7nic+GU7gx8Gvxogyk+zaC\ntzgNeVOJrAMLA2Lcq8AzB9y/qTZ73697lCUM7BeqLH9FPds2YcdPLMg3zl4V\nszqdhi2bPleqvnkzwzzNDossK+xV9tJ28iK13GDbWV8S2icv3hPU0o90x2L5\nnEXE4aMJ++5QfiqA7rMkmwUw2G7fQbJKZ1eHWzew8TifnNFdoFrKEb5TGjy1\nm/sOQGFRgzWHx8FVm5/WIBFI23jzl+5IKAxq+VGlHco08h3zWX3lAu6FAgCb\nREHldvk5DV+7BWIaCfnRkrzFeeruz26p/91UqkVlIONmG8TNyo/lzFIo/bun\nFBVmgz7muEiQOIKlSXWBv7ReqDrPZuDJ/RTETcEAldwzyZx0zxsC3tNh+F/m\nuww2KNJRXvvs75odiMzx5LGMXv8kHTYRtnLeG7XWw3ZQAHM2grqoraRbJlX5\nWfC2OEEaUs27XOPMpTevREiJf6FZOIK43aCyTwgKAuh8bPN9Atka1Hp7ugkk\njdA/\r\n=PNCE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"989ba844a7d07204a2912b1c9730de9d1e0da192","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-eac6866-1582806429279_1582806508512_0.80553407097957","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a4d6502-1582806451066":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a4d6502-1582806451066","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a4d6502-1582806451066","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fe8bd86cb7e9b16e16abfd20ec21aa6dbd3a9a38","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a4d6502-1582806451066.tgz","fileCount":30,"integrity":"sha512-S3YMBowgiK87YInvwqksWkOCv/r1kd+8X5y76FBiZwpEK6GrS1SyQIyfkRdQchO14XvZjyGmTMok8TVdLDRN4w==","signatures":[{"sig":"MEYCIQCbBf/2WMd99iyn/HY1hkO5/tbwreHYaW93hV2NXQSI4wIhALPPK8fEsj5tXQKMkBFeqStvAf2e3xQSqXF6avJdGcTK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7X9CRA9TVsSAnZWagAAxnEP/AypOE31/wAVAPZfHqby\nuTSCPM5ErDL/ZS5+g2H85rlqHU7mpFK5pgboLykKjwfMz8B0C1Myp0xN9T33\nBjvxUfE420VF5a2YxKeb1acSgMu/XQYiY3prBl9lAnRKEUNhZsATFmh5EtiL\nGU5xRMssCc2Rywo3LZVh/m2MJZzQZ828pqZPZ52qIefSzVjYQxylylhkuT5O\nyxfkWyCbGwi1zRMM/mIJvHspYGOzffyRia8PNLRgp8h+4OZhIyy8jTzLmsqU\nQMLkQZuM3IULKJ1uwxTA4aSW5hqn7u1esmGJSA/eXtN9VNPZR6EG3fyH0FLH\nYTCvEMbMeR/bBxoTguv1btR2fOKs8YawK+mDaMa7meNCnRMNO5SEFR3cqjJg\npTWLIsUYQVj7rbNdsoXq0SFXuXs4urg2zIVsV2o7eFLmj1Bsky/l3jw3fJEr\nSkKp3j6PAQGcWiKjsxaSD8DsDJCnDFQha5/Yf/4qXtL2QDnpZWrWj9Lb2Zx0\ndMluanIU/HCmZjsL3KKZgw2EXCETuyPg+Dm9qaRREBDNC5Vpcpyi61hNLpgI\nAz4nHS331ryx+Y7Pp5Avph5u435X64E47D85aVj0dWXAD0ZLyI/uL89VLGNs\nqe9UZMENK8LKDSgq/3muh3XWDjjpVPDoh5tIpakeJXRdGJADqhUjEZXJzhn5\njFWD\r\n=vRKt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c60c8db17796116bc7a045e483912f1adbdfa82b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a4d6502-1582806451066_1582806525285_0.46645484270840143","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-4da5936-1582806719082":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-4da5936-1582806719082","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-4da5936-1582806719082","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3c5e548655178b22720bc2b61e835aaa488b6079","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-4da5936-1582806719082.tgz","fileCount":30,"integrity":"sha512-PfmxHmTzq/diCAOzrFvO9L1FuCriua096YcymB0Tk79i0LPiugLp3fifkOpoYZxYGcw5hWAw5HT9zHDeyvWK5w==","signatures":[{"sig":"MEQCIC6bhdJ01Ko5AZIUbRC5uTR7ZoSdiS4S7EWDY1Crad7VAiALL7yc4o+kqbegGaK4pgo/BHxvvYxEwdrN8TDIt6Z3xA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7cQCRA9TVsSAnZWagAALgoP/35cVslclTTWwSuxjjgt\nFZmWHIdpNEigwbHirNIP2XoyvqgfMqdY4Us9oq/hhn+M9UcFvuXE2jnvveaR\nvWulxswkKSQrZs00a91I/W8QoQdRGU2rFHn2xIV1bzJ49ZvJUec1K3Y89d7b\nPMBWunv0XiPhctU+vxRFk0zo3iF81m5dSBkJqul/wKBopQyMth7ZionrAETt\nxbGBA//c8H1a43qubGedNGqZA+vrCd7tBZGeOTb2OJR3jJnmcN1RUDurSVmh\n4r0rmWkZTVZ4KDoHyEVk8WQ3aAoXnAc09qpF8hTVyaZOX9DljsPmJ2SWgrxi\nmikT88tJPRhukGHWYu4xEc8EVDRR8fxW4zUb+Hd+gM4DJ9OYYnmOdh4h8H/T\nneoumLkQkfITnNf0jIKzSQsrn1PIYzaT3svYZ7LzdzcQyHGEAfVXDyZiKTst\nir+ANIEGrNOOA+RNxLx1LJLS5dSNul4LdSIwpDT8CdnPngbKPYm620Qiev8K\nxXtmmMBThEcD2Sy+ZdMDU4t7PvhOD7Rs8fjC7z/2FRQa1f+6D1ENQ3ISBN3Q\ntP/TVdPvr7oJ9x8Q2lQMOOE5YpMw/QFDFh1ch4DaxAR+m6pnNLISvok2ccA4\nACi5HEjLb3kz6HoB6c9Jl3fzpvZfOS8ucpP4kjNOfTnI2F1FzOxl6vuAkjG/\nAsB1\r\n=fRqq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0ff891fb3b349d5862607e6a8c5d93014cc1423e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.0.0","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-4da5936-1582806719082_1582806800058_0.8663271805362742","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-ff6bc27-1582806886798":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-ff6bc27-1582806886798","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-ff6bc27-1582806886798","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"460a6d0db5d4a49667c5a97aee2186c6219725fe","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-ff6bc27-1582806886798.tgz","fileCount":30,"integrity":"sha512-yijWoJCJJyK8iQhg3pWVlSBAIi3g8i3WOevbVXvLjaducaPfdV8K8lWJC6tQCXVrnNldHG27yXa61WJsypJE1Q==","signatures":[{"sig":"MEQCIBVxYZKesO8I1A1oBOU3v6EVc8XfVv7G+sOxPK9UKOWYAiAqpR2A//0wyN9HnVUqZ7hsLIHixDjJJZn+GuyiLT5mjg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7euCRA9TVsSAnZWagAAb8YP/0UfRkdyoYxgWS+nNAp2\nvqa1cHco/pPObedUuN7li9f9C+y82+yIe9rnYAKKO4GuPthNx+HN+C16LHIP\nhr7sRTdIYqK+WQCQBC3bUEQP3OHbXrrvRV93iD7VwBvjcDB8Yfs/mRwSEyvr\nHCRvdA4GZdwme892McfwXNHZHGrhvxyIrgClMtWASUh/Fly7nvNbBnej1LhE\nSB78u+TfVDcOuTZrYR16vwY8BgRuE46MBDRkA0jV7LQiBd3w+ctYgYwUmRzC\nNavw8vgTMkZhEUBO69ot03goG21qWXpGQ2QazrM5XU3mpwco6shbIEaH48nZ\nVRc8DjOWdT+Rl+A/c4nL27ApEJo7PD1iiQ2biojAmQBb0h72hqnAXClaQxnh\nMeRtqAp11QlOra7gsui7FB6gI5Df5ArfSw3nsZB0x++VMuXbjkgKbDLx/P53\nRqxCzyp9BG6abeqm18Mt6u9rErsA2SaYatq6uqwMOSM7CBPfJOnCDHkE0kBZ\n2+1VknYLqDpg4pdQxpnEH16xnpJxbedy6L06P1ToXDcL3z85H57M0+Rc26o9\nZVDte9oEAXm//BX6ayRfQfbIssh9YQPJl5jd8IpdpFlSwdbPxksdjGTwqAaW\nPwQV4+JI2PHsdTV5dwE0MEbYNgnvmXIvMWLKYIqyf9j2t7kgSzS+PopYGWkG\nGyTC\r\n=AWkl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3057c2f221c5c46e1ca243cfa91cb8b4ecbae42f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_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","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-ff6bc27-1582806886798_1582806957922_0.2504056992997532","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-408a3ac-1582832230592":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-408a3ac-1582832230592","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-408a3ac-1582832230592","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e13ecdffc85bd734adff6a0c66e493b9efa2584f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-408a3ac-1582832230592.tgz","fileCount":30,"integrity":"sha512-ac9L5eGXxGAMAeL5PkkLt5Q3QQDnbLh5XYo+EPNsT8CXvvBcJ5vY1IGPnydLPK/t9ISfTdcg3rwj4fFNnvSKrg==","signatures":[{"sig":"MEUCIBce9zPKB4C7S5oH4JCwO9Yykp8bItQUckDbQN2yvPP6AiEAtHaF8suyX9CBv3/sFGUv0D2jJggYfUJttPNRwU7+O3E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWBqrCRA9TVsSAnZWagAADVwP/jGxTmTeBwZwiYFRB6DJ\ncFU+/0ZC+o2UT2+y2lPuF29DWA5E4wMsZJFo45CFwoNkIdhi3D9RVBybDwgR\nbTR3+IQTnBQ7EDwN7DihVu/4qCat285oeDn4Wsj2Skqj5nUOD9Udit8Dg3od\nxcoHvkpTnjF2KGonacurogqmJnBCNla6XqbFyxZnn0wL1wBiR7IYw6EDlBPt\n1LJk+XFyI2eLAEJlg7coco5MgyDxGFMPZhwfH+CJrNLptUJWgOyWJ6vX7rV9\n+fYA9PxPvCcBMxyL5EzuP79W4R8H+9KNLuokegklWoCS9sdTgRVtxMxSfcxw\ndedz2viMR1zTVZoAegEghQZwM8Jv6ZEavqLDFmWNcNE8EG+ym6uBpxMKFXLT\n2ybtN16NrBbCwSzo4+9TxRqVdrrnWgkhTjBSpzx2SHWHlANKqxFXvhl/Q+zC\nu+x78zTDsF55KMmPvqxqNZqC7Z4sybYLCNGjrLIkQ6GW9YPqgpYS4IDXDENb\nkXhH/L9i4NVPnxLWhXdFP9QjV3aL7Hj3i7xfD24wEJ2yrl/76RzFSZIzWT6U\nWC0bahYvzJhrm8lWXCm4Bdc7cVDLj+mmyI5b29lYEgYPvdxn4sPI5wHJcliE\nS1Kjw61VFP8a7/KrSke2EdHFpWNoYXK9EsOsCdHGX690HMBvSeoCiCZx8pRR\nkQSE\r\n=S8ju\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"77db35c497db8377013eb451cddea6dee8f304c3","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-408a3ac-1582832230592_1582832298566_0.8268314198913695","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-ba61eff-1582866432404":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-ba61eff-1582866432404","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-ba61eff-1582866432404","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"61296dfa9726d7e9c973d55c5cf434d7cf166b21","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-ba61eff-1582866432404.tgz","fileCount":30,"integrity":"sha512-lLcfSFazGYKcMfYbnrpzq4SRFvkZpFN0FXYHFui1Z7rGY8pAGzW2l/fZiG1HmgLwp52IYMtY2C96ZC3RFGyTRw==","signatures":[{"sig":"MEUCIQDRqlI0LPBHCbYgDA35OLcUU/a2d6Y4iMQFAJlgsgBL2gIgb64fkVCR+rdlMPMswK6sivn4mlJsFrhKOkZgX3N/KEg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWKBcCRA9TVsSAnZWagAAhvUP/1hew+q0hMyKumB1mRvY\nuIhaKn1Erlo0WFBdwFlgXsDnGb/xMOwStEP/FGR7UTQ/X7GrQtWYWTdamgRr\nYp6nmi1cdO6/OvrgRX6Xzk9L0mRM12KQBkSUJtlnSLQhH6R8+K65Wcgsh91K\nnjYdPMkDSz3buBybEzM8O/MrX1vTz+JZwRnS5n4jZrE3dJLilk68MiP828UJ\nAcHSF8i0D/eU4o7S1KMpAdSnzcEvfzfbOG8gLpVrjBHv5HK5rQbAZEfmLA7b\nw3H4V0mStH/7cbWGs1I4j2AOy0rFvdi19NDgSCQ5p28M4zJPRXdLuRx9KS8S\n6AMgMtPmb3OhHcdiWOYMyjcpEANyOmrv5cPCvu7Buts2/VpX28LfEabkZTxP\n5DNqsq0gl6XaKNsAjFc/ZkvS4Q9aqLd45gAPsieoDqVIs0U7z4Y8fPaI/yDB\nxvz+EFu22QdSTWqbSy36zKbEdLa/+BRVPEez+gJ4jTvfRqUwN9X1hjzA1Vl4\njiwEN4H0KIkAAJnlrd0WfYMg8QaDJJzkMWVY4Za8e1qVwlWWCbm7AMxb/iCH\nNCPyMEoZZ04Rngp4x7AluxXsTsqhzTYSqHgvcGwLawxw49csTZdA1AyM8Qo2\nTLk+nw/pAIHcruIxfDedaKk48C0LyvCRySYRMPEnSLwwWPHsHfyNCpyuhgFr\noUS3\r\n=kGc9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"04fcacec981c124ca4cc13e4cf27369f15977f58","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-ba61eff-1582866432404_1582866524195_0.453702969961463","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8c3b0c2-1582866612780":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8c3b0c2-1582866612780","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8c3b0c2-1582866612780","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e59b49204d68c7d142394da4c03f539e4220301f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8c3b0c2-1582866612780.tgz","fileCount":30,"integrity":"sha512-CeM9M6yTuRpbr69NR9m9Bndcn42Hmcf0NpoPrWvLe8n7mce2in8f8y9MWRhAGz1v+BdbUP6RfpURClL615u0Iw==","signatures":[{"sig":"MEQCIBWqd2lYrQdEq3VJZUBfTsmlOUD6CWMOvMzHEoLG5fIFAiBUBTfOFhahfnqj4ACUjA9eE40ysdfGYmhida4jwRHLgg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWKDvCRA9TVsSAnZWagAAC8oQAIUReOdmxDsEV2FO1Rhb\naPQ5pq3w2TY/vnoZ61ovfKNf6APWkgAyE6efEsQVOpbIG1Dq2KsY4j+ki4ia\nHgTvYwhkCLhq0uBL44ct70JAlzlLwE8xmFs7tTgadn8v2d3BAzpLvaCpxnKH\nD5HonOUMGkiuJ5Jwv5ykZNtnyT8ZHAjg612hTPhJPo9G6g1JP6QPPq196aAs\n6T8KQBOsBXovo+fgQel8fdXOKUufaH1Hr3nEOSmr8uu7ghbd0PzxjbOvlky6\nal9g9fkmyvuNRxuaFs5qJRP/GAIx5Y/lh9aCPlkGFvyzjSU5RIOdCYsU5Ng5\n6J+abipRvlKMgNdAD9FKRWcsZwe+aC0AtoInwx04GIn+jzb8bX7lu1DfjCxw\ncqpUGzln0Bm95Kz43zO+dqGXs+DDmyCRWyIwZCbYQQkBnxzbYmpv9W/+0KLf\nRy44jEZRP5InTpUYe0SFJlPB1FxYhKOKy5RWit+8RCEsNbLP/3u8xFLhNrqW\nzK9/tS0iS9E5inMNJPkOzyBb4NiR+2Z7RTi/qo/TTpDPTlTfJmEjSLALlokY\nOjHIUlH54eY/KwexaiutdNfUTSJ4k/REcdC7bWYJGp+IbCojU3bGHIGl8ehZ\nsmi8eRd7Ip2axIZ7eFPzorhFHH4m6tiouy3ndSC8H/dcoXXxwaXXdxrZPb9k\nsbd4\r\n=fRLk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6570fb89eafc0b166855472977be449bbf716ae7","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.10","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8c3b0c2-1582866612780_1582866671046_0.7209469088672171","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-908f2ec-1582875554986":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-908f2ec-1582875554986","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-908f2ec-1582875554986","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"abf2575db4c886025276a11a741846379ebecc45","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-908f2ec-1582875554986.tgz","fileCount":30,"integrity":"sha512-vQpK5QMMie45McaKd+5kxkunlwZGQkJNNwZImCQUMcNjkkd2uBE3KOJphxP/jHj3wGc8iq+4WwM+5p0zP8m4+g==","signatures":[{"sig":"MEUCICcMt8BiXtS2lHH3jKw+UAEdkZkBiyNkzJfogAsd0C4NAiEAxLDWHbUh5RTaT3NxoY69QnvCjaM/eN5amoBLxMX7Dzw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWMPtCRA9TVsSAnZWagAAOUMP/2lyJcTrB+GlhHbz8KBa\nQqDXTD3E8Y8kWO6Oq6Q0ILB0t7ec3sZyXOXwTv1FZIe1KfFwzigMjwyneD+r\nIhLgCqaU19gk9oqPM/ZFlWN8g/VwSJFzaAQ8QEpwyGrf3IbDnmMa0kt4x5dD\nW63Mdj5/iR40la1ZTMQEggjr/yJiLnix8MNQDpw9+7FoNNTdClp0DDClorPO\nqTtw7kRjmqH4wUCYcGx5+ziafhUb3d3HTOisyOSD1WaEt2j0a3g4eH1BVoaZ\n5TBENvsi0+k0OIRjyAvF5Pi+jMava/93fp6IFpzu92VoofbgAOUqlApE2AGd\nGssfINybqUw9iNNlgwZBomm07safc8AF86Ccma27T8+TXQJV8yFzSavQqPPJ\nmgHHot42Om5G+HFeH28vYJ2FQ+TmOL/pf8pCEPuMRBqa/m3cITv3mxgFoS72\n42NyfTljyqmoQcAH64H2gMkW2sRo/q7XMo7LcO/zak4Pxy+MWk7shpL1rc8D\nGpisyWG4o7XJoNbxlFroN4t+kpSdtUer3KHP585B90Al4riRdE8iCAJnKH4t\n6TQqwSHvlFV2vGUsS0MiY5vNaZnwrcQqxJsdfCoz2gs6aJ+zFM91Dwr3Suzd\nrj6nhxFMAW+aub2PWf6AbLc3GQwoO3YYhUkDDXlMLP5uKsEFDweL2buO/+2W\nfuFW\r\n=aPEd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7e55ad0ad185cba22bb45923b9588e90b4cb2a3b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.31.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-908f2ec-1582875554986_1582875628890_0.2733382217412159","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-1c3c525-1582877195028":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-1c3c525-1582877195028","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-1c3c525-1582877195028","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"65ed1b6f8363195bea2d645fa6ab2c42385db752","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-1c3c525-1582877195028.tgz","fileCount":30,"integrity":"sha512-m2Gb2wVY/t8FCz3fxrqTpEHIEZI688Ozs8HdlTzNUY+08R244Q0tg3sbzuq/o0UQ+NDrM2TlCkWm5avc6MQQqA==","signatures":[{"sig":"MEYCIQCJ9feoVYOwANYlMaCyRpePJ+WTaVIXgu78XBvQ1DL/7wIhANT09HJPUuF0FDSbmi7PCa3v6WednsvDCzmjTXhSCyKG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWMpQCRA9TVsSAnZWagAAUEAP/Ax74NCOtA2NHve8PGsp\nqP122qae3M7xGg1ILM25miYT21SR4LLGyEK7F81Oqk+v9jYr5NgKHFtqgVtM\no6ot2Bt75e9YzjlbzzS0IKJvGkhsgDMik2y8bktd7ZKwGgT6CDW5tEE6vKmS\nCU3XQpOJ5aGbXdrBzg25OX0mhctaiNSq6dOWbZOC3wfxCXPfmpIa7AnKPXBW\nrlshxjqkg2tE3zBCOomt6HwzkBhYIyNCyct2UqOt3A6roEVKcodAJapO0msZ\n1BuOvorxzgiGEqCaTJr6h1Bqj/SK55peasUjnYtCbQnD3PjuEJSfCyc+K+D2\nwqg9Khmj0q+awO6NpFWoiOPJZGjrTOtayH8k4vClPj5dRCP+RFEhAgBkiz+U\nRvcP2bJy7wy7ZUOyZNBz5zD1Q/fNfN9RiVMzCJ7Ic/jMJ1AHJEGqM0zLkpWe\nJDuh+Zvp5XY97bFXJaJhSQ/6QhAzw6IRV04V6kPrWA/K/czQUC6OBYtCwrqi\ndX9Cs6NIdBnCV7y0uDmv5CVVA2G/EjoIf/XRi+92dTkbDV4GtQovGeIQr3RW\nQOTT93LRgA7Dh7Id5Y/qXWMRqalJD72N87a3DJcJWEKk6btkuz+yMVzUNxAW\nzchYyTDf/pjWjtq1uCqdeGVJYvak42Lwya2uG2uNxiT+nCWX95TZLmNanoDL\nj8EC\r\n=HtVv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"04e5abcbed8846286cd2a17ffb31a57fd8c4617e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.2","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-1c3c525-1582877195028_1582877264127_0.07062902829282103","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9b876b1-1582928452729":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9b876b1-1582928452729","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9b876b1-1582928452729","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"29ef2ffdfef30631f53c5b142983811b9d7cee4d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9b876b1-1582928452729.tgz","fileCount":30,"integrity":"sha512-zJPNYcef68MGUr/04MMV0K11kGTw8j9/oV2e3ZRsWMe73/w9CSEhN5KPO+5nu+ekGS2SG/vEwmPZlumJqHDDVw==","signatures":[{"sig":"MEYCIQDI2s/38sH9dGW7G7OzbRnXiQ0IXAne6GeSo+RJIcfuZQIhAI5tlJd8J6iIJtlIfGvoLzrCQHExNTo2pN89d7BHrPg8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWZKOCRA9TVsSAnZWagAA8WUP/A9BFjxqPL8lF8el9Ezo\nWmpE0BR2gnUTNPtHvinPXqUvmiwBmGmzwQcYdrMa2g6lQQ4mbNUtdZVaeZMd\njEZJfpEBOVh/dCEi5ux5c0+2ezZS9HxxvtlPvkhtiPKPxFGXqklFHyV0AWsN\nWiprNn3yqOkdSiXqI2rNgAXBu26L9EfP7iNkFR+AwRvbEH6zaLt3i8K/5xkD\neWqYUnLU98qhDvCNrE+RdyeYoFe6EoELzC/cG2s1pA3wHFLTI5NM9WnbcW6L\nW0P97rhVemoq8a0l+tkQf3kd09LIwTO2yHUxv39gilOL/dPVtxAECo6I4Wlc\nK/wZOkJUeRyztfVELJZbQwOmBorQjyNtDPg1K3+j1UCdfn4WIMjAVEYIU1xs\ntvszHy3oYBKFrqfJUTWx2+qRgBWf05sWiuQBqrrLWsbPrs0eRLV3r2uhlgUq\n2Ovomg/p0042wB4mtdQwDsZRfkY9MuJNcC+aqh0UThSmswfP1imKJ+9g/Asz\nXPsg/OM4f9o66zRyXDsfPUVqjeAglzk4RASLlKke50jksGADVVv4SBziWJQd\nUOKFcgbkMO9ytXxRqcHUKlcecezdUOQIKvfRiy5//BZcFDHjXu/DX6+u2p43\ntE8WYjyfIHJyQwNac7jQ956SkPAAJo6THaOqHlK5xpM4YmwRECJJ57UVmHiH\nMA8o\r\n=yas4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4285275131475e24a058f60df3e930e4262f4e91","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9b876b1-1582928452729_1582928526486_0.8268374706239197","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b8922bf-1583140297230":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b8922bf-1583140297230","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b8922bf-1583140297230","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c6ec534e0858d7ae3c0369309ff1ffebc0f19ad6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b8922bf-1583140297230.tgz","fileCount":30,"integrity":"sha512-VvD0Ohzu8ygIHWE2AuJOA7UIWFwClT7sy4DvKpBtMy333v+1T8ahfQThLGOogF+OSr544UVYpyNfK2cSvWXqHg==","signatures":[{"sig":"MEUCIFCtiDqz91gaccyd2z6mPag5RX2M4DA9MDDWCKWEqKThAiEA4/FUoaA+jmVCPxYrq97n+u+IkG9HK4UAmuWrgegEiBA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXM4cCRA9TVsSAnZWagAAaGQP/0JAM81P5Hv8RcI1bupE\n9HZrATDtjDCBcg91i9rDgxBBR2EyBAMjoLprLbbbWIA1JCcA+g84e64UoHIc\nzBKjdcAdis4TDmJRyTrkPCol99DYnITFE6VQvyNfKRGYuOMthGvi4W4M0vsB\nErSwSe89ZVPMx9mfCFDvPJQHertrURev70TYS38uaboj87+GQ/QVowuATbzB\ndpElwkmYynx5P0POnXeoLJrDjfDJr0NLPL4LWZgsuvtINnzg1mnXKpLw/Y1N\n6ogOMIekuOMi7ZdzaRI2J0iqbScmhzILweiewwiGouLWVJ47K/WwM4NbBEbR\nAUcz3hXVLZdCYYLQOC/8tm7EM4pqfXUn2ybZFUrkaGFSJ7OkuQo92EpvzzK9\n6XczRwTCkJD/Dr5RS+MTG+GQl5Fbou1C36lOaOEbV3tgt2Tn0IULbj12DC5P\nIYzplkmW1WygUk0CnvjQ2u0/vl3hl//+bne84ze/jmI+sOnXIw+FNmfZtqgC\ng/toEuxhXVP91B57QEcGVN/rCYDGdde41ueXn5kJgmdH468ajGXRcpaWpznL\niviW5yg29+w1/SjLHkoYe57QJPFbT4d5JIJi+HNmlKAtSdp2o7Rxqj+q0Aqo\nncaXtK4ITNGAwJMjoX0Xil6bweI2icEiVY8Hrf64KPGaxyGtMQ5uU3K2sP2c\ndlmK\r\n=kfHY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7ee3baca40ed4bfdb077660ccb091fbc302289d6","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.4","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.0","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b8922bf-1583140297230_1583140379919_0.9679893785287697","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-15c0677-1583190863208":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-15c0677-1583190863208","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-15c0677-1583190863208","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"60106db8432293938caf9fff105a6965e93751e6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-15c0677-1583190863208.tgz","fileCount":30,"integrity":"sha512-ID16qkLiq1g91FhyBi3ejY8sla+h7dAXuaiHe/JHm9d6LbJ8lTv2141k/oF2WVECfQefsbkPR3Py2LJMYaVi0Q==","signatures":[{"sig":"MEQCIB6g5AKhyjt+GQYiWjKu8MLc6J/yZomB5bethou6BMe8AiBlbk/GS2gtWS6WeJIkQi224L6/B+wzys1Hy1A4hueBsA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXZOQCRA9TVsSAnZWagAArd8P+wX6G+72HvEZiVjQ9wof\nSJ+8FIdln9AWZAsFDjaiUjJS8844mdo8I+j8TFVnrTi0Fufl4gcnSqqVIzbQ\ne5BTJEdGi8MgYTRA9dinuxHK/9wBRWxUyhKDDdV/HwbiMss98Q4wemycH53w\nMaOu1wE1WfPTLP5BffOPi7nshT0Wl1qAGYlKHWbAcB3+zLQ5nilfIURUZgqI\nR4Zox1kw+ftMlqhjMrqluT00T8/9YOWDMItH4zXsS2dPj/Ry4nbvj+PTaMJy\nose9BEHOhzz8QMObcU6zkzOM88fb8Si/aWTjvnTp58xs8yIEigCm4c7XOUUu\n/Z6zIyfQB4jkaZnEeUYxyqtW+FZZXKfd123han7igBSwIQN+rZCYaLVpp834\n/pFit2A1DTnDNgtOl0lKQ0RdAygqrYOn3zOhP2VRhxq2CU4CAZ8Qe9/oEmuE\n6Cf9KUJ2dfllOZ0G/BDcE5l+Cwf60Oe3Q06Ku+2fY+2CDVtE8bHVo4PpQL+j\n7wXHBO25HsSe5Rqdfrl7myzSFUU+/CKJYsgoIW3EKiAchiajkMzZm3eYakZm\nzxAFAd1rIt6LBRTOr2qrlgt3jegd+2C2yBIZqRSPhx5BeTtp5Dc57zOmdRqv\ne3E7Ur7Mgiy0vRL2VxYbfGprWvbxC8EtRwAgQ6mvDpV+AX0q8PKvgR9PKikG\n6t5I\r\n=xm31\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"99dd527955944d71e9e0345a0505421000199b66","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-15c0677-1583190863208_1583190928088_0.7446244596298706","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f598663-1583223418154":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f598663-1583223418154","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f598663-1583223418154","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9b1c1821d1b36efce21abdab912d6bb94512fb8f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f598663-1583223418154.tgz","fileCount":30,"integrity":"sha512-IrcFclU//IbI94rTI9SVUzr23y/yK+Gt1Ak0D1DfQYGauSZyD45CZJ7q/U+Ae7I7fLfJAeWlVKF2M9bmcmn79A==","signatures":[{"sig":"MEYCIQDecGQFUnk4xV5V9kKcKtygr8Jlv1falMq5n9LGVjm+ggIhAPiPmHGfcMxWShZj0HPL9TG+MMHFqwUhDbdHsTrR/vJw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXhK/CRA9TVsSAnZWagAAyFEP/j3K0cjFd/NXCcYt2etm\nIjAxm1l+waeLdDr2FM7DMoxJToHQWFv+tUC9X5MrjA9DdEOAoXEkdLNQyeQ1\nj6WjTylm+Oyg9wdrg4SVBhTh1N60H4R1aqkhYAoNaYoATjoixaz+9h9KLZt3\nfL5uSB6QAG3MUYFko2JRry9g8KIO6kLg0QOsPX1lQW9POIzluQJzsOSGYfqJ\nQWPnrK7psYbp0Lxw5smwn7p7mwnYlsYaWIDm0JLG5fqnRs3deGEbCXl0n+Sb\ng7SZdFS7Lnap/ShtZuUOlHvL75cg1Gcm+316vxA+JYAH3UUcBWsgwygrbMSC\nuBqZWoDAKoTb2ldDrYB9tqCwUQFXhRDPJ0PV+ye8mBaK45zEB79wb4IPkDkq\nqSKz6hyQGJx7Hv9Ey1kf6YZOPsZMXGRat/RINUGILfhEWrZ+KS3nes/apPZd\nMZg4F+p4e8RouHpK+aOgXq+EgnEt3Rkc8GiTTwnco9t/esw/oscWvfqpOJXU\noWpCvSuvOIHJt11HPW8cSo7re7FJO9aEl/scF7DzfZueEVr7MSBnZKKXj51n\nLo2aV1jHXD3rndE/0I4sCcB2hQCLvO7mO5PQUbwouLGtF1JLwgtveMC26jnF\nUfhu/6ATGEDdGJRJbDfMjemcLzZZoeYfOz/Nxu0Ib8Fc/7tEPyOeu2xxb0K6\nL35S\r\n=bI8h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d37417d436ba6f61e44305f73e70967a14079ef2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f598663-1583223418154_1583223487198_0.5098058017368445","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-71bf3df-1583224262079":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-71bf3df-1583224262079","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-71bf3df-1583224262079","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a26fea1a0afcc58758de7afb9e8e6d173f33849e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-71bf3df-1583224262079.tgz","fileCount":30,"integrity":"sha512-GcEyF3K0NG1VyKFo5/UZwZ6LtLDRTwspW4EniJtoQ8n/5TD3ccwQVkz7r5F416j+24wSWq3kpPB4nPDel9Hezg==","signatures":[{"sig":"MEQCIASCH2V+eAIsVr1eOudrIKT1f77KP48FjbzFUqaGdCrsAiAao+MEHcvgePMLvlHa4I1TSDE3vRMZbAUYCqagpfjUxA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXhYMCRA9TVsSAnZWagAADMgP/21W8x1jky6YSrYV3y0J\n5EoE9enI4QBzpouubROfsGrjYs2cOYvFGvU/IBUl3GJ9MovMMEv3cxn8uweN\nnoYdTbYyNgUBj2aZ++zIgjx978PDH1nmXoXiZKqOZ6F7IkLpYAqvvX7AwLT8\nvSBvRg02cLihiMayfhP8b/TsXc5zvpVh/4UxW4cGfD4J0qdKJOi93VsJg+0w\nqkZXY6y8MEPVOy4jwXs/fYTm+Dzg8INcjkPebS6yXrvIQnUcZV/LBwhvg+pR\nQ9PpjS0pum14yp5ILNIxS9be4MK3KeQ6VLLBk9yllsCYIegV43GvXjz+zfpB\nLs+RUtCtSAOJ8hcpIp1Bn3IW1Uqf/FmGDSUdNyXH/iZwEVhfNA1VYDpxnEkG\ntpn4WSPMEytOvgsYiso4GF3vW+75HdCiiJQ2YYy3tYiH5GnzuMFH/3lYwzFI\n6ewaCLpJbFF1MGfEM5Sp5KWgr1feiai9fsmfYiS/Nb3U1lnVxw0THvCNJcbG\nFwNWurb0BDULBg7hWvW6fZqF96DesnY4KEJkwv+7H6gEXVTUhTCK1MWuyKC2\nYloEPhSKDFHjXLUWgpj+3AvSXcGagyZiyHm2L+aQeFvZ5Uue2RyhKCVVH0nk\n7+ue+a6PCq64waE4sr3+UmalyvHzuejdSyoSm2LAABjJvhq1DmOAcciZJ9RJ\nM9Wi\r\n=7iuP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"bbbfcd96d9acd67a7f9b3e6d6675ca2f8fd17d5c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-71bf3df-1583224262079_1583224331935_0.7801007729922476","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-43877fc-1583373907356":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-43877fc-1583373907356","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-43877fc-1583373907356","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ae225c5508b4ad78ac8eef1f66fcf57e0e216198","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-43877fc-1583373907356.tgz","fileCount":30,"integrity":"sha512-BpbTTGAEB89bziE6JC64WepL9qVR4POvI21voy3yJbCZQcGjHuHfhv05SIWAKpAc6SvXjiMgwxTaXsXOm6I9ww==","signatures":[{"sig":"MEYCIQDlgikQNZyVjpiZMZrlxqYtx69QLPL7E+OPqnqKvSe9oAIhAI37KN1iW2fKI2C8dhp9QnrWqSL8qrM03SWDSsk6v7m8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYF6XCRA9TVsSAnZWagAAlNAP/RQnouY7OV/kb4ESZ6ef\nfXLUt0Sb2Bv/b/pbc03KUkXdKt950VHhHJGFLBe9SCwrTMti7Fz69ur2LoF1\n34iM6KZHHk4q9Y2qyliuUmZvMummFjf5+9jIRrz8youvMDhUohkpWU5YUiG6\nGHzlMVa8ihTM54bLzCgsCNI+WJ+rLxak/CTCf5cr4rTS4ehbj9z+UQQ4eBMh\nnGRO8iUdrwumNILOJ+nVgEmw/uMfccyTcq+POp4Q8y9J43YxdomNnEKnVYh+\ngQMY3xVl+V4uHmzcQ0E1yEr6M4EY7sPYh71gz1LXApz1Ogq/SiHyd/5b9+4+\nQarDlkFgQt5YpO3WTzHbmvnqJ37LqH1P5g/e7VZpAmxImuVPc3wBIjaD0wud\nV3a/Je94YOma6RTGNHd9oD40MyI/6apsRz7+DwSGG0Dldm04NXlIVBLK0G8v\nVxxhlVkGewhvqyDTP81gh4ZtRR53CGzqA8qHFPFDQmARxNFX87haV5EjzU09\nVEZ2ngknv6bM2db4zve6L9s+RGhHOCsN5SxA+pj9OR/bcTarmRzRXPNr8Czk\nmLmnTAfvsu6hWt3De6IFyZBUKY0CfZqMs9mpr6s/eUFQaybzGB3NKqR4FlEY\nlKDUpg64yajGNrwVZFPdn6zqho5yj7UAqaLKSXPUK3MTVVHpcU/E+FujPiwc\nckic\r\n=qBVj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1b556551b1d2fe553511f442371dd1c08bc83d42","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-43877fc-1583373907356_1583373975405_0.32515611230750596","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9ed3693-1583373905185":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9ed3693-1583373905185","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9ed3693-1583373905185","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cf80030e99acf1ddd79b929f4863181b8738a6eb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9ed3693-1583373905185.tgz","fileCount":30,"integrity":"sha512-O0w7zRwgweFmwGxkhr3N8tv4HR0g89K+GAxqcUXHci4roVmhWoX6ONsikk2GXaBfgzcho7LHWQi0zvFcrQTI0g==","signatures":[{"sig":"MEUCIEEBJlQp18wxbsLjYhDVmNWaRz58ei00I4UGdcWspOprAiEAuYZ/ulD81FdL7D+Msyt/5KgzVXqZHDx7igGYz4jSlng=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYF63CRA9TVsSAnZWagAAzM4P/j7VsPlpKzoeNClKK/9n\nnCMusn3SsnWEBHlwcz9U7BqTy+TKAqB6Gtvh0sV3hQCqZxIEzuhaukp9DhTE\nDk4FI46FAEZW+elj7aCJCyrak63qxX14rTcTj8pMKDSjYdMwUYUSw/fpQUw5\nZZXxwink/gfMqiLmgX756EqDo4zFmTTa1tql6H7AdIGwcJT16vkk9uXwMXEa\nRVdPqJVCmRWnWUR16QcDrOb8rHRpRG5nyccLcomb6gBqlnwwvjQwLIBoH9+k\nooOVnAbEARmloZiPbUkKysroXigEMiotr58UXE/c4tO6wsytvqFTHrEK0tWn\nZQOpzGEZTL6GATFjp4BIsryEo2buapxNBCS82xnescDrzSTDavllJ5SYCUip\nksby0tYOhgqDwi4qOyYYFTowu2Ue5YcOcb1IZYwifExF8GyqfABsH5YRuYGL\n4ToBhNq3mCxpxdVWGVeKRF9IQyMNiZeP9mgz4XGHGCDQzS3K2nSV1nxq7LpC\ncSaWZnZWFWc/eVrvF3e/smPt2sxFKE/eyDNjZwdSd4wUY+X/Rkgly7SUMSfJ\n+CFkOCD/zunhFpcXAKqkppszHNM50AXDeLmiv3htNPx86FaVMkSl9Usk37DN\nOEhrTcF7XBm4q4aDXW/IfHM4l1qztmwGFjIejrlMyQwkAg6xe1u8LGoALQtI\nyfFy\r\n=VP5D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3c4a0de33e910e614bd9f1d3dd5fee0959006f76","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9ed3693-1583373905185_1583374006946_0.331256806617491","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-565a7e9-1583397689607":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-565a7e9-1583397689607","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-565a7e9-1583397689607","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7c7722a0d91b049c63142465220bba1960f0dc94","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-565a7e9-1583397689607.tgz","fileCount":30,"integrity":"sha512-3MiyPgqrrxNq7oABnThTzAEfGbGDJ+LW+yeC05I0pEBqty8GuW+VCC7krdgV2C+6UWhJVQf4OQCQ7nL9dnOqyA==","signatures":[{"sig":"MEUCIQDqQJErdNCcQ+RkO+rXUiCcanwR3rNYyP+BHHnrmpMf/AIgUHlbm551tQ8QbvB10TbAN01C59Ks51ty4Pfx1N1HoxI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYLt/CRA9TVsSAnZWagAAqm0P/R+oxG6iMcWEbwVh2Fmw\nLmjO0dUbehUg516kyPwkmGA5xRybG6fIhauex9fWEWOdT0SF3NjG3o2HZ94q\nwEbuTD3qAfkEY/QDNPopfSmFn6pD74e9KQsM8TMEraslWYDRMRae+iArvd02\nHQraVi7leGpg/67Hk6VPJ1wnIQDMrFJD3lHOPFRNIS4nZVR55hFmuJFH6ey4\n4rTQk+f2ysOd/nkaLF/fwHAzFIO9j3Ob8yMrO9x8xfpO6A5ioIPpCRdxBJpu\nTTdKDknvGUvX7wKh+otU2opMMxd2nFQyet+uIZo5D4CoZCl9ByUfYajFmsQI\npB+ZLqeTeHA/k2qDcfPpqHSxJI8SpJxgFG89drQgHVz+8/5Kn2l689eRtPb3\nIGJAvLIs6AlmcCJuqGZ/hduSAK0tzfZCZy3iJKhb7AUsgIJWuCmzNEtAMAql\nod10FHzFSa6BaEdDNwyB6RDVGuhqlqz8ChuiqJJgCkXQKjFFnyznt9PPOSMF\n76x8y4t6z139PfcSRl4MI56SI9yUEuYyGKi6e4xP3xJQgyUme7YUKKvpvj6B\nLBTxFuir2M8spkO1iVf+MrF2tBVm+IrM7dvMf2ZPTQseu0Xt8QJY7WBwfl2t\nzUvvR/o3mnt5sJYz3Z8W9b75C6Zw5FZhPy5VepSo4JXeidm4yTQnwoQwwI+/\nHGk8\r\n=9hrD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0c6070e3d08cf1e338f2be7c386885f489c81ec1","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.0","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-565a7e9-1583397689607_1583397758931_0.9116206289843622","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-cac29d1-1583487541788":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-cac29d1-1583487541788","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-cac29d1-1583487541788","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"154ef7cd9d0dc1add9bb369cf6f74c0ffceb601e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-cac29d1-1583487541788.tgz","fileCount":30,"integrity":"sha512-ZBxansu8WnhFeJhgHtvf/1vF9NIQi1/qqD9pvPx8azjHeYdDm+vIAMviY8jhFfTp7+DTXiFhvWE/sJb/xv843g==","signatures":[{"sig":"MEYCIQDpdlfvuUvmclcS8yZt0V0BzGYLGNb6l1MPCebNzB9lywIhANyNDA+mwyNZP487xDhOyjTHcwCRVQWn8CXn7YMTv8LJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYhp7CRA9TVsSAnZWagAA6VAP/30g4y51aMbmQ6s8qcMM\nZR8K6bgiDUveQBeMJ8Sr49Bq1vRqxSxKK96NXmsM9XuP2RhpsIZCTK9jO/OS\nlICNvh+7LYg0SUIKXbduJzs6TUJU5bCsM50sAKIOnW5UDRUgkz5huE2QxMmj\nKq97hYII/XZp1O3S2tuntxhL9psrz4iTEzyiLqZ14wf6X4dbIGPM1ZuVoBFC\nGr/8sq9DiToQ5jksGBwsfPJGJf2bYvhZ0qImV+5VDrTsN74rHLKShynXgQ89\nAWlKzw7kJc8E4/RhdU6aevHQ3b00UcHD/eqijOZ/oxpBKBEqn+Tu0hGNob/X\nE6pQyQVUHB/28gcv2Q569oDOmUCy76WGFmqWRbWo+sUcWQ7zCB2iPaWrcGB7\n6EOO3+LunoAmOUbb4zDIkuUyjPvtRXzun26klTt7f/NLzrXLLPNN1GenVgJn\nD/JNCwO4stZfg4fDLUTjx06WZA5NSZoFegIg8jBAGvD/fkWrbylzs7hsiL2G\nfdo/IWDiwxeLEamHKrWiPld+fG03VXudSLFbEMh33heCAOwRGYQAPIF7jIGk\n3UWFFwaq1X4S08Rd8KxdSGzjWQRSZ27JhJ8W2C3mafdDaONVwPwLSOEwTZ5a\n79hhRxL1vBWbN/61tRTKQs3V7fcS7/hnUZh6g9EL9E9/RcsBdxVrwbUn8l+Y\nv+/S\r\n=T42Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7767cb20b05259ac7815290d489174db3da17378","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-cac29d1-1583487541788_1583487611034_0.8946941536177551","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-202c16c-1583546364639":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-202c16c-1583546364639","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-202c16c-1583546364639","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"65e0080316b8c67f18350e740057c2b7556461d0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-202c16c-1583546364639.tgz","fileCount":30,"integrity":"sha512-AmE/np0CDaUZikyNIEhPqz1TbwXyLJH8mv2HBfdIEUXXgIWNS1d1tYxHOC2aC0+v+oOb1IwKU+IfxWyyNbrkOQ==","signatures":[{"sig":"MEQCIDBg47iY77cmnsekwqmHqeI4NQ0jEht/+xorpa51skJKAiBn1adbE+TqBCtMP4v3VcCQK3aUPKxlruLcm6Rx3jMBRA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36556,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYwBPCRA9TVsSAnZWagAAwSEP+wXIs8mY/ptpa9bKpJsT\nNqwZUUWWxAywLVpG90JB9a3BVn3AB1wrw7eSy7oP1XhQ2YutYR8Rj7I8w62v\n/l8ry4wB1W4tflYa3ArQg2Hi1z65br4HoSz49TQkRWBtg7HTq+BE5zVUX/aa\nSjdeGxFiihySQBkPEhUP3+RP18AaI7vOMyH3SxF6BT1hWy0GFGXTbujLH1OV\nqKMSiZTJ4WXW878ySi7/v7Wha7WuIV++E2EQADDmPqSyCm6QjV69ci580Ofi\nlnnXtffoRAP+1SYNdw8y7RU+yAbpx0IzcfQEoptjokB1+Rs8WOhjy73RYMMo\n6U9uaqoia8Zg8X4VtlV/TYKvcmGlRPRYm5KNPRtH3xXwJH7p4c07UdngYMOz\nUOjm2h+kH6lLg2R9qt+ZydvrrUDJwqGhT14W5o6AR3XHEPBqg5gZRchohS4d\nlPJ6IFvnDELSQND8NWK631olx1WNRwB8w9ohbUq7ApNbpJrjTsb5tDmj/lBd\n3BaYeND5P2oBYqdDaqsXRm69fJM5MO+oHGiX00exKCuRaXL2KWm57Ut+Rwhz\npxLf1sY5zAili6nwwg1vGosXss4TT66Ig2931767dD0f297QpH60Xo7uWD2x\niyWAP/xsT3MskWBCNHswmg4GIz9hxNbJsfpjwh/rvHurLqfWO8noYnOYLJYs\ngeTP\r\n=t4Z0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aaa35b7ccad7b85db675f9ae1af905815ad7325c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-202c16c-1583546364639_1583546447347_0.04252780856177951","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-d1ab09d-1583782623241":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-d1ab09d-1583782623241","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-d1ab09d-1583782623241","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0a52c692265116a6ea5609292fc2c9900c8c4d9e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-d1ab09d-1583782623241.tgz","fileCount":30,"integrity":"sha512-TPDVwe5SdQNFeHHyPQqovDnXDRPjuSkHvqGbKk6pIQgjvHBjbYJPhX4Bgjs1k8ueiYgdBNU0buTlNrLR35ywZw==","signatures":[{"sig":"MEQCIDV3wfF5RdYvjTpH2PT5cOvCvA4IXfZ1pxNe+5HI5Rd9AiBaXxLIAdB0KZvdmCBM0DRUcMzn5cWAwK7ZkM2l8ANlBA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36554,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZpsqCRA9TVsSAnZWagAA0xAP/jzvxK0VrQ5yKqRYpoZ2\nEap2QtHp2BDP4E/v2G4YtAd+4FLwk+pccyTEs/bRJaYHR+vYHPXzU0yxnHUA\nl+a3twfTytRbYKjSI2Dj8r/i1iS8Uk9XHHHukiOYPttEQUAW3uRud9RCjo82\n+x12g3iAXG5M4feS3xm4RQR7YLeJhDsBtUHRLJpl58dEDhuhzX2hRoftcj8v\nk9mTmB2RGhsoY/mWVTi2ib2YfTSNdQoTQj53cBggaldo1xam2BhR7bah7Mdv\nZ+vqzJFafyH+AsFyX4mx8X+18X6HJOgXYazPN6Qm85ioJP6iHYKQR5YvoAgz\nO2GWXfQ22c3EDKgSKOU9z2BTlhQRwqgkzpaGADi2jmx9Hcp8sJGOOvJ+RcVt\nhiAXIsGtr3ZI7ruMpPf69Xm/scYh8qc186w9oPaQbwBbxYDdpoQ3k0AS8zvB\nEoFGqgbhU/6NDwxiTmpDUxfMjWcfj7CTbOiftzH/fWQgFPTL8zmv0jgqzvwP\nlEcdFW2aEpFqJSsCg4AmC5G2zSyw4TXYPyCSlckg4/HdxEBeCxYb9cCaLsnU\nZDJekC8COe6J0/da22ct691JWrIUmZxmlnsZkkXQg9HJ/q7WJstCt4amm68e\nTlRJkJiFH00SqgdEA0XuTcBUPRYZTS6XOhEz/hXCjFODm2IAwbTzb9qTW6lB\nKom2\r\n=zNjr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0014ff29057ac119c4024b8dbdbdbb1e73296848","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-d1ab09d-1583782623241_1583782698077_0.23091137051758515","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0060be1-1584025901785":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0060be1-1584025901785","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0060be1-1584025901785","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e2c09908ee1cd4a475e718f34632fbb334aea1dd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0060be1-1584025901785.tgz","fileCount":30,"integrity":"sha512-XKUFmg3TELlwPFnEWe3sonEIiInKd9S/RVkHygySmWJ77fBtqQjYG0vsyMXnto2QqIx+vI77JA5bV3zilKyeFw==","signatures":[{"sig":"MEUCIQDnlMNUZoUo8zv/Yui7vOQpX0X6ZSskz4Js2IvbYx/SYgIgZyh33dDRvRurK+FZ7AE8LZdkQO1XtRAn0pPLdRc2Zrc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36554,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJealF5CRA9TVsSAnZWagAAmQIP/3+xjisrHBu96GO7VIbH\nGbiRuQg7Lx2t3R3sDLj7yo6z3piMfEb4GPYxQUHz2W4US8oM9s5Ws6tU6FeZ\nfkKoEp3z0ggiZeu360vCmt9y9XiOk4+GwCUX7bVW3/Tyjk4q0zngBRetMekU\ngzMlzLcJF6yaIYptH3x0ODRAEZNco6IWoNnTRqPuc52e9dBpEBLPKaKdP8HW\niiQfYcsj0oMYxPmiv1z31GCS1Cvar6yun7eTsh9evpGhShPwYq3wnnQnQ0AA\naYKuNikX0BPc41HlIoSYwSvKKeboag40e+8M/WZE9hV4OMD2AbbLqPNnVjuH\ndq51s1tiNF04IlWVu1P7EZE9dP58yd+3ZeAN8i9xqf8Wm4Ezjg4kV+j/T2zH\nGhOK57gIl+Sr0gIIJJgOhIUFdGneQBAjMZ4+5oLvTgszcLW/gGwQEGNTFdvp\n14yOThDM6MY3aQrnCYyNVQt1IxY+T87TDaVhF9oe04j7XFyTRS2IYVIUdBP2\nsEsehQnqt/OWB2PaCPnik6yRy8yY2tAki1QLThwB8zUiLe4UFhx31HmWAGu3\n4g3FjyvJb1+axOuXrNNeUXs1DNba63z+I2Ls6L4oCMw3YHAiop3N6t+0EXwR\nqDBrYvC/fl91yzBQ7V7q+IdiJXwdZbZ8oCU4GHuqeAekUtRV6fMmCLlEnaqm\nAiUl\r\n=hwmq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"26a729210822b91dcedb0d04f6854d42b08ce13f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0060be1-1584025901785_1584025977050_0.6847898646818678","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6dba21c-1584136226784":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6dba21c-1584136226784","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6dba21c-1584136226784","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"261573cace51240a590ee59278803cabe537ac67","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6dba21c-1584136226784.tgz","fileCount":30,"integrity":"sha512-GI9TMqT/IwlL1xxXzLZLotTkhrs4uo52eJxYkty1gpzGqct9h62K3mIKyU0PIE1gkMcSB7MjezoenEMlv5OBFw==","signatures":[{"sig":"MEYCIQDu83NPjmRB8J6cZbVrueodMTPvCHpH6QXfdrjyTy63WgIhANv7g3uEEghBGkegcdzceOqH6RSe1aPOFJ9S//AGSOiC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36554,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebAByCRA9TVsSAnZWagAApKgQAJY1yijRvZSxPTek75le\nVtAhFDv0UzX60uyKuJZ5knaYUoEm9zuMz0Ec3ZthLudgA6KZDSpUkz2j/Dim\nZvUS7kwDylcBrKM0GXoHOWp2SlRcs13jJxVSnRX7mugLef7ZTb3R6mWJQfm4\nWGSNXUIUuzGsCnRznltuqGtm1O6Fjq+UkTNNHh9+QkoHjKORQG1sGL5btbgO\nfzx6Tz5hwNH91N9k32lM0U24h3JvJMEYEgT3GzUPh6G3g3b4iGUCJ07Z0fbd\nds2VTl2GMhCzQKtKOXZ1ttSxMmlgohHLavcIFSg4u0dFnGNgUUJgQEcxQl/Z\n94MsGzCIChwD4JQUrCIVDzzIlfJN29UFjjAaZ3STP8Mv3BaTu9D4t98/G6zx\nY/HfkOiiYIfWQKdbPqj118Y3rBaDLPM18PTI5yFy3orUujBZZLB+YlOmVXMc\nn3RWdwSw0mZ/on7XXPhViXjhiWGnjGYJ+I6rzljTW0ulep5kB1dEwaWujuQd\n/pO0xtW+H37Wj8wv2W4HHfJhWBo4LyhEWMl2DZ12lbkoMqQf56IjKJ/ct8mY\nG2D2zO6lMcAdWgVvx1RIxyLCv4g8DCIhC0HoxRMTYp1/+g6LJ4+sDz4nPWQT\nmV/MO+oEagL08y9duxkznc8cKDs3CORtiVzhBXDc74Nsoqsce61CZRis05k1\nFItD\r\n=Yl17\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a945c1258b95d041c791c12db612dcb897f7f4a8","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.16.11","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6dba21c-1584136226784_1584136306396_0.55523642989405","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-ca809ce-1584314494871":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-ca809ce-1584314494871","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-ca809ce-1584314494871","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4d619b58fd7ba33e8fbe50ac66b158e529b70e84","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-ca809ce-1584314494871.tgz","fileCount":30,"integrity":"sha512-JOnjiBGr6suWe0lRYXIl7FTbqsagGX3n0CiVaIQiEActT4MElWiriLP7HOM8mRe1+27opk0F/zglC8YmVPgC3A==","signatures":[{"sig":"MEUCIDUtPB97vmHlCETgeRM+cDcwCjEwnMS2jgjbO01w2UZGAiEAubG7lPaDGfmoqgbi1teTJGt7XBTyvy3sqdbxxUwxSa0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebrjBCRA9TVsSAnZWagAArhYP/RihL9Eef5rFoO6QcdlU\nmYVoXMfhf2kLKblwUbocuH8YofDdO04ClP3zm+y7GtYBRCLWAOGPSRZaDyuY\n95ucSefgww6PicfSSyX88a9bAlmM/HhNSJoI+aK2WTMT7eOkuoh4/IQMbDEw\n5IWHew9Z3oAc397bg3MfFlz31Ww2M4VTk/Z3d02cTrsmiVkxAZ0iyNOIS8wJ\nwYrsGdhzU1707RBk9CxX0SPx0w3W2GCQymElCXY2/UltUr36cutgqaxjc4qB\nbAacV0gMBQjnJVhWQ7hOlGcRueOsY4Dpo5/zvxAN1owYVmfttZ4N/ys+l4g3\nx5L5L6iR8BJDgUcJCjDjlJJ9tjgGyqIYwaLDXMcB2tNQO6/ZP8x+kKpnaBUj\n5eg0UqTjP0CLITF+V2QtZo+Va8m192kFi0225s4ahEiX63heUrOuCw3G1ShE\nCV6nT75Ukk7OBOqY3sejG7URfPj+i1qm+6I5rtDGwpOhAQSdS1o2tizSpS47\nCJodKYPJFArPdvXIl2gvgXrTudLptZmxFAVMlqmMqF5jcsMpFqNMhzw4ro2o\nH4TFaoyE9Ma7nxLTv++H9T/T6xKQ56qC9qW6wMGGIt97EgRFCgQLdmX6w9Ze\nzOJHH0Z06zTohVbfzVWZBwqHMFkY6Mms2z01aw5PawHLUZLnJ2XDd6/ryOpe\nAFXc\r\n=e7ss\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f533d8f6c6bf7a3cd61950d060a6a304408ae47d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.0","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-ca809ce-1584314494871_1584314561304_0.12987583344259446","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0c309ac-1584504485325":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0c309ac-1584504485325","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0c309ac-1584504485325","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f3d3273bd28df5ffa443d72880d23a6f69da6330","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0c309ac-1584504485325.tgz","fileCount":30,"integrity":"sha512-SdlIv9DDq2bSJar+5tJ4DcAvGTaP5DZA8dbXpKOV4qGDBn1JhoTm1w9zAGUPaczgiHqfbvM38VnZ0JNkH19Oow==","signatures":[{"sig":"MEQCICT98ux/c3Gozj/ahu8XttAugweHmSkuOI9uEebbVRNlAiBML8sYH2jXMfsYOEPmX8UfYkXTpBvBEyRTPSDWZw4kYQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecZ77CRA9TVsSAnZWagAAN10P/2qsqGdq/0xbp3u6NoMN\n1pc7nlIkxN0Dkc6I02NQQUSyoTEnRK3N95d5q1F39pRWixYqgx67Sf+ixeiM\nFptBIDnKFoS7+00saUyS43gX31rDAFa4ayx2Dp3lZK8VRL5GA6s/q5TQIfwa\nYRkTIcw/If4DH9/rtHPlqszpPqPtSzH+wAO+OyUWs9/wVRe+6FfRMKwkLJuP\nsWknfg+DKxm81rZzj7JBQd9BI+bhEIAlqnJHNK0ubStAyaEXzODHrp1qODFV\nFt3Vwm3r6Rdc0EWfAcTZDrf+4IL9fU57YiArtz3FvGkjoLj4/VtZH6f0vHjC\nUXeXLnWmPJi3CeRq/yhvFLqLeaRuWeeGTY5C8myTaKuwwdNZzk4QPB2Bcoxd\ndx3iUudDXOrUMiUs35Ebi3Vh5nS/CQ8JYDpBGDNiTUvlo6r+WBxI+MXrLrsT\njEX7tkTjZrLg4gvYPOgnxhrpF9p6vr1R6pCi2K69r6d8ACf/qqILGfHpLipu\n6T5Sav0jc4EPDHgTigdFa1suQzw+YrdqAWcMLZfZsfjKtiCAd+8VOOjVnpQf\neZrahH1tFoRt6wb2pxbLPP5UnoW4KwSsGgtveUcRi3LqwWXYlnCl6gyxvJSY\nmICC88+qWeeZK9TS0wjSt8t4KD6hzvekW0JbhHbjlwg/xq3ROBk/6Ets43+5\nAaxb\r\n=8j+P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"686a52249297839af64cfa8052e224b68eabe356","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.1","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.8.7","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0c309ac-1584504485325_1584504570508_0.8841643907869041","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a1852b2-1584719264748":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a1852b2-1584719264748","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a1852b2-1584719264748","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"595fba0900080485ce1fe2b70b88d1ceb504858a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a1852b2-1584719264748.tgz","fileCount":30,"integrity":"sha512-bYe7DPtdx/1Zvqr+4cuZreo4CkVhrSXDieScvkDGtC761TJx55RG1a00u/0q3GzD2viDpZpQtIV1tOk5uJ97yA==","signatures":[{"sig":"MEUCIQD1Er0AjZCU6zCiFPNTBwxbyGjjIeBHXxgVhjjFKTgC6wIgdi1oz6FTdXSACJWYPqfFLLN9hWKdJ6BbhzDqy8cIl/0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedOXxCRA9TVsSAnZWagAAXGUP/Rkdc1XItpvG8suP7sM+\neJXPLHFThUdy2p113NGCEIfzRxQRxaM8JAJ5Qpvn2zGurKIdPJJ9uw9j2ORg\nmd/INIJC2aJ5xnEl/rGFF+cc+3HOkqXs44xDdjl1ARh08B+ZaOLhlPj1rESM\nKoFLGbHzHl93eeESep6sXiqqH8VR0JwHgStIsvZmMEVx33kiUInTi1ZznBxr\ns/TMjAHUYvToQ/qCC2X8Sv+DSmQ7fbou696I/vG5Et1REnPCRgcETO3S3T6I\nurvWunQHhlOdyCVAgA/8sJm2L0KrxCpfXyUA2Ztdh4F3mWLFu5J1I+/WgR0r\nMJ/jOh2i0H8b7PN2yNk2vgGvR6r0T4M4x5O5i0nTjI5dPVOrn8+bF5cOr6wd\npk8GYdh7ITsbSOsPglAenaMY6YPHkiCtxQ21oKoMAB888Q31KfmucbfmjOff\nnsTG7q0v5ebwC4nCFF7DMQ8Z8Pah4eLh4jj1TBULxZ7doHC4YT2uS6Dbo596\nkBi31RHYnVMVSmVI4YocpvWmaONZyEBDkgxE6DxV3CBQnh7t88DGY1uh+geR\nBfRTX7WVssDS3NXXAUu4tD0+0JIEMkal9Ywqt1+XyNgpenJ8c+YZoGPFL9Hn\nAyoNImDSjxPUzJ4ke4Lhkud3PpOtFwFxnnto7or+7Kch8RKldluqHDcGAJDH\n1uWP\r\n=7rtg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0df9735ed84706182bf2de50bebbfdfb0bb77d40","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.1","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.8.7","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a1852b2-1584719264748_1584719344986_0.0867295593854236","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-22417d2-1584719675321":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-22417d2-1584719675321","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-22417d2-1584719675321","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1b52d54e80a4788b78c4b1275255f46e0181bf34","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-22417d2-1584719675321.tgz","fileCount":30,"integrity":"sha512-FGCt332+m6Z4tpAdneFQsg5sYRhdOycIsuBdMkpG6iBFEBZVmrU3+SEDMSXXUs82vBo+ZF/PMFnBw6WY1HNXBg==","signatures":[{"sig":"MEQCIE9dDRMTbkIxnvZH52Qv4Jb1Rl1NJpA48x7VTlix6QYUAiAMUyjCHXQDP9oYagne6bNGuAwQ5Y/tZQC4f972xybRpg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedOeDCRA9TVsSAnZWagAAaRsQAJsFTWmnzbY7xg1qyvBe\nFqfiBFOIBu817rnOnOIKCxatewdc1DhNQFiI9eba7qbraxUctKFVYRqJMhOh\n4YRYI/6tmg9vFqi4UI1n0S6UKG36smwjWVXB2oTonyF52tELLh4j91QhG8eB\nYI3A9b8d7EZE9W0as7KskqiHFbnNlFb6xE2Q5bbcGgIzGvkQ2RDhszFr5Upy\nBtXfd/lOZNdbhtimFKWakn4EuAvmAvj+rX5p6rjdOEe+94Yk09G9mizldF/l\nVZVKl7ITFTvVpbtXoYzvxZCG1k4M4lJzsLWFNStvMo6cGvMF2DGmuCurIsvq\na8aEcw1YTzsR7ZBACb6ivkG3bMkIMULSt2Cx7CPr3Bw90huluiR/uhev4VMw\nWxq+VoX0dgrCSqteAgMo9VCXudH5WcED9revGTEN10rUcTO2m3R/4WKK2iIr\ndIrIg4lL2D6mBuacjjDRIWY1/e8eKuTEE+DoPcYoac4zJmhnnwAUT3QY/2Ig\nMaynn0eZDJviHK2UCYqEBKeky3X9l6NtDaKjI0jcSMSfGStvXCIOCcrh2i0L\nGG5YLxyRgTXm51oFUI2JYzN9B9Cep6su3sBgRDGzuC/g/2b029IlG0XAPc/3\nxwWyZhRldMQwjFauM3ZM02oH1KcWQ4IcZBdWo4sMGxSMUBmevysH3EQw5M3L\nk9S8\r\n=/qZS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"449cd494c09310b579bad3b703ea241cea56d211","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.1","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-22417d2-1584719675321_1584719747008_0.33525203768952894","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3ed2737-1584831863290":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3ed2737-1584831863290","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3ed2737-1584831863290","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b17052f504559fbadf00ace8a4d26a12ce982df0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3ed2737-1584831863290.tgz","fileCount":30,"integrity":"sha512-yBjnNNdU9ezJzz0hyrmjBZB9a+h5UlRCNZEuEPInaatCY2WrFMYlo58d/5RC+tKWewsXtx/ZCZ8mECYOoJHh3g==","signatures":[{"sig":"MEQCIEB6V/IscwPjSKtp2cHCNDLnLoZasET5tZYo1g3vbLieAiBlGNjhPtB+TPV7/qALKB93rL5FU5LC47PjUmhorKvidQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedp3CCRA9TVsSAnZWagAAaeMP/24yoxFywbd8BCefdgUj\nnj1c2QpiEvOQvuOOrE2dP2FH68pz+wCSIy8MTeAnkqxw5UwIi8wFfW+XwMSn\nkOLblkRVWE6fPr1o1mQzxCuFbO+l3R+uQ5xO2isLOMJaBX9ItocEpAd0Qjmb\nOrXok3ZxhXWsUrqRi6Ufh0Fz/c+a0pG3aC/jFEle0Df9O75BO3FtsEKNlhEF\n8UEMhWRJ2g0IAsItikmH6uhxwLbVhZhWgAE6vaBk7sGljDxsNiRmqEBe7VIj\n7mhqEnHfHQ466hauSnllqOiW99loI4Xq7ABeqt6ZIGEmQSlAjzUr+KKYUovq\nvrjEOBCeVANvPM1kFAGG02rIpfNg/FGk6Xw0sl6TsRtIHFBPzG6KG0IjTWaF\nj5JiDLHqG2pisCKeT1kvDD3xVj+V12FHPB54UWbHTQn9tXpDzWEslIOMefV/\n1LkWK8JcYL/IUp5x0i2MPNPnGYIja+MkKvZ0WI8EV+7Xu1X29PGubQHEv/XI\nuORn8Ybmhn9158t/w+o1j0Ko4q2U1NrOQaWZVs/uzZWNucBVdJtJVU9fa6T7\nIUjLroi1kMmidEp4fu037YQCjQzvTU6sMlUBlO+k7CVz5wHg+7LmQj8bt5mG\nJYgrvDN1KnerfwnobJ5IIfH6Unu6OHcuO6QDKdLES4KY0OVEkNo1DWjoivU7\nE+Hz\r\n=MZTJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"872cad5f20f568b7acf87ec3e413f0a53b171c64","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.2","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3ed2737-1584831863290_1584831938002_0.34128885157770306","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-2bc282b-1584852475515":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-2bc282b-1584852475515","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-2bc282b-1584852475515","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"825504248ffe8a2e3ade77c00c4ceb1f2f47ff4d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-2bc282b-1584852475515.tgz","fileCount":30,"integrity":"sha512-+NE+5GOPAWp97a1bON/n+5TIdtceysCb1uF9N+6xVuQceRuwu3QFQ7Q876XOAgCXjKU8N8QZy36lfv22L+fj0Q==","signatures":[{"sig":"MEUCIHFo1RSzir5jkLxNbYYVMSbLNop52OQqDV7PngHr2mi+AiEA0kYjb71sNQHBiMGnrctDTJ1vKmFjnZmS72mE+JKCM/w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedu49CRA9TVsSAnZWagAAKtIP/Rq0UxiPsNCXlSc4i27L\nQcI0Nn5onpieYAX/uBt5Sd04esFmXxS6qs0JHoUHs9hwt0CzjowpXnC21iPz\nr+Oo3nOmvAlZVTxoiZTRt1R9+S1kq5XPsUSU1mceexI6SOhXb/+2Wnu3+G8R\nnQBa6RExL4GWdT41iV0+9+OO2r7Sq2WW53Jg/CJCpsYy2I26WuYOrhIcTZdx\nkmOn1ORJjRiSMfltzYHeoByw19DYpB4EsFPxDWvkFxfZ5NRLePw05461zJoI\ntv4GppjLLb7trroC2WH51gnDcuQbvKS4rATGNa7tz2+RR5dU0Iumf3A5mYis\nEf3PqymHeJj9dzRzpdGyt2aI9BjqlKXGguySWpZSsR+tKaCSyjU6c7/LMRYl\nsmXOs1lp50r3Gaw6KKQyowsJVb36qNx/p95P3Q/Y0rN10y9M+7tO0GMFjERM\nMQZ6AiX8KakBzVTzku1W4G7tV2/MFXgrrW1lWAc8uznRSz5/n+Ld9j3kZgfc\nM8xIK5p6kbtZSPz2R1s7sHg26YdpON6/xNdBK7Zka/6seB9ZLIZR3FuPnhFi\nzyv59RDSmtHG3aJjD6sK//c4yH/AaXWtAwFEYGqHjMiHDMpremTN+rmXMwZV\nZ83iiabaOdbE+qtDW5LOMNUHFiveATSwikPSgraUY8fzPOjFd6KzIjZhxqcw\nGJmu\r\n=UTJc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0dad73ada914c3db84def7c8dc229995521c7a56","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-2bc282b-1584852475515_1584852540526_0.5099803736753081","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-de55995-1584876889520":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-de55995-1584876889520","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-de55995-1584876889520","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"46393aa58403bcf6a0963876cc52ecaaf6b50709","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-de55995-1584876889520.tgz","fileCount":30,"integrity":"sha512-h1thdQOogTKTpM9HasA17W6MgagfuVP06ecrgfmGzdrPBl0sjvNK+1U/yBW603vxfHBWeawda+p4ZiQMuSWfRQ==","signatures":[{"sig":"MEYCIQDFfUF2lW7+FdGLywawbMj8b0RrEK8r013yEbILHtWDsAIhAOi1wJc4evMNMYQzUsIQDQZv4p/PjeYILVuqFL87LkGB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJed02lCRA9TVsSAnZWagAAZ7MP+wbtqi3cDArHRl22DQYL\nifjyJ7en5kqap0eiWbjBj+KEfZgctl6zs1I9oZFZvJhyT/XbagH6g3jycMUL\nO2JKMmn4TcmJNxnexzxsbfSdaPiaZrGnF5XUUAcMzjBDYkPyYPWQe9pkP7tK\nk3H8KwI3L9UX7ptzAZeN71o1l3ssoFv+ve1B6uEssl1+NWCUhHrWz2kGo81k\n145IDcrwR870i7p+snP+KecaIsU0GgFGKg/WQ2LKlBjewWyBHsYwutvK4FJ0\nmzo+GGpBjGD/Bu3KKblMVNO9/IsSmsjZp4P7CdG/Zf2dfP87hUZPo6U4RrJu\nInwpG0Ch6xDfuhkZdQi7hVgQZTZGz7Dvgxf2eaSCpGDmp5QvgrrH7NvGnErL\n0dIJ1XiZe2zVGUL71Xfu+FDQoDu2kt+icmkewxS/SxAmQurJ1sO2/NBD7CMF\nQSbsCOFjcixL2IfAH6I7YzLH2i3r4TncD8mdUmPKGR929614DmAVI2fVVdRu\nXIcetwth/Hn4J/SF6fIMc7ACxcdSHgXKFuDQNeGfdIeNqFxpglN/TcIT0VT3\nniG+sLA5eZFhzz16/TeSfaxHmyFU7EpWNNG41Kb0VFf1dLifkVq7KvQsg7+C\n15A5/sHbXzG85s88QVHJnxW8EMC5J/srfZTjjcQ/tcz5YIkwPE8v++pIrAWi\nFpwc\r\n=75H8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a736a6520361fce05f1ccbb0839968d16baaaf15","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.1.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-de55995-1584876889520_1584876965151_0.4407781004270497","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-fb10cf2-1585159376250":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-fb10cf2-1585159376250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-fb10cf2-1585159376250","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f57a6b7be35547d4a7c38b66461294e76a274991","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-fb10cf2-1585159376250.tgz","fileCount":30,"integrity":"sha512-/qUOE3CtL00QV5wAGNc8/QBsdi9svtWeff+16mEfgpdR4lNATcyWBqyRFB3sByfUlq7/rC52X4HNvRAlBdB/Iw==","signatures":[{"sig":"MEYCIQCCK712YzucqZmS+TWNvSeI3lzkqjA82PrATmX0GUlecgIhAPTDDU1aBwJyIv6+1vUANBe22WOVLU+xsineFMNPGMzc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJee50bCRA9TVsSAnZWagAAXisP/3rAfhlgjQ/KBRsis9xg\n0QefbJGU/JaDtUEG8AUoBfLw23KZ8QN+VJ8nMcGiNK4E89e50odyn01TWjUZ\nkcDOE/z4nO6GDxk5+6FRwcKWRLWY2X7ytCyA18TRVah3tNGEuc/tgbiRtzvu\nU9rqy77W2W14H5vQWQef3R6/cSDrcLyJnEKbIB5kI0g2e1A5cdSfWsXlTjp0\nnGQz7se+2kmrn0TZtKNgh4utip2BYlN8Qm/h58hESa/ijre6FbBA91PPQKNf\nRhj9C7TKXxNQnb4B6j8+EvUp8zp2xn85//b9DsrFdLuP1pOOzY1nKQEsFWDM\nrGGqF+3XeTbc8M7gAZn5c9S4dMOXYFtW/I7Q0z2CoDWsCdQiCW4WZptBD6q8\nkyceDItYNB2Jy+40d0/EHVetzAI8RKHdp2dKsscTnrae9SonARGfKURTEERt\ncot6SinBMvzShZFkNVORrfZFUvPDelioNxjSD+zOISF1cn4fq3o5ylhVDFU/\na4KqdiC6vg6OUm6SoTHT6naT6Q7d4rROD4Hn3S2T/3lmMg0l5Vj7J+zKixfb\n0imglsJTsbltBHlS+h6wKGt4dXwm6JWx/RrSpcU9CJUyT654ywRuU1XOtD76\nckItIiTgib6qIvYdbpSr3Su/OVk9Dg/udJEy9bi+BE6x0Lm36O9hp3m2bmck\nJloG\r\n=T9wQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"75fa47ac32e85392152d266657db1708faff3fbb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-fb10cf2-1585159376250_1585159451515_0.25420203938659336","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-20acc27-1585160151291":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-20acc27-1585160151291","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-20acc27-1585160151291","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"391771c1362cd9b8ecd64613cb5321416566b1d6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-20acc27-1585160151291.tgz","fileCount":30,"integrity":"sha512-xU8Y1bfbVhpkikkX+0k+wugc8k8G6oRFEjTOms4Fz6LrkVdmcfAfOD9ebQT56Zm2JHVpbaF2tVb5bpLa5fvUWQ==","signatures":[{"sig":"MEUCIQCwHnzK68BtgMxc7JjC7nzKdKfaSlDXEnGbLDtkunc6JQIgVSZ/tbPrE9AGhe7Qc00nH9SlmoCAQk6sN+99s6D1/8w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJee6ArCRA9TVsSAnZWagAAY1IP/REMVeFqEqPffBI2xaxX\nhFLYI9AGVVm07A04K2IuGSsFVq+6EgrrEkkzpH7nJcpakYItfLdqAKgkF6Fv\nV+znh3e2yKntF6kcB2GtwsQybZHwFGPH/d+RZyoKfasMQBZ30NfmTIeRYlI9\nb3UO+HiWyDIWjezsUy5bGg/aQU4Hny+D4WQauwj5yM4kUVceg0J6XotgF1Dt\nL288Rs9HutLhbCecY+QLbz1dEH18cv7qQlbbk7N7E0havn5Z18IYrkzBIbMP\nmJOHu46Ei1apax4euxIF7jR+pdHT3bkgT909Vr8lugM92wp0EtVSO1ARxfkT\niDGEl9yYqCmzFiSXzTj6wu7g/L+Fo4mrhf6WQ7T4Wk2SRQk6PrGayACI/Q1B\n2ZXfy4mwt0+3YTvat83G5KbP7HGUDZRFBgTji1KkzLku8j3vQPR9N8XwiRD5\ne/JH8KI7B/6RjfqkvTyeZ0B0uE6m1CS2/Wzyfxl/GF54PV4eInz/zie+Lrxf\n1a83vuYYRV1EFH5MqGH+EsIUdGoAavBer/QqEAEDnWNvr9Ysqm/knRJRpQw2\noY/Oe5QH9HfnvbJYwzy91n3ujQybT1NhS9gimsFTH3tOh7vajzd0rTdlm9q7\n93dLhkiJ8YgxYO626yr9aCQlIfWN8kZL2QO9zCan8RMzEf+ZqKL5z/iGYuBw\nmM6M\r\n=R2Xc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"46bd90a7f83f1b271973e0282244c2ee998e1773","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-20acc27-1585160151291_1585160235327_0.9394202732637056","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-22049bd-1585215546778":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-22049bd-1585215546778","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-22049bd-1585215546778","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e3691f73c51c9fe58a92d7b1d7aad53c4385169a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-22049bd-1585215546778.tgz","fileCount":30,"integrity":"sha512-YdpUmV0WbagVNZPGxlj5ZXPN8ntMm3WbvQFyp7dzkCxipPYcmnKHjMTwEW5wCIPGgReq9oMS3L4yqIsaDpOBuA==","signatures":[{"sig":"MEUCIQCoietGMcINIrFAQ4Rg8R2vzuA57+ZKrbKx8oTdGEXksAIgfRUX9TUzK5XmhtlT3uEgnEl/O7bjM83csWHGLKHJM4Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefHiGCRA9TVsSAnZWagAA4LYP/1LWgQhBtg4snBhKgFBN\nAji19nSBfT9ofUwapmK21Ww+gl1ZVrn1HsobpqcSRiv0LImXmLL/Uhpkah/C\n8X1VfLUcJ51bHibfPFAtW6M2wPSfZGDlcqPltCaCzSXLY+SGiFFrX0PmOzxk\n2X/C7v0PUSgNLCjIXQgvD3PmdTQlJcMNQ8x+/pJ6+HsRb/ykRk9B3X+tLR8j\nEeizkRBqoq7Sp8WLvfClRMaGKe2HBLdq37jvKX60C77zYlvSbPzyQG6N/tbk\n7C9zNuAVeht/OVz+MTZ8Ri7Y/prnBRvOCkgLJeINsWRpRLNFQXEGRi/zulR2\nGjwJjGUU+NOF/+v8zL9nmrlXXkfmCg/eI8/r981nyJQDmhkzlmyc2WJfK80d\nlBsOEbZlItVX/H7YhjQeyi50Znk/PsoEphpaLjusaZoNGTq0lZbMpPQ1qzXs\njCpxlrKj1rXxPrwGgm2SQGE6HKz6wQltapZ8AKNPQTNchm6S+1NF+BpGHWHz\n88r1SlhN8pSfyvpG2wFZqnJ3GQTQrS0iam1QAK3g5j5MlOUanwhRT4fsiW9o\nIGdNdq9EvWPpk1NO0rRx2yxdx3XCt03uGMrp6MQrW1POnZcKYtCzjd8GVjtI\n3SyVT7ZZStkWL3SbppCXazpiSIW1EXXq+rWwm/Gs1NeOMcyRyX3upUFfhcqX\nwT+k\r\n=S0t3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"621a130862663c2f8f4f209d50618dd673db1a36","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.1","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-22049bd-1585215546778_1585215621424_0.6873342228102475","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-65eedf6-1585215559050":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-65eedf6-1585215559050","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-65eedf6-1585215559050","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1af5863a5214fe6b702d7a2b17ed4bd11546f9b6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-65eedf6-1585215559050.tgz","fileCount":30,"integrity":"sha512-UEJ8y5mZcJIXFA49r9OYd7CNFoQzw4qwIZ3zSCEX1F8Ku0ubA3C5ZePbIRWUJGPVeDh+PEawtJ75jNBQ98iuEA==","signatures":[{"sig":"MEUCIHCNewpoJ/KJUdGL5JQDOhnGGF/KD+/r0V3phsm3Sul5AiEA6pNvkLj8g8DCGt1aCaByGjx0poBp4Sghd6iAGFzc6v4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefHikCRA9TVsSAnZWagAAdW0P/123R4LOo31ekbTXaf67\n6pHNCFG9K9Z35bn2A7FKqjzxd8DpdFAMcU9ebmrZf6vJ/mCJKarLOFdJMrux\nQ6AerbpUpxG05ClBoT/xu1rg9U700CzCyTVoDELACCFGY8ilNfgxE/tbw12d\nCM9xuxcDgrEshR9TFCVT8bIIYT+dJA13jdouSSOnN+V23wjcsuyPQtybVabz\naj6fenS3o3kVeuv7m8dzHQJq4ErxZ2QF0RqMgWHXol847C3KkgUjdgu1fCSz\nVoTuuRC4LrPj13R+O99uEGRVJF1bbOTPmEfVFkBjCe5navVrUkYeM3PQCuFx\nRe6XVSRMGexMryFxm66BpoLG5RMnljVQyF2git3T63X7mMhJA0fE7ASDAeOo\nLeSX7xW59s1K6fWIu3GpsH7k4IcBpUcRKx/l/rxTDaCpJomFqunmB6apavbD\n2e2nNZsWTfns1jBYz7y1bxzbLnwmlay+Fkb+TZ6PWdSo/l2zrj515NqJAe3b\nydUio/kuxLGHUnLR3YDN0TPvMKGslq2FzArQ5tMVSm5uI+NlyHC93QxTZkZo\nqYMr2wuGSl27mdI6MHXAhtLTfoDtSpwJwcaxgofLLBpv7FSbhmoKlAIiZpHq\nYZOhkiZftLGSU42oGB54uzaaZ+XmyBo/8jEJ0MZQu6fnyIsHGvNW6mw5vCO4\n6Rd2\r\n=6reo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3b7a8a5f6fb2d6bc647cc08cb0207b2ca256bff2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.0","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-65eedf6-1585215559050_1585215652181_0.9062505684039524","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-06ca790-1585217152823":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-06ca790-1585217152823","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-06ca790-1585217152823","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2178ad3fce52826d25bcccac8e823b4c94f86d14","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-06ca790-1585217152823.tgz","fileCount":30,"integrity":"sha512-7Z6n2C4yvIH0zvGszb5O7Ljbl2KYdJCjbcsavh4LrOTFBxf4HevUrJrr7lx157+XJIzaRV+VjmogcP2k8VH+CA==","signatures":[{"sig":"MEQCIDhEfekxip7u9pCCfbSYXGN5cSj6D1PkZdH/XfW3PPy2AiBgFogHU0SGEDhtWmGT2v5XRuyXpnqTOf2tunJ7ZqFiMg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefH7WCRA9TVsSAnZWagAAY8sP/iW+ISL+tobmmfsWpDHj\nZBWpUf81fmmxVmpzN1uEHb5+fDOfBcXV+u++KHfmfBgdgdcAMo7+hGi/xIxw\n6np3ViPtnYjMC6fPYiUTPq/fGl0UtaBCCQVAnVfYCdqMxpsP1ENQU4sljlK2\nHB6MnvTwlcyVuEn9OwrZy0yA646JkEZGtpjqsklVbEwn8TNd/byGjABiP72U\nYBkqEtVd8wic3vqS3vKXzBbwSeypWrfFfctuchih7ronOS0WJxk7W6ApiB6O\n7TTKK0TCHXJJ0tyKm1bWxRQjNCCe1pwoPalZzJtQ9swoDsnClM2lr/9Hp5g3\nkBmRq350n24Y2n8MDkzdkn7HAxizUIDHTaptherX7HKH5XmSok3RFuTKTCoa\nifwprzhkOM33mfn8KSTl+whMgCjT9+Qg8Hwllz9CwU0YgXS07PUqukEjFJQd\nVAovyZrnT54NVr1/EaemgvPeQv2QIZn5QKOIjO/NKQtzI8fejA+IBp8ia+N/\nIj1JE6uCeAx7VufCv6UtZDiedcRFMOqo1TXzY1eOnvjB2Rih5vmydqfwbvpc\nrQnBhLo4W4WkA7yCH06cQ3nrgcFETQev1nQUqoeywuQSAX9VSAMhHzxLIbum\nsQ/9mA0ITZsy51zNmedIX1HfGOAkveht2ewHL6TDdLEa4pGDq7O2kLGrKUQ5\n4DT4\r\n=hJkB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"dcc0e0d3f7d52317941e932525392113ae7bef94","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.1","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-06ca790-1585217152823_1585217238090_0.562634275915006","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f57a314-1585240398562":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f57a314-1585240398562","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f57a314-1585240398562","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"95cb87a638d01a67037688e97a8e0c7917647cf9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f57a314-1585240398562.tgz","fileCount":30,"integrity":"sha512-ojBXsDbIXB7fnUY6vn50jy/SqS5ct0R/e5Cu77XzluwEn5IiftHW8jVpKeWQ3s7xdz7l3tBQ+Mf3jgb15gUClA==","signatures":[{"sig":"MEUCIAEqvUGYdxuiy7AFbT793ENMS9y+0WxVp+bFqAmFWbg1AiEAopQZKvOSfYvq8glTD1AMERk5SsmrqWhRcjwn6JUuCbc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefNmmCRA9TVsSAnZWagAAODIP/0PqcInzd4q8TZ+JeERJ\nkX85CvwAMHwlj0UNroOTwP1xkjwdDfYkhlCNgS8kW2D+r+snFNOUml3kAeZ2\nDhiOeL6MZMKbYU+maoITLt9M6DENFtfBayMC2P4bugTomu9QCBnGlHHaj6ij\nyTG2nGKwPXhoLL0GP1+QNQIQhVQCLmeCF77PWNGmhS1AN0kwRjrsHl+m98R7\nIh+vbBLm1Zy+ZCgtioH1qpQkVcLRTU2INONUPJctCaZTBeo0R/FKuI5b63ZB\nKJiAtQqycF6dfzOEzdsCEcabh03xgVjONJKXGCUcx6aaPnN7rKkId7cB7+cI\nC/ny75sFWIcaUuK9MQXrOmc+QlpUqDNhDZGoP+tb3Pqe0fG90bpnkRdzcYwF\ni0yjdK3KIJIY5iO7MC11BTbXlCONXpjA4YLCNPx59w8ocjrC4o0p5j/FP2Eb\nHdUPdHOY+awKyIhZ5Rtk2vKL5rxMGm52EQic4tB1DB8Wnw3V5Hv//RuJT+jN\nBDJbskUS+kYJ+jFPbiNkiIV+mpXXeQYYkhFk1FZAu7//pvnMgHZW9pn4QRjb\nGLZwGNZBXQe+L+olrJBXmCxJAgXDkYKV0tnfPWQkiwMa7euNEdK+J5s3M2ZF\ngAgmD8oUlYGU3lDwyCPF/QGt/AaSZLrOUfsryLnlPnv03ltteB9Xe8gyPH4Q\nd6N+\r\n=FN9R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"be448b8c973f876b783c27f8a9fd41d0f8237d6f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.1","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f57a314-1585240398562_1585240486316_0.42015896190433555","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7e51d27-1585255190518":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7e51d27-1585255190518","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7e51d27-1585255190518","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b453bc6ffb6e8d980294f504cff85f73c8a98445","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7e51d27-1585255190518.tgz","fileCount":30,"integrity":"sha512-BfBPTZIKrxiRBaIKs7OtPtOP18rglBT9IQT18c2gQSnY7dUf8dlYc/l45p47+CDgXQRRQo4zxnm/xj76NYF0iA==","signatures":[{"sig":"MEYCIQCfeZ3couK8MkpZ6sgRF+1rr+fFJIxUii7kFuQ3Lt7N0wIhALqTHbLXuEgI9EbdjUvTfCTFpPRff/8u4K6rkizt/85v","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefRNgCRA9TVsSAnZWagAAUV4QAIimxDeGRzQ9IqiNqSf9\nXncXGdVQFln3c3w6wANOOgA3Oh7OonO7EoAmOmQqOFIC/ewR/59fNfPsajCh\nXNGvwZsZBdRb8CEh1JKLmq6pAWTvpvARH4ahfRIpeJMZcrYnnq0hzF43olrO\nCI2pDCBm+fJapxzc3wEmJhJWGGql1zLQULEZ/962qI8GT8qZCihAJkUI/QP8\nK9F0vE7cPcsh0DJ3W5v3n3C8XspzTfC0Aik6Ay6ZqA+ILn4vIrWM/vyveXnY\necWPZTlOZVyoMdnLhKNT39s/iJhB6qDZXW/ac855I68wNxhfOsWj/hG4raog\nH7yIRxjSRznRdBQFZlIxsnmTaL1UdF0nQUy1qAwrV67GSkh64WsRKGzRrGLk\nQzrCU+i36sgzQBiG8hZo1OWSVU3USZMTVv2S5l8n4ICFGESwzJurQE6ILzek\nP50oJ6LHGyG5acW2g2PJEDx/kxjcOLi4LImvnRGkuYAUPO2g+s9Z+VXZVJhx\nbRbDSmv1l6qwTEEsIraucC+BqbLyre7S4ygkRYT9kzYmqk9jC12H9oObSyf2\nYObUiZ0ZidVq6zQsqlTpTIEOy1gBZE+bxQHhzt+nvXk4SmAAuhI2jGkE24JJ\n+1GzsQiERB56207XsBv0twQEdy5DF+zDsmFYxrb2529rGoJPc/ZZCjpQocvI\nIgk9\r\n=Tpew\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a9d36343ecda8c03f592bfcb32425bfc6865ce9f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.3","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7e51d27-1585255190518_1585255264440_0.7523659778190748","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b50da59-1585255214091":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b50da59-1585255214091","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b50da59-1585255214091","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7e391986292c965ee27ba85470e0ce8d68bfd217","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b50da59-1585255214091.tgz","fileCount":30,"integrity":"sha512-kJH2aFMsTd3Y+KilyIx6hr/2Fid67Q4I92SYIHcN6YTl72UFkIQD64tNnhp5yp5hMAdHx+xHdnTfmIr3mRKP1A==","signatures":[{"sig":"MEUCIDJk8jpwdrjN7XjOTrA+qT4NBic4RoDo1Aw3iCofawZSAiEA8rQNt9Wna1xRCgO+TszzSR4FdkBqhB2jr0aaWbZUL44=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefROACRA9TVsSAnZWagAAw4cP+QC3t7X2/pfyG8owrkmb\n7+XIyiSmxTit54Ad3dRKVLFteSQx+oQUYIXICnSYL6REBi4d07vDuJulMQDo\nQelD8jOKg6IG37Ig4VpwakZ4aTj0W0P78Gwss3q/Rzp8cBJDGmzBsAfDxHKV\n+wAucU8rFwR3vwKoV1GNcypmp4ARsMuMDdloYEOW6bySBYn8Dytj7nKWHANe\nzTvR5/8Ve8ueRYQEer+K2JAhRB2nZV6XqsrKCSfO9dV6jtuLrazbWv4ae73J\n5PpraH/uwba/dOc36nvOe1G3Rioa3b/CaL+acSk76iV8auf+Uv9ciEY5AC7b\n926862SqDssw8uL1z8C+QshGg7v3MORjPzyxmi26upvQCJ0IlmvRqecVu4KL\nZ74sjKPdJU4lnKttARAdccXz/1xktUBeBaHC/pewpzjlv2i1S00EEXppjW+o\nyUZX3tF9DU/zfRqwtYhi+hwgJ83MqXKRwal8GHetL1E/xe83dBlunETZB7rq\nwAqIU1w7UgMt8SouafCkfsvw8gb2JFRbuhIDQHBTFgCtcbUDFYM6Pk9x+HiH\nEOknxNLrNQ/G9TsAiUPOSBJ5YRjXDaDFjRH3PrbqHT3EGkuCQ2NwklAvokny\np4rhmTmSUkrxE5GNA7cOlBgBy/NvPu+NZWOTH/zQiW84O3mrQxpKxtw/7JmF\nQD6x\r\n=edmD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9671eea41035ceedeb8cbf0d20b00bfcbc805f51","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.1","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b50da59-1585255214091_1585255296253_0.9918634722126114","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-2a1d00d-1585264443746":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-2a1d00d-1585264443746","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-2a1d00d-1585264443746","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a8dbb636972e0ffe17afca0c0a6f982618a01158","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-2a1d00d-1585264443746.tgz","fileCount":30,"integrity":"sha512-FvAfrqAVu1jcQBi7VnMh7vJ4Q4jAWcICzR9f1u4I+l16mVbYJxxYadCPihdL4nZE2fby1pKdfEu3G4we7dAptg==","signatures":[{"sig":"MEYCIQDDM26KILNZHDlF2OqFCWTylX4ctcTJV2SO33S1amiFUgIhAOrvj5ZkiuliEPjmD8EB/LbrTXIh3v/tRWB7eJe+SRnu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefTeMCRA9TVsSAnZWagAAE9EP/3D49XafiDr3qgbzujjC\neYraZcBcc1OK6QXHAn9grrOgnKBT+eSNA5e9Wl2uxeVVJwAzmrKVTC2K5TU5\nUvPLYC1F0OoEbpf6VX0e1YGYjMfC+FN+ZWzU5t+uiACz4PGzGtZZYrCaz3Ca\nspJTHEj/21CDlIh08d7rsGscL7wgVTNM1+VBSfQ+G2rGXh8SyAejCrbsxvgo\n6q5DUZ9GeYJJKo6dsuGUw47crCN23fgBFA8VvR5etSwVC1XfDVxV8hpot96O\n3NxHwJAJj2lFi+IDR/QESCy5uqH3Zrr0qzMcp0weBlVQ+15b9hZ5208TzXiz\nwHmi8rDz7pQwDLTo0XaCr4jYPGEKeQJ6uMr5o3mlmSXO8YXGoGShGvDYiIRM\n9x+r8Sg2PYKO6qFF1j52ogtgu5JWExRBSBoz6f/tKR3ACxHvyEHn5jKbhTbR\ngxiLUI7dEY3d8DnfdLUH0ilVae8C4q2tjCE+U67pIjzbrVUKOYcg7O1KDtsN\nVyK1Cebr//jFMWZrxm2sOrHN5V/+hde0Nok+4MGOWyCGVXzRY5czz0JeJOyG\ntd9B3yED8+HI0CVXOX/ZFRSUEezQXyByW/mrgXmH6hnxqnAFDHjEjmOdsk3k\nRhIPZA7MLWXtOklAwtGjzxmnzQ6JdW59FxU/4zMW6hVJUciJ0c4HvvxYSKVk\nZ5b5\r\n=0caz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8ded16db2f8b619ea6dd7857d9c50ef51122f602","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.3","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-2a1d00d-1585264443746_1585264524101_0.8408498974579981","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-cf4c2aa-1585296548801":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-cf4c2aa-1585296548801","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-cf4c2aa-1585296548801","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f3a9ba82ea872a7d1b394773b9d2c9033a2895c1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-cf4c2aa-1585296548801.tgz","fileCount":30,"integrity":"sha512-+3gIeM4f7tuYwwvX8IpOTHCthn/mKQ1bveOzN7L/W0i7BfOROXOa82TfFF0DnnORxLYj6LBt1b4AUWPZofbtZQ==","signatures":[{"sig":"MEYCIQCLp8BVEpXXmfphIl8uxw0oU2xdTJkE+TpJ6cr+9SBD9QIhALx+42HNxBor6LENiCqAPr5pJtC6zhaLlr12zKn4gQ6U","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefbTzCRA9TVsSAnZWagAASb0P/jO/jkOJl9E6Wnml51uj\n5RbshzHp4ncOVLHtAud8FKdN4q90+c27+ipm6qRSOlfi4O9QoR0pUMJmDP37\n9fBB0M8T/prLv+3rPrWK7i4QaGv1T+w9Hyh73fD14Pbyg0IBXA+AXMUKb7yT\nUEnouQOk3L8p966uPYBUfTj8pSV/nrdeGIkBUrjkQRiEup0n9xhHCdKKFtyK\nTpEyiv4MW4HQUm0ce5t0xYNF0ony78c9FZK/rS8jVzyTnRGfS6Yz138ownu3\n6X2cw+xqWJn9GbjtOaSTSljGDZbzGViyG+RGJqz2EY9HwR5d5TIQUDWyzsnw\nZ6vRT72GpgfsZklfmBIfgJXmsadkzF5jz5fcTHWf2/V1hrmJysKhN3BQEAup\nav3J1ltjGCMyvHs30oAf00EUaL+8QqJeew4Jh42V9A6R0TjS8LO0dRNSS9/O\nswd7oLH5do04Hzc2nN+tFlb1T0/36IgY9FsTZJMmr3Xrd5fmO5jSfRhcYOb7\nxLmI4oty4EYUF3HmhpyzDI2y7YmGsJfDo3puiV7HbS7CFECHfIjUQXIJEPFs\nSOVha9iQC3LcTfkhXQBOz5GdZYKmEUZ8Euh6s8ZKRnyHOuB8fXGRF9aqwJkn\nCgRo7ZnNzz6+SaV43jWBSM+pF+xrorJ21YqG/1AEaI7KGfH4I94VJa5IQARP\nNoPe\r\n=V/dC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f53c247d1ddc406c25ac9ea41c9ac6274346790c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.3","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-cf4c2aa-1585296548801_1585296626551_0.4107341120217791","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-13544ef-1585510991707":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-13544ef-1585510991707","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-13544ef-1585510991707","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"be4141a19450f8d0f8ae09aa12128d8b3d0bc36a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-13544ef-1585510991707.tgz","fileCount":30,"integrity":"sha512-OFu/Wzs8Zpffu9JDl74yeMbwUCboAMazon09QhizSDvhZug8XQdoxKExjEp5qg7tas0sj8pvjNiSPfLZmBQ27w==","signatures":[{"sig":"MEUCIQDtd/gm5qzVZSqtKfzhwkiVvw5GpcA23m6p17GjDDKFjwIgGclVsGGJQR4fC4pSKLPzLzLv1Tf/UFXDocT/KiVkDLI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegPqfCRA9TVsSAnZWagAApaUP/2hMsq/WOUEgR7sJEPFK\n2fbrUCogB11uHzYOYj2an7/5CRygQu4Ndjg2v7ukAtVD7iVo3QDyl9yOb4U2\nQXYjLcFiqM+fe3NMTrLeIEJfpr8dDtPlRSYlppZYFPW0i5tvFLGsduhso3Ez\newu7QZ3suQFUFGROHLNeZVTiRGTRuD/OapEZN3auyDcJ9+TU307NFZgWAd3O\n+7xaIKZ2gLkY8cpiFX4K5YVYZs11b1Fkh935zpu/XIYkpZDdLjLxoKK7/yk/\n+M/zkw723fvuzaqctNzLQpASLRTPAB/8nZF01azwTzx3ojMg8BKjCdztb/Ov\nt0w11/01VUn3hUN/EEhhcxijKvmz3OzJfYBmbnV3LcFvcN3tEr/XE3c23PUr\nC8JtyF21ikqVl4/PR4OYYwUZTEZ73t5aWfY5lEbnK1YP46hmBT3RgItP1iYd\nsNKEWbVK9lBA6XLvFsDaSA1C7bwNbO0fHOEIZx1vOSxnsvluQkSLdiIf8aXx\nk9+Y+Slsrtho1l/Hh0kZqIpTNVraoG5aB7IYAGu6ZAxe2asUdI7HMAtDmb3U\nfMa1MgITySk1k6cPi8Gu5POjma/bZJJPOef02yLVrlYzxhxPvGo45zRFGADj\nijlUmumvEnURZJMedzZOdx6hPoor52Vz4vFlZicA/XnA8RI0T+55uqZHJMeO\nsivD\r\n=TZbC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"08a40b96bba80eaf176f819d110b9a9c669b9aae","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.4","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-13544ef-1585510991707_1585511070474_0.41614166475366887","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f27a7fa-1585511312402":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f27a7fa-1585511312402","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f27a7fa-1585511312402","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bf56398801ccb2f62c3a4cdf118d063009ff9311","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f27a7fa-1585511312402.tgz","fileCount":30,"integrity":"sha512-8fI2bhvzSAdRUxtxFaWWwlkL7jqOzZjW+hDsLyaH4zQa1RuxQ38nzSqpL3BbF3Al4A0X9LGFs+zdduMJd2Dbjw==","signatures":[{"sig":"MEQCIF0jJftkgBp4jwz+NKqjTfn4eltu7hxSPISQgc3vKRjkAiBG/l+Fb8tc/6KsQILsjg3JdQIhpHrJYOZNPJgsexpcYA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegPvXCRA9TVsSAnZWagAA248QAJ4sQzUgYx27CHWOfdlz\nvev5tpMACxMFQT08XEkeMulRNyaGx+WUqEs226Ibgur2k4Xl5OcKjThff+dA\nuWgzjslC7t4WaE3+j07d9QxtONiXl94z4EJi2Wmz7dlUXC+uY5j6QFCoXRbV\nLzV5wZLxpJHwhXp+YQE9D3Nd6da3JKc/zScNiBy8ZkrnVL6rJ02Vytqidnvi\ni9+328ZakDCosaw5wo7/BYhfxBI4rhnlofEl8FYNnTbFOsBpaK14Wq3FeeiO\n+qG2lbEpZ7Lg8BnFU8NLStFoBFCpnudrfsbzkeI4mkDlF+5jvmXyOszfijsZ\nP3yARIqhUuxvMAyjFV0bh2u/y4PSBAR+S9ysWivmCVAsQOdGKI/fmROMydzD\nKCRna9TweLaZ8tUxtllAjOg9ER7mXAy7rTWA/FOfTtIRTQtfJUX9+ekwrFU5\nQJ2J9huidr8+vwTlVw82bBT+BX6VEEyP0UtytQBbO4lCBPEoxm0GnMoUUrX7\nB+u9bs7uwWeXVZ+Svs+11XjV1R9wfUGC/qXytDbGWHRyb8uJTNELBHevJeFW\nqqGjeFE16F9ajsqUrIQR6WMuHOzIBPFQ1Lduh2kRX5gjw9HaFnFyImBU24Fe\nCJvbVjuSodd6XNKSFxtmIOlAouLSb/a2uPwgQQq5/xvQ7Ol9vZuJCWh6Mej7\nkv0N\r\n=Q+sk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d4f3377c9cc2311f48004ded9c2e26f42371faca","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.2.1","typedoc":"^0.17.3","babel-jest":"^25.2.4","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f27a7fa-1585511312402_1585511382686_0.664729738912246","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-38a6c8a-1585560814723":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-38a6c8a-1585560814723","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-38a6c8a-1585560814723","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"81833a06235a238a81724b3ac35792f8f6b58359","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-38a6c8a-1585560814723.tgz","fileCount":30,"integrity":"sha512-mm36wv6Bzll5KN3tZWzQU5XVnNW3MxNjOHB9n1B0pVEYz2Rxd97G6o3tnuDF5E6se3f8u5ZJVLmsKs9gs2qsUw==","signatures":[{"sig":"MEQCIH1/0woWdIVa5pCstAWEV97k8ZhAU6ywG8zJaHi1cbsQAiBfQKpvvllcEY+la9OUtHvZFNk5xT1f1uT50xWHkeLpnw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegb08CRA9TVsSAnZWagAAB9cP/A6v8DSynfGI/7JotxQW\nvd87cd3w78MshX/MeCenlNQ+vq2MC6FieV2HJk0Rf1Co7hm6/rJiKNm57+X/\nfFGF9rDS5HrjOjfz6xGK04nyvJYtKxnTvg3ZjQcDp16/ungdWA10JmJav9YR\nfFODbUspqsM79GQ9wT+WSliTiJKzoiVtOlSSoJ+6Ar9LpVjNKBE+Z3rPVtN0\ntP4YOnIN8waeNBJefUFbSG5oVIhMbrqNVd58gf0dgH6WRVG+1jyDNh+QvGYV\nsFmBZsH9JlaJfmdFuwGqiaHYZ2M5rlgfISNj0GkNDx6ngJkHbr8RumFQ8z7f\nyjvcJIqEV4Hgp6P0kctb1gAew60/w1/OcRy1QyJTiFDvY39fuzbi/ETDJGX5\nE/VlbZSPcYR6OrZajfhsu0HwXn1+d14nzFJEl76CvYS2/Yzsc7sEy+ar/Z/N\ncjwI09SzJI3x+5Oq4E2zqavMud/EODNmyB9cSvQ/FLF9wb9VqNpF5KDpzowt\n+DPi9/UT9q+5/ExtwdpSs4jsNPpfHp3rkkWKSpP0PPrFyxeG+IOsCk444WSI\nqboIR2XzNlLStGBptWo92bmxDVDU7Dgs1pTh3hyRZ0qkdmypwun+XuSJsapN\noAdYk94/5LzdgyZT3AkjZy/teAgcO18QLM19wbNTKGy5ZUzku8COKTtnFwjE\n2ybL\r\n=ckV2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e972b4b339664dc2bec046bb652a3d357861684b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.4","remark-cli":"^7.0.1","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-38a6c8a-1585560814723_1585560891949_0.930323013159766","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-d07ec44-1585565607459":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-d07ec44-1585565607459","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-d07ec44-1585565607459","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"aece29a5dc132ccfc62f3a109ca7029c4dfb77bf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-d07ec44-1585565607459.tgz","fileCount":30,"integrity":"sha512-GiKFSgkhMSJRYCbI95eQSt9QMTMQfiLh7cwcjELgmpZV7LT0XCp9ahsSTBaV8wgLz9ObyTmmvWGeHXONJPDNYA==","signatures":[{"sig":"MEUCIAe3zI3HNb3iLP17v64TNIAD0ksodaFpH1HoBvOImQhiAiEAtyojC2g6G5QIBQDVvTH+plCbI/MHcsEpSYbQUiRdNlU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegc/3CRA9TVsSAnZWagAA52sP/j8BOxNH+EYeyU7WqcXr\nbzFQE7PNqVX3mczHDe/wLK+ARSPH+oiCLmk283zCJBrRhifADIutTzUDQTcv\nupZROu/NGmA59fjDmjFsekFFMc9xYgrU2OrQxXOHfMrcILYpXA33tdZeZZYS\nJjOGVpVao24mnVw7CQFKdJmi9yIpPL6N+/C2r6sesvY5Wi+r+Yf4XPSWheJn\ntowSyxmHzGjjvKnDMsPcThlIhAvaz5HOY2s79HFBVnPRv1lNm2dH14VmCVAK\nLWqSILoW5dVEJILaR3Ldn3irx8LpP4nypP1M5HVuEoesW65fMsLMgLnMUdpV\niRf3LPRKeumes9QZYU3mdNsiLqXFStdei21FmR9JtEofdJwMZNxxW1E1aSNl\n/Of7UYdTSZdSzKJWesMyKYyhZL7JlOIWExodMaJrMNwd65/BzGS/cEnVmnSN\n7CNbel9zA0bx7lFt9wn8QRT5SAtfsP7vy9A1JOiPWN7CrNOyQbxmodLbr00D\nsc2VpUKBoQoTQEeSLiNoKywhXdslj3UqF/W0Jq81bvmQAr3hdXtnm07+yhPV\ng+sN3wUbEPaX8dvs9cv8ujzY3cgmzOILE7vnc/qELbideaPQ5aWPD4Bp//sY\nuI2ptL/roggENdTPD1B5eE4wSzlg5aIjXDE/tpy+SCG0hNellZUM777inuwn\nY3sZ\r\n=EBp7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"310f0538dc4190569c7da9cef74f3b821d606d8e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.4","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-d07ec44-1585565607459_1585565686580_0.41632423277141917","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-abd454d-1585824420627":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-abd454d-1585824420627","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-abd454d-1585824420627","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c4112b93b74de7ad51e738b0dec2e016d261d8e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-abd454d-1585824420627.tgz","fileCount":30,"integrity":"sha512-r7qGNdrVZbRKVSTut4Fnf6h06rjbyDVqNdTh6AngSJjlrJbTZD+Dsl3oS7Huhp5c3s/Wmb5kXE49w9bgRWJGuw==","signatures":[{"sig":"MEUCICLMKG2oUoc++a6Yff+sGR/y+8rwp2J6XH/K5YdzEaP4AiEAt8tR2XUlWbCtnSo0f26m2Ogk7sWHhrcXsO1La4vWoNw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehcL2CRA9TVsSAnZWagAAmMEP/R8Qt1COowppXfYYNg73\n4Q/YT09l6uLpkxaMxBaYrCEwtzn+Au8nLxqU5XsDIENyPcFfKhxvKtAXf3ag\nK1UPKZOtPSbXsZxG9We1I/+JyuExf1bA5iCYT8W2TRjQ4OBzjkSowv9ZKMHr\nYzN1J+m1D8EKG+lTu/rMxVZUmRI4LGcMLhhMer/IrtuUojuPBxn5AaMYs8bs\n150gOmxHvWhrFrXiRPAsLm12TVEM4gYvcpi6nHEPcGDhRfuKcRsifkZ62+G7\nUwpeam5/oMi815iO3Lojxu9Fi87RqDMij1hYNt+NGLuNaYeCg5tmrrHb6Urk\npempa4B/n9e0eb2s+QaeydH6O+FZE2jyNE0yWcadJ53vTrc+T0rliWcufafy\n9qu759IKtam3FkPq6l8iUVLJhn+sSJ0Vx7hqcf7KgCZNIQQ5V5X4fw4jSjiW\nHLL20LDJ8W0zwvcIVGYaJGazhMNHJihYMIoho8xgnM4tCDHoXf3kvLVQRY/z\noxGbCR0ipRQAO+dXnY3MyIkaRJe/ISV2L5+vTAkpFTHgLoWE3+koxUlZdlqg\nE2bvq/YXFCCijrQdkuXgx4cmhsJDl6IynSyGrfXziNKt8hX4x0c39XjwPK8i\n0XlQOsXzkIOHJwVfA8ha8xD/OYp1DOmXI/yAqm5E4FqZ3DEbZm8VXXYNcQ7V\n5IBx\r\n=HApA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b97133468d1064c0a7103b5f18df3d231bd71dea","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-abd454d-1585824420627_1585824501925_0.9149846481281425","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-20548f7-1585824456055":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-20548f7-1585824456055","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-20548f7-1585824456055","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c21768a6375363d41c321d668f41178bebf24ebb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-20548f7-1585824456055.tgz","fileCount":30,"integrity":"sha512-1QqpfA9GHYNMa3evSI1IuL4AmvQjcs9+NVViIOSfBYqqJaf2PdJS4auDLPiZE+t//66n5sT6n7KL28Ig8Zfm5A==","signatures":[{"sig":"MEUCIQCJEV7p5ORSV1gVYjirSo3Oxbq+Vuzd1FUsQ288+VbjnwIgbvMlrnyALT5nv6jRQV8hJ8dKvDiS/IcL0f+sDAcbJp0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehcMRCRA9TVsSAnZWagAAzLUP/0tE8xwx7Tg2sxPNJttw\naui9bZBRSReOe2qD2wA/XIOZmGb1Zin4ZPOuUWUYUeyu3j7J/UvRkOZmlCTg\nZyJ98La7PSA7YhETc16JD0mAW/B9LTJrZHJ3UdCwbD8c7wEYtLEblCquqs5G\nCXxGlIw5E4bOwDG5ckfgGN7H72cVYppro8g7y8NqaLNoHW1LXMtFDBInE4Wr\nAkAbX9x1k3AMEEQ/kvYZ5w+oqIWBR5FefxwRTy60IvWLVkrs/G2X4nxqYcWK\nRFOhCHTYJdOpr5hmIzHzbs70kiJqHLt+aYTGqxeGlJ3dkp97iFMYDV3Yux9W\nC2x0LzSMTHJXvtPuhQiCeUogA6SA0oRWJXRYh/GJntmNaXtPqilh5+0+oKy8\n09rv62FUqkxGJkDooUMpEfDeZZnhNJ7pWl50SXJ31e/0Ola3IYQ+o4p8czrv\nu0Sh3EVb5W9NfdOa5fJj8K4DT3ghdaoUV1fkPMGuAbSYEZXr9Bj6NoBcNf5m\nzAUSARzhnxea9vLbvUmUZIE6Fk1BVCbqWZGz09JK6GN2kpjBBn7HfkI6LKy5\n4qAZXdfdOQhfH3mUNw2ANMbn0+6xe8hfUMdsvTEGsJRuGzPJgGI12PJvLhLM\naSFqXs5niKI/X4c0RogdKgRyw3SdO+oL1vnSNXOrIfpOb0pihGz1w3D8r7Y/\nlvHW\r\n=xMsL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"bb94f626860db288f02dce5930ed3201e55808e1","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.6","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.4","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-20548f7-1585824456055_1585824529053_0.16206102920369703","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-258da2a-1585828153485":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-258da2a-1585828153485","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-258da2a-1585828153485","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"41197e44df019583266da88727465aae45cf2ddc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-258da2a-1585828153485.tgz","fileCount":30,"integrity":"sha512-ggfe4QCam3bOgqeWy/P1+a4QCwDNlTdXqTtceMuIzoPSHJpzjDBQC7O8YGrPpG5L8A3rXiwBkkvy5xamj645xw==","signatures":[{"sig":"MEUCIGP2fFQYo2aHaHg172D8qwrm9mZAmP5jhdPFh3EoyM+/AiEAtj8IOXtyRWEHZGVxLL1aFsm9VBmEhgUxqYQgVluqAto=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehdGJCRA9TVsSAnZWagAAyf8P/ivd8ZRdqhAjdutghKox\nqtzSPU9sz/TrLrfNM5N5ty+F8nOXyrE6jFbq1kousN+Bw+pAIbB9920LtO1S\nMoRnZ9nlpMFoSIM86gpXit/ARBxSvRcbNl8EIMg3HA0CdYF44zQg2RLhumYi\ngNgWHX1PvrLStInNldv3qjn7Wk+zgCs6wq4/ZrcZRvVQ48IRJplDx8uCx3zd\nsQkgE1WtWtSeONx0K3ykzYsTXbuAGi9n4cjIF9T56YdE9k7Xp4Gu159mUzli\nLGrVVQeP3AWgkCejdin+0r6Up2V881CoGxeAw9AWqjulORKLg2MVawvl64jN\neqW2jAJeI0+rvSwHmpS7bN1qopgaB63MCuaTR9yTWpazdKh+/944GJxMFDkh\nWja5914WSWWlVs4TU+akiAzsxnH8/8mlwgaE/c8U+LcdX7XvLA2xDanW5o0a\neg/XDkyvjPsQmrNER/0Qii1/qRZEL2HhqZ3aImybNNoBcK7gYA7/YRf69OFj\n0Q32xUxKrzWQuRoUCDcxxRtOk6ypoaq8iZzNASRdji9BcHsuRYX7vE6yYcUW\nBFS904bJOVLpAsTIa5qEB3dBS12qcGEMml78qF+5EDMRpaunFNaCyLMCz3AC\nhZYvpdl2VxmG7CGiaf5NfIxg+95yLPpHRH9lk3/55CuUrSBRDO2u0ySO8JEi\n3Xsd\r\n=PmRe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"645bd0c1c85bdb436e6969e9290e9bb76ad6f5fb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.6","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.4","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-258da2a-1585828153485_1585828232904_0.8260711317614047","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a3bbe97-1585847743237":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a3bbe97-1585847743237","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a3bbe97-1585847743237","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dd664b98fde61ce3d3330759d10abb616c1d3143","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a3bbe97-1585847743237.tgz","fileCount":30,"integrity":"sha512-55Sj+MR+6Q9HqJSCc29opLlSPOwLt7hWmZfLaM/DkoBipykBGWXeXW7Dz0fTfDyJmvY2ZVj++VqiLTW95tf5Zg==","signatures":[{"sig":"MEYCIQDsujqba45ccXu+bhu80QkmORhB2gF64gmtnpayqT07YgIhAI/Q3JrEB/HOJEICt9YRfDWH0Pu+StyLPJ5IkIe2A5ss","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehh4TCRA9TVsSAnZWagAADksP/0p84uljc0aM+vwdvulA\nExPBcvUAJXjNU4NlFd6XCvPW55qF55v3rOooEGQtLpxqh7L8mQmN/vNiNlTH\nOFY1wj7ZWU/7wnJJjZTGCIQI2UCIZe/h0zzQ0KibzGSs9FqSHmHkFiQmyTcP\nbsUnlSHl4tbtnsB9LY1tcuIwmrWRIq+uYsUdLTBrGdMzXL7VE/16dWoR/AvA\niKlae05LR/Kak6klVRaZKBViSZUQNx+7GL2+bK4ZQmIPnQPZfV+NLoyJVL0y\nIvpl0DZTtpELk+nEt52ohDe0C85b1RLvST4hRVaC9LyG5saMfkqzNCgTHX/m\ngZseIKDW+9Aau+KTnSOvAKn+NW72764soeTGz4M5IgQZVZMDfA3Y2z5TuyS8\nu4I5tEax1DM5vvx8SNLiNmFaawsmz+M1513FVYI76NUIExNoNOpiB6wOVY+h\n3X9eFNK7Fa+SLp5jn+UvpBTZDu0E49mNDNcvZeCbVPBrRFE0sNbKdBRhaqeB\nVTwzPvL6MQsUl91hLBfr/ILjcxukJ7Nj7x32+evwFBu4ZGc0kL4mH91KN0WW\nanHfjerSzPGBjBD2CgmAoWPkjH46dapzHlRe7Rv8Ks2KcjYANkXkLkKS/nTj\nMC/EaKukypi6Wj6azomiqjrgye9Tk31oE9SnSzRG/DL6Pav2fIjE2FBT7ymp\nXw1y\r\n=CfzN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"24e7f859daf0b3c38e763806c7a5c946a5276986","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.6","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.5","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a3bbe97-1585847743237_1585847826545_0.19921892181997736","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-622d3b8-1585903929967":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-622d3b8-1585903929967","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-622d3b8-1585903929967","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"391951fdf2026c8432b28eebbf3776a91b6fcd16","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-622d3b8-1585903929967.tgz","fileCount":30,"integrity":"sha512-Im6E0wXx5ccTbg1ErU2Bwdexwe6bgOW9/3qC/UCjAguaEeUkgPD+Jgtrs4BvcTnHVkT6/bE7olWrh8mJfWB4Tg==","signatures":[{"sig":"MEYCIQCtekSGlC06bFMbSvM3TItrFUFav8F07V5/PKH+g+muRgIhANePJeEdBUlyQ9Mzi+XMnaB+N7YJ6V9m/xEiqKNYqywb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehvmICRA9TVsSAnZWagAAqm8QAIWBQPT3xsQ+ChmJApXi\n3ioq7MNY6Qa7CKoALKmzsW91PeFscndXHbyriGymf100DV9WeWea35u4ByQl\nK8oHfwmU2TjGcFPE2sF3gkZabTt4c19FM09MIdBufURoMk68VXxlKAjCgTXf\ne0UHest63FApNt87N/QRB8P8/2d86+9DeGn/g9KeZeOR2HG323wc8QwpVzao\nkmWvEvbXn7LdJntLkfILqFsldR0Spz/f2269v35wTV5kc0xHe9PrHZlEllXs\nMlZknHvdTRkcr79qx2l0vuLU9/VhEBHqGAtfCEpRGddSyFHU4TuwhCB7gych\nUjo2RjaddV3yWrBcap9UJQCuvnZhrsW8Fn4iz+VblgMYSGZ6QXUyIlkUN77U\nLgRf2uW5GqssaKeA37mLaaehH18foGEBJbz9Mx4HDKjWkFIS4oTycChRTxA9\nBvHFDt8PPnJYiPYSlKlReqvCWPowZCzbzBUsVS60mQk7wzn8Bop06mBNX8ON\n3dwQcbYpYZmU4Tf8SlLiMv9a6yYycMCVSd8UP7UDXtbH5qT7U1SqJgSgDNEt\n0bDOOCzKmw3LuPFThSlmvdme02Cjw0BOrI25xyOnbZPpjU+XCTcfXukkNzYj\nZrDBoe8jHIlLOG9Wtd2a7bXLEn2cnhd1psQ+2FXRj16RDKwj15W5ctRq23n4\nJsWO\r\n=SuSV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9cd825e6301db706203af3ffc422fe9702190e5b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.0","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.5","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-622d3b8-1585903929967_1585904007452_0.9503248601822982","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7d053e3-1585926920262":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7d053e3-1585926920262","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7d053e3-1585926920262","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"53cd7763595cdcf1a21c6f65278944d915bf6ff7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7d053e3-1585926920262.tgz","fileCount":30,"integrity":"sha512-IfcZpMEX/MupczPZW+Fn1+SWR7dx0zPkg67Oyp2cMcok7DFLxa+c6lPje+/nEYbIn+ce93jAr573dcmR1wYKsQ==","signatures":[{"sig":"MEYCIQCcGElC5yLEIb5rId3zWiNlQDEa3TmGUQ0jmQSBpmUeIgIhAPSf1RrspF1aeQ47rG3xE4el1Vyc4dImO/Eo/psGkO8H","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh1NiCRA9TVsSAnZWagAAhXsP/RPMVvD2tjnjBVABVl5y\nam/nuGFtnPYlu+ZyRrq20+FWMbZhBuLdMYjo+7ZGWlU8oxu5fG5GZos86JNi\nUjyhrzdX9bRd0ch0Ec2W3Z3BsSzcvTlZFrSF3otq2dMPDQLYu2mF6m8MjMXF\nJyQr4J3mIgNZWW5GlTihUTpBdoMiEIQiuI8Tqp2sfoBMc8Ri9iqgCsQMbuuJ\nR/EQQ7yp+uisZ+GaJg6fBVJy1d4Q3oASVR2jTcBco6XQHq9QmXgJ+se/Axnd\nHTgE9wUDArFItH3t3M++6j0QrYoE92qZOWrju9Dj3Ob+V3/S8RUmdXyajS5V\nXedcKiVGeyrWcOPDwUKKwPmKriVK5C5gVs1y1DUl7EC5BQeJYooYnK4ht7QD\nfunZ977Vsn/at43npfy+A98gno+hOnqrOz5fIl4shIFDpBos/0x2Hu4rNWz8\nJJhCXRrlQHq1ww8YRu84ah7BoxP7Sq83cMrUvr48zv1ttPeyZkGZmqY28YXu\nTIzDH5MDu31RQAsVHH9XQNpdegYUWDBh9V2FK5HW8AP2JddIqVH6MQsXMFsY\n6wxbZvi8NasUHBHCk1Dr9cwVcyqNXndMN3rhEKB6pyPRBWP7MnixTBNFM4PI\n+zdckhtguUEqYLSQunPrvXsCEbwR8XnDtJViWFsWDCX21tJG0+zT58faeSST\n2nJX\r\n=IwVq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"215d89dc6d2876f61c5dbaba1771756502bf535d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.5","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7d053e3-1585926920262_1585927009543_0.932933823210804","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-fd0400c-1585947752457":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-fd0400c-1585947752457","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-fd0400c-1585947752457","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dc865e17f1cf0d2ca97ec661a99a93610a026b1b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-fd0400c-1585947752457.tgz","fileCount":30,"integrity":"sha512-YmY+LD0SAhUrXT5jLGiUovxskaQb9Bmb42T+xf09CnfHCCir96MsWybs0vxTINJKjY3MQ2YGy04x+O4Ml/Itqw==","signatures":[{"sig":"MEQCIFFY0pM2UtlL4/4R+0PoWsEJgc2S9oGbB3TtmYkstpzUAiA1KrseDtqI3x2K7XVbej+qC+e/ZT7MaKG7mRpN4hXhHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh6S2CRA9TVsSAnZWagAAwR4P/RfOcK1keHp+v7pTKVbi\ne6WEAA1aUNqXCDs8UBd/HJbRoF9P+dfnJ57837QBskVsdLLBHwjg/2eGvKds\nQcoojeyyHueDQcmMNZs+WhaPqa0BmEWQ8g9/UmkkQ1d4Ep2FcpJ8EVf9Tqc0\ny7Vw3uAERh5lQhBGt68wAqfcZ3NWKiGrnSuEKQgGcqhaWyY29vTOjE424he2\nitfs78RXpELrZzgJ/AVuyPhNGPnSHBVJhwRIw9ebLzM6rVwN5Rr+9hqgiNiQ\nlv8L6wCysN/wf5H/Kh5+3id86iAuDJ/zw8qwA7dAHvrLQqvJg4rwH0Hn85/M\nvYdLq/fJF4rd4hcl461cnszv6gafmgn3BcuQ5+LyIemav35JMGS+sTuARUgq\ni4dHiA+7dQQo2bTiNHQMcXtAFjiQpMfspItsplZYmddyVIy+lmJExFoBwxql\nrIrTj0BSf1CNLn3s8j0Luv1+zWoX0WqXRMW3O2a9itiLX/BHodC5q+06t1eU\nEW1u1PYJZhpUvwfrT/v+HTsJ9dwcp+aK6KCCnduoNCvMmV66+2gTSAQziYO+\nUHSyhyy0pC8zaAn5ZiJN5SEsG0qrR6veEIMX+QK2MtVU1+Xp4ZgkNpUwDkR1\nO5d7w6lSNqC6zYlF4c3KVsQDqhVhR+ZyKMdzbi562HeZ6LOBbvMr+VYQXCxA\nP+yQ\r\n=nSTe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"83a32a0da2ddc3560b561f39493da6ac2c19a1c2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.0","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-fd0400c-1585947752457_1585947829678_0.971794059231206","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-fd0400c-1585947758261":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-fd0400c-1585947758261","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-fd0400c-1585947758261","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6e8ba4faa093e769ba90ee14d5d801822efb4c8c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-fd0400c-1585947758261.tgz","fileCount":30,"integrity":"sha512-PRdUB0hbkKirzM2rIevROdWUqG2O5jJYsa2Hndu8r0AZzf9sZwCB9gfpJf10SyQpQVMjAlOZkGfRCCPMBP8YBw==","signatures":[{"sig":"MEYCIQC4VLh2L01QvrTu1EaWsCMRzFd0ZMLadXpSxYAc4pVSdgIhAJDCWv/U0PFKbNwKdxi/zsLkM/Wsk27j/zxAkT2Nk49n","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh6S9CRA9TVsSAnZWagAAtBQQAJ+9m/wkU8Q7GD9b6Mcy\nB50jcu9637mg2lJvgFdfBqa8210InxsHyHjAd2EeEwEinhfZt+BxINuidAmk\nl95raWUFg7DNPTnBpOrYvQhE4+wIXMiILhL61zyVrDJLx8pSey1OMXfwtLl4\nAiRcW3n8zUXgjn6cVRTxBo/aPOF4RI7r5ChFLwnQobPh3HptwcZX9x8qXFlb\nqY2slX6kNF4/gB8g8L8AS5Y+HruaOmT/KSJ5CEvTot9ZJwrxM9BYNXXONMjp\nhRusM16dgQK8Jc+kbOZOPgTcEJc6KSQ0tDDDeDZrrT+EWhZ9tgqEOObnFkEp\nUjyVyCVpLbwFcy29TkN73u4ufu7I5CU5w3mOnqsDnzSgsWASDoG+awfk4F7u\nG5NxbVT+OFaTr8asPa0Ft2NRX4HKOXDNYGwVac1B+Nx/NMl7fUd5x6H+svHs\nDyw2ZaWVT4gV2DOWVx1l0EqmNMEsvgG8Pv5jhywNlqxuUEp4vs2CdxV8W2AI\ngOTdlHnC1IzTrx5bttxaVum4CCEpANha7zwa2xaVGdfApEbfPxx7G0ADjws/\nJXnKRRTtoyIltOe8x/KdlkjUzR/TYHFRRyFHh+27tiVD9/0h8sRbu2IvOf1H\n/oaChRpEAn31KG2zcIlTLz76/C4O6pmuhzwdEZF05a2Fa4PD7cFUEeFfEdIq\ndb5L\r\n=ba6t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"070325c0234008ffdeccb5986517caf8c0a2ae3f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.3","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.0","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-fd0400c-1585947758261_1585947836729_0.8817075688402218","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-71c560a-1586141191227":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-71c560a-1586141191227","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-71c560a-1586141191227","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5a4342b9745829bf9b2235f5226394edd5996654","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-71c560a-1586141191227.tgz","fileCount":30,"integrity":"sha512-3NOV6UFswBK+3MBPkCxBuGC4uxmyzQp92OJE85Bjd4gfNIoYzizu2rG43n5TAx7E6sWPO1IQSUJ6NZ68hW+wsg==","signatures":[{"sig":"MEQCICtOit/eWxVQfVedLwp7CF0VkBkUt+qQJjosVYm3UMQtAiA5WQSECmU4/J42jm+NpryaLZZbYl/WSBuRzxKpJvf8tg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeipkkCRA9TVsSAnZWagAAiIoQAIBc9YlfZBr7KPOa//2A\nfwC7vR6r4s8SGQayYPG+YFgsxuUo0J77bE/QAn8H+do/9ISz534m3TlRS8xF\nHonNa4bwAq5HVTJi5r9OmCLJIb0OjD17Mfg/khq017qcBYcF5e+rkKsjT3bE\nrT9Bvb0rnJyzPB1De8nU8sP2RPTN8urQn7Ct1UW6PesiG9GAK+rJx86RR3Wz\n7nLI6zTUplyg201NwlxgxnaALJfv9tFYaRh7miVyZLQboVScjR5F5ucTW3MT\nYzrTq+pNmxr4KHQf9FLWmug4Gbm3ZoLQTK0GJJL1QyS/R8LPdmy3ACDPdhlh\nTXhKF+riI37zIAL6pauM1Cvmd2CytGxNzr285Csk0NbRH4upVk+qIQoP+XmG\nw2VQrdrta5qmSBnsPdepo/1ZeeywyjCw51MeTlvQbBDDmRNq4FEfFTFqAfpT\nbdNGafRzfBXgEHKID6SXFk2V1srkFoKOzF/5hv3KxNRrvbheigl8u4ZeEFsC\ngIofktmjC5QrSjdpbIBPXR+GeMDC1bf3Y6WbrcktoVDULtYrgSwU27+GVCfk\n1QUenOazPFrFZ2TBugg6FV+k3yPSrlChVs482sbwwUQTaGrGC1Z85BVS/j8b\n+VkVJZBGvd8r9iXUkz7Xnkh0TY8cbnsrcOSOA+Ntnc/vj6pBw+yN+/v7IqsF\n/1P+\r\n=JDMD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"026a3d300fbd9f05fad56448ace3c21df2b27221","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.1.5","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-71c560a-1586141191227_1586141475609_0.6825784921812896","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f99bd31-1586161660329":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f99bd31-1586161660329","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f99bd31-1586161660329","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"30daf971c6d3d619b6bbb02ecd10d47f0a65d5a9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f99bd31-1586161660329.tgz","fileCount":30,"integrity":"sha512-5llGFoXHQBkwZi/RSalTsa2QdZZfYFQ8kq0sS06IZkHJVF6QoQsJ/4y1Czz3YFSrSDKTrZXUVYXDatorZt7iHQ==","signatures":[{"sig":"MEUCIQDZQwR+Rj3JWhG2SpIrnlJad3ArExu+nnfSeATH6LXh/AIgfV4os5rVqZzJozzyhIBi272aU0yOST9cbWRJffJDas4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiurtCRA9TVsSAnZWagAAsPAP/jyoyR1WVm5FhjvbpQpo\nW8SUyB0IOuF429G3xHemrUrTncq/swiFFSU2k6JyjTJzNqTsipgO/5BnW3Q1\nh6Y6MPIK9YfWP4dqo/CmcrHHigN13pxAIGNhxNWxKxO1ljbbMQR7KwY2rwxn\nXuVV/poY3nMP/tm86KMKctyZbmwPyNhu1ZWN9buRqr/RgK2HcieqztiDsy9E\nwADsG5bNbdrQ3F4u5iro2ZEy0p6ini3d1S3TKt7uOCmfepxZvSJI5TsxsyLA\nHf+xzPHtvAl9/rgv7Oxv5LFfgeZWn0C5LJyd1ceJ9HtmPULFXonbpmUOIu81\nq1N20eWZeRj16qUTHQDAj1ztGNJedaDMbwC2johmveaNNl5RKrMAe2Cl+U3m\nLzzghiUM6dO6cDzuMZss4g4KKFSqCuxfsmASTp+S+HM5OxgMi06k4sQFjNYe\n0VTHQ2FAPNK9LrG+K5jxosI9+pFloa+/KMHV62mXq2wG/ywLzhPx2PZhB7Zu\np6nq9rSe3EDscl8KgPuJSXrV3zLvLavW9X4WOtpm8Wfk+5V1XV3ns+jH547a\nf4QTX/tNJ5QVBA9TVXcJ9l3lQ2q8G/Esrj2oKzRPTQppS2ER/VDNJM0krVTs\nIBIXHkw1U/PiKsZNLCpraAHkqDrfY9ttXI8njO1q8qzylFkPyuo4oTcGe8ms\n2Ege\r\n=stK+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a1d108dc18ef0271515bb2fbe5c418d92b9ba0b9","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f99bd31-1586161660329_1586162412614_0.7010618553603292","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a0c87dd-1586288335850":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a0c87dd-1586288335850","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a0c87dd-1586288335850","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"91a79adbf184b644c25b605f1310566b2808e48e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a0c87dd-1586288335850.tgz","fileCount":30,"integrity":"sha512-PxPHgYx8MFdDPXHMCmE2Bqr0DA+ws9K0Qq3yFbOHhrimwAMobo//Nx7t7NdTq415UyHjrriPTR0bSI5W/9nE/Q==","signatures":[{"sig":"MEQCIA+9cEC9pEJkyb7uf6iw38K8YoPpmEx/XMx1P+E5t81RAiAGHTOukzgBXOIJ0WIPUoZTFN6lxmHVHUBi/YsBUA/Z2Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejNcgCRA9TVsSAnZWagAApJAQAKMhvP5OtXi9ewz8qzUh\nRGlZ7FFQfGZVXinT2zmp0ZKPpPfZOYSZnjQG0Rwnp13zBDHKDbfaHUXWAVCr\nx+fPSret9c4EEDnAXHZ9HxvvnI1QOszuQ3W2a2BuVy5eaTlH4G7ZhMr6ii/4\nE5hg/6mYceR/TTrz3LSfdRG1wt8OY1NtGowHAYJhThKeEOKgdR+bw9qBLQkI\nAAcrgbZbUNzww3+jZuzGFqp4FlK2YqTMlDvpU0ee2lUldFc78LJWkg6dLwMF\nqbySBJnA4Unm9txzequ3jTweVTUAR8+UC/hL4NDXIfjl4ju1hfFPkwHkHL7U\n2AlO2FV77GbAEtJtIgzwiO/Avbi3/XznK0PMMpVZyT2HQn9U2vLXkontfF9s\nzRU8AwE97Kqz1reflz9Hj7hRJxPT9oJqnTQAXOShF5vrU6zH2Z06oeBzQBKK\nLJ654WZFatjvUtYOfombqXqaAgpnjdV7NGzmSpRmuY0DcQlsU3MVusRRqYp8\nKkJZOTkRgsodRrtUAs7iv4eh6+IjClZFeO5uejWI9E4jYOGxLO44/GnO5lJ1\nV64CDsd6PdJ5zpCteYnXBRlVGWCoINheZvuKOpRTert5+CdvtJlXx4O4ryMN\nCGrek+PcEdP5E+hAu7c63SX+k/8VIRBmsl6WRU5A2py8FhRJ5ORcnCke02qq\n/qTs\r\n=iWEi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9a3b70982600ed77d3fc2b433c70c7ccf60c2768","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.2.6","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a0c87dd-1586288335850_1586288416286_0.789115610756284","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8c3a4f4-1586358319419":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8c3a4f4-1586358319419","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8c3a4f4-1586358319419","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4a567a6aaaf88651c9d01e657d9047c79f055fda","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8c3a4f4-1586358319419.tgz","fileCount":30,"integrity":"sha512-IbhSP7DUD2uSNGxnSayKt6gJlnE4y7SEvWi9Z1dJ4iOeqHJpUMtmgBBS71Q0fejE4p/9wHcNFYb0P0QDkzPU9g==","signatures":[{"sig":"MEQCICtAvEZ6F9DuAI8jGWPU+C4jE1WM+3OVwnAF33YTj8FVAiBYrGI83tRD4JFWENRmuy54Kij8Rm1QCqZwn0YZR+g/wg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejeiFCRA9TVsSAnZWagAAej4QAIbVe3ORp9Jzslwzpews\n5x221KxZE8VotCLBZjOwZTkOZsUygISMDJcr+QvM4zAfxUWCO/giDOy6/xP+\nqDm9PuNbA2Rj+ZdvlqwCtxWJ7inMNi9NUxQeI3hResgKv42VTLcLaqpHKP8Z\ncDsQ/e1uq8lAeyGcQJb6Sjl+0KxXLGUJ6jIN2Dpq6F+jLhjBpPyvZTRU0Ywv\nEwJgmtENtMOqNQAN0DyUUl7w4gwDrTxnJi8yQIztnrJK1nzWtDwCUXRTE/wC\nG+0Lb0RJ6qUIBtOjanhNttCK9fhSOfNfDt1jHXNNmcTSmx/ewgF5ypEVUvnI\nBzSB6YOusNDpjPWTV0IU7/hFxSMTS7wcsvkh+ce8dFBtKL2Cz5jffHqT0Hfq\nZKYtdYpWWkJPteop4kLECtaXAl3FMsInWAknK7FOQpoTM6HIWFZISLddTPkh\n6DtyKgjwShbNfGhy+aricWLDpWq2XAYyCrn9YJf98W0aQW9ERnL41o/r898V\nCC83K5sqCzn/C93rS+jKSXCdjHXoOy0IY4Gyn3/XjLvcde+kzFtAUSCLziYG\ngYL/UmJ0ATlkX7j44aaXDnT07P2GYiq+DzySYwrJEP2JoCEn3w2cb1Z44LkT\nogPxEyUkzC9MMMuQayaJTJsoQminWVisdOtyRN3qZY/uDYU8hwPytC4hEKZY\n0v6M\r\n=GHk5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"929734cf90d0300697449282313bd6435a3da625","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8c3a4f4-1586358319419_1586358405006_0.2651895195992069","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-18353c0-1586359928782":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-18353c0-1586359928782","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-18353c0-1586359928782","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7a285eef9143c4c1ecdec5cdc0624651515eacb7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-18353c0-1586359928782.tgz","fileCount":30,"integrity":"sha512-SONKZOaUM+un2lmFdV0FsZt4042CwsBaO58r4erq4QF0rsSVEB6wAkISTsQG1lCTaTz3ckahn16J25/s9nMn7w==","signatures":[{"sig":"MEUCIQD9+OOuPRaSOLxnXnQV3LRPvXVmx6OInIUz7B+eVvn+WQIgRtPyQKt6bdjw/6D1idsVOOzh0TPNRXvRmSm2FCjmm50=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeje7JCRA9TVsSAnZWagAAqMgQAJOfet8iM39qi/AN0hVM\nZJb2Yn2H+6PNPIe5AsbciHUl+mKklw7aAwWO4bpU7LwUEhG7DcGM4OwYiAzH\n8in7BuvnsRcyNgurQzNg4QIU8BGgHflOUIaOMWDoda3SRNKpuTAXf67kLBKP\nWuo1McURHxbQAj1LOwJbI9efR4qNvijl7qn44/WtZ5ASmWvqzfqwQF9k08uN\neJwNIsB/mjIfW3MYBuTf5kCFbn0h7GvvtUI91ltJnjEGWCnQcsaWNCfITj2X\nXFCxi957NeqrF/ESkK5ncZk8TPmJmnXU3lLu7FrU3+Z0/5oHMp/BteCDofrd\nAXY7JTcwnI87Px6F3FlfUek8nYgM3pr1Iow6RM/oaeBbc1njXxRpExTYEVe1\n1N2So/+FlX1UVeztWf8h+22yKriat9IslwhWw0klume6CwdCRuNHrBZCOrM/\n8M/RkIiDkgzHWBfIPK3vShIGpe0S3ZYPweaoMFW8B4QyPaoDSkfoEJUrfBxd\nbU4WhULJaOtZUpiYoeMCY8kkspufRkYsvLcrYVeFMOvHh3oE3zfq4MbmwLyT\nMYyNLW0cIMBU2PXKfpTnU0smIN9ZSOw/QY8Y6zQtGV6p2BtRV92EKe0A8EXt\nP46zgooI//93p4RqENdoUmYdjOgrLs6Fca8DOh67Rrz82wCTP25cPNh35yo1\nrIfI\r\n=5H3u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3af1a16a32563d89ef2350c8789a7e728ad91f79","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.0.2","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-18353c0-1586359928782_1586360009090_0.8906555197411459","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0ce0140-1586657527134":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0ce0140-1586657527134","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0ce0140-1586657527134","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ee982a19b51b2a927bd8b8b5f2ddac3c7b17416e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0ce0140-1586657527134.tgz","fileCount":30,"integrity":"sha512-1nsi3x1SguUZoCJg+XHWpeJauyfGAVVOrzJpGJJLV9s/Y1D35DNkz428UYo9KJ6Ai4uh1gfIeoHHylRh4jaGEA==","signatures":[{"sig":"MEQCIBU+NFf62gDRM2uA5bg+4kstPpeZLUxVGYbcHpQ2JohTAiBOC17iNGoLm1ezFe9s/541Roxo0No6xYZkkUVE/cDgBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeknlDCRA9TVsSAnZWagAAnwkP/1WqKOpUCUpbpOBktY5C\nD4+oQCLwJxwR3bw5cmrmKSuNYva7cz7+8r0OCUBtTMOLBCe1v06V7KdlyvYB\nlu1T2AEl8HVPu8mkFGxcsNVGKkaF/FjLEMbNF0kw4YUy08wG12Vkkodsxyp+\nmFBS/pS82rXeDARN+2lrNoX6GJ0/ynueCbyEHht+0PRkDWa00TgWOXs9OJGw\nOVFArG36N4tmmLO+ZeVIQoFxF2jXvunMoK4L/+2S/h8iw/JibQZMct9Nwzx6\noIkGSihrcxJildQ5gw4iQtxUT5cI/mArT/vUbxFJmE+H0oeDTlH6DLfKAa0O\naRM0GUxe5CHoi5My6pldkA0mWyKWe7fHXvsD0rRYVc0fZRXrAPxMcDfm6gUy\nRfjD383SU3snRFbJFRpcqOqTPHUxmTj23Ut3IIMXHU4j3y0Aqw4mPnvWEfeP\nR4bq+RmzUBMyU0IzYVu5jhJiWo9W1JLszEx0TMQQn7S36hKmFKJbpq8eh+h6\nd4Uggly77burpF27OIFvbisklm3P0nTP5YXIQrEr80w/N31s0FlaFXDnp+zO\n65rUN2niYmQHX3tK5XvK1YZ33g38lrpc8T4qPz0aNSvCF11iMkgWDARX6ZPC\nPK/3rscUTm29pHyh+PIhK+UFMtT5+t44DrAmirjJoixr6EtCBNYkGP+CcKrg\nmfgg\r\n=K+Yg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"bbf0ff47f2282e456b78e5b34ad9fa78a8a4f1e3","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0ce0140-1586657527134_1586657602594_0.17850387986959415","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b28dad5-1586658058251":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b28dad5-1586658058251","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b28dad5-1586658058251","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"88e0e53e549178022d76ed874b7efa4228889a24","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b28dad5-1586658058251.tgz","fileCount":30,"integrity":"sha512-4sAYAG84UyFt2upLeSxfEvMflPIruw52WX0m2n+/5nMs37HiHX4yNUs01f3qUUQ55yHy6OIskAKvRLT1tJLLiw==","signatures":[{"sig":"MEYCIQDKTOThGjFUFV2MgGUWcWj4WV/B0+hIq+er+0xLE76kjwIhAJoEPX53FyoodjMz6D1WmsZ8+dK9llyhqUyoUJzxarpd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekntOCRA9TVsSAnZWagAAJ94P/35tvMyIFRBFnC8/0VED\nVxrj/JZeO3K7XfHPJYo0yXfxwF0ErRf/xGQ4/qEuBH84gk3ejlKhLuJeB8ee\ntwuOzdUpGmZ2Bria7b5K6zeVzNRQUpoHu4tnoqRxDVP/KiKK8E1X6X8Pzpew\nXPih3TncY8UW5CptkzIwbGiukc8Fj3xyV0eujwAPYwr9met4aYOroOT8DJXE\nPcdJ4lnVBRyVOoZJGRGZKtc/MLIY3tpwxfK4f4EcDSd2HcblR9q8K2vYzMW6\nZ1S6VZcfdVr4dVWrVhq2vKGcp46gv/Efa4mW6KMf+G2Sbr4fZLw4xkK5gIZ+\nR2MvZ/pIJgszNRr9QxVHqrImPutoWldFKz7RkX8CT0G5B5uCum50Xqjx8OIb\nXg3+hMMw2X1V6zpZlaRavsTnquRdjT3uppLW00tzZnxSodORgocga6bCZzKV\nR775itGV/01HAphoiLpenBuM9BLM4jvvQ2i652W4gWkYuI5Rnw8hYI7q1VWb\nw9nEX10DErti64n3TCBExpUUjN2RmPRzkm36qPACF+uXH0riOljCxewKOKA3\nKhKgemcTOqJHeNasVpfw8KBIws85PSdQCy992oaXFfBeWZi+NFX4TPk8NSVS\nN78B61uegRlevWEhoRtXIv0tLrSpzZyVJu6/ocmUG2MsHJtpPkr9TtoA2T8p\njHIP\r\n=IGnX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"26e0397ddd0d439772994e7489a10de0e51390b2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b28dad5-1586658058251_1586658125676_0.44485517342393743","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-1370da8-1586714237205":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-1370da8-1586714237205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-1370da8-1586714237205","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a7ca6a0272aa4c46e87f9986383fb83613c7ec68","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-1370da8-1586714237205.tgz","fileCount":30,"integrity":"sha512-TiOlITg2Wnwg3hmXqRDYrwhnnY/8Uqm/eZvsCnNoMoXQcG6RJEnuINosjzyZlN82bF+098PCFi/UEqwMZOdjMQ==","signatures":[{"sig":"MEQCIHSGBxN2Zk4mWD5T/i1f6kcNF78A4rnCyv+bqWWIH1UCAiBFm1XTDN3iRrMjEai4GBTs73AMCHrSXNf35xhMmJnALA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJek1bLCRA9TVsSAnZWagAA17oP/3jOQKJm500DpmwBURdW\nTnyEIc0AvUaVSGGOblYNHxBDNwUP0imHDZPo4atK/E+Anng9Hh2smSEvR+mF\neHYAW+eDbr260I0/0+0FPhjg1WtvCKxPblEbWyZaY8lhVaC8HukDAATsIPsh\nz6VebZpST9yh5TZfi4d+bYdPTlNYk5f1YQnqeUTcf4YaSqOkhQ3ZGTo/L+0n\nGwgt7FAsRSpcE9JP4GVEdiBfKcTrMsWdd3S5OffPaF3JRqy3/yqYh7Han2Jb\nnZ7ecxANAxVAuwzorzP7pUEQWAXd1eIPaDoSMKnM3sD8y77cf3EnrOx2bVbu\nXaRdCI26qW9LNuNeQ7tHipU60TDQbCN1SFjttr4tGGaE4zl9hTu1Xlpe48Lh\nyBtUEUrGKLoWEdUjEzwS3j7PLv9GTeQ0dME5L0x2oqE8Pe1ZPNuGFGK4X50c\nvIty+EFLWBcFBa1ZeBzZAUfp8KJypnmO5jl+Djp7kdw7dC1jnGBJNnlY4KMn\nw1W6FjziBKEEjAGbRICAgK3G+KBvDOT9SneC5+JowdmjB1P8q4MGE/CtD8h2\nk5NibsyZ8ZYDMw2T91jLIkqztVPPnLmSBEQqin1O6pBlbQW8EIWLo5UUIREE\nQXG6WJJ4m6DlkBj3iKOaduIpCy8zGmGKbF+PJp+HqgdRV0pyV3YJFDu3iLV5\ncSlp\r\n=6Iva\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"433416766a0780ebe58057707d072460c17b447b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^1.32.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-1370da8-1586714237205_1586714315258_0.40479437860896006","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-e4ae4b8-1586727912181":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-e4ae4b8-1586727912181","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-e4ae4b8-1586727912181","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fe9409d89a28401d6c5692b9fa779339003669ff","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-e4ae4b8-1586727912181.tgz","fileCount":30,"integrity":"sha512-+OCOQqeSitWWLnmSA5iL3w8Jm31YLqRAY8cVXbQsy/LNt90hSA+qveg9VeOUY2hQo7D9XarO3H5fNMSDcWO8/g==","signatures":[{"sig":"MEYCIQDtF4rLjzFthvkEVELQhqP7H4MVHVsX8Sf6BhqGcej8owIhAJv50jSaMjYgjvjg5oyNXzjFUBXxkDkoCZ+LXxgEoVW6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJek4w0CRA9TVsSAnZWagAAai4QAJrv2BapvMkPn+8KCGjr\nDlkBXMTKHr5+vneRaLtArpUxCoyIO9CzlXPGwBDsVRycj0ZZ8bf5p7bGagrI\n8EIvQwMcRWMM0Qjs5w0/+9uMo9NDXFVRNuFDOul+y1m3953xF5fXfvnN8MI/\nUBqQ7CPnchq+WwT5VKyDYGAUsppIVp7JESBoaTU9tcW80SZhyGaJp+k7TpRN\njiiLzTBYZDZ+FM9+tI0+9RWA5XtDeeUeyWy3v9Fh/nYi9ac/npvMoydjfZnZ\nYG1AKr735oY09DKom1HfHezegQmuQLGNF+AVB8R7PzxTJhfz0lQDuGvdoDm2\nWldXVvdGlE7wgLG7gN1PyUT1gdMMsYBLslFdnkgWkv1rGyAc7j9YexvlwItw\nE/W4niSy39onETns/+pkE43ZLE2E1m8H6LFa1dX7QvjXr0O7/lAxNPWDVyqb\nb4EvTggDwxaLagEo2c9bSA2d0dgA6jKVnF2U5ZT5dKMm/BpTezeIhEvYnCwz\n7jvzVj1VbyqF1GCMB9o39UsYciT96wXY2f+Om17SJ1xAyP62Djm7IaUXnV1L\nfic/0Gis5zcD6CifnlkhSLVBMXhdmqoPVHnui6XAZNDtxlgxTweytnWwleF+\nDMAIowKS39qGY7NX78Z2qSc1aMFrFp4cN5aEN8OaBorWly751rjsx33pfn09\nsJ7/\r\n=qWHD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f29100818599be5e97d02879b1aa4e8912772655","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.3.1","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-e4ae4b8-1586727912181_1586727987651_0.19289124835765548","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-03f8a47-1587117925886":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-03f8a47-1587117925886","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-03f8a47-1587117925886","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d3093ba5faa50d8843c84b46646dc78f406a8fb3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-03f8a47-1587117925886.tgz","fileCount":30,"integrity":"sha512-690aVPzn/MYKmqvp6vQyX0EXDWyc2JmNlbkp5R+obZnv5cSBi8x1lx+4vYsA+ekTmRkCArgsHNgjmLpZp6MauQ==","signatures":[{"sig":"MEQCIGnBFIa7/2cukjJNBCKALWSoNrCV++noBGzz+mAA8tFmAiBY8lklGUp+yb37pKkETmwy9GBMZWizD0dAShjGuuzrEA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJemX/bCRA9TVsSAnZWagAAQysP/1LJyRDdbsjwOQc/qg/S\nTtaE35s7fnHY/q7JJgEbAoYsC7m3fxYdXqOELnpQ7WiPW+WXMZs1yCPTErUV\n7YmkJqbeJRZ+8M95p7H+Gb5Hi/J2yQYeXUWp3arsY6prdMQzCmRz4/5tc4Tz\nk5oDJ4v1d6a5bpn32+OvBiY11kqn8PRJ0W14quIjGGAxYtZ6apAJoGQpC4AA\ntCpAnzm3BkmiYwj2SMYuv89veOKBCBEDKt+HOaK0T1zeop9K5Di0+2frm0ef\nYTyt83NCImLbh9lDoVu/hGoqJiaOXXX7GvIJbIhvtl1qhkHO2pNvDmN2VeK1\nYvvCMrUR/rfMoaC4gZ8qdP1csb7zMA4ejnnG6lSA7PPARnaZG6f1754M3d9w\nr8UFh1X+qpvW/SQloDB8Dy/WAbDlNQEM/wJCRtjbJWz/nTY1cpviu48gqQqZ\neZx3NkueTv3yjKTGnRytrAWRX7Vj1m3n5aFLI6WO5Mca132GjQBCtIvFtNuT\n1uO1Zk/WjvFyavGVLIjxz7WD5k4W7WS8WkchyqZsFS0NeiWWNvPUFHxuhptr\ntyhD4RZkMY4+SJCNLjEvk9IuIp3e3Bofb/1CChMO7cHQ80tgYBZcIEkbTSTu\nlL+4l4keOGDF7FGsnXd7idRRfz9tJZ1IgQfqHM9IA0Aj7BKkZW9uPNLNmXGw\nroAl\r\n=17Bh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6c741ba75fae650baa3ba32028ebacc24c9ca127","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-03f8a47-1587117925886_1587118042750_0.014960592183663302","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-57a252d-1587304604912":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-57a252d-1587304604912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-57a252d-1587304604912","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ac070260e18d53fd27dc1c61789884aed4b2caa1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-57a252d-1587304604912.tgz","fileCount":30,"integrity":"sha512-lhXMirtCLyIcH7wXBvqVEj8TfoFKHvF701905xaP7E/ifrSbNne56zeElupgbiTHvgZpqri9dXMVwLbdzw+U3A==","signatures":[{"sig":"MEQCIFAw5bZbsAr7ywRSk+TuOdtnU4eAkSwAh53qX3azO3D8AiAHA81LZoS9dCBhJYGbxftcZCzBIa4xiq52jYW8HrkAOw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45656,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenFj4CRA9TVsSAnZWagAAX/sP/iNd0HnBI1ZiaKSwkhNG\npeE0HAahbQ+RZmsSlg3/xJlljpJX/n03u5qUuUpWpOvQnbgxmWNRDrWUf7AQ\nPKjrABnVVhBRyGVFHwTER8eXAXvoBjswhPS3K1/UjTMVh7RbnHeNlyW81u98\nYhnCfX1hlMj8pe+UawbC77KdnPLdiTUzeE8Fxtm9K6HwHDG20LdKjGlfQRtI\nkxd2YecpQFwGvXiRwTkIiY61dxQ1wcTyBfrO/F+XeCiL2cx0KlT1OTO0bU4G\nnNlCWl98+n0X3BQkAUOnQhBoRRtXQwE4dtaSHxpgOicI00sRmbP1dugrlw+2\nVG5xhiu5vCEw6+YjO7urfcj5Am+2EX9pIsi8YH+fI4Wl4KCXk24DmTsvtYLh\n6tnFeE/edHKCFUXVIINIrVw1iDJ/2wm+/2PZwxnAOa4Jr2X7EWnFDskolwvx\nmvRw60oG9ozp/jDEY6VffXuAJlTQZOpvx1Wt0Do98Y+cFFIw/ALEbbsEL/GD\nJgJHkS934X0yc4OyBiFoNHfV2kBQSVGryfmWcAaLMpLhvEs11MfyG7aHdprM\nRkjoQ0l+pk2F+ni1aFL52lM/H1k6CjKP67Txl/7/Jy4xEI1/f5tOaETyrzzs\nQZ2M7gMSx4qHPtcyZ48stJVY606I7OJwYkdwazBDhfXwqetZvgiT+dhguJqp\n6jX9\r\n=dGyq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nnpm add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Named fold - `createFoldObject`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C | D;\n\nfunction isA(t: T): t is A { ... }\nfunction isB(t: T): t is B { ... }\nfunction isC(t: T): t is C { ... }\nfunction isD(t: T): t is D { ... }\n```\n\nTo create a named fold function to fold on `T`, use `createFoldObject`. You\nchoose the name of each fold function by passing an object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC,\n  onD: isD,\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n    onD: (tbis) => console.log('executed when t is D', { tbis }),\n  }),\n);\n```\n\n### Default clause\n\nYou can use `_` as a \"catch all\" clause if you don't want to handle all types\nindependently.\n\n```ts\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    _:   (tbis) => console.log('executed when t is not A nor B', { tbis }),\n  }),\n);\n```\n\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... }\nfunction isB(t: T): t is B { ... }\nfunction isC(t: T): t is C { ... }\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on. You probably want to use `createFoldObject` in that case.\n\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(union) of different guards. Oo reduce the boilerplate of having to write each\ncombination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB);\n// (t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1969e38c860b67149f71969e3681fd937dc9a0ff","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-57a252d-1587304604912_1587304695491_0.12547147215533627","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b92bff9-1587305609676":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b92bff9-1587305609676","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b92bff9-1587305609676","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"598441ae6892c91466aff92a040da2e3c47961b9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b92bff9-1587305609676.tgz","fileCount":30,"integrity":"sha512-kRUG9OZwik0jtvCRhs+jhJ68o9/IU1x2zu9h7Ug1px637Q9TUgYKfdcsNExIafOBC2SHOUQp2NjAz4cwrxtDlw==","signatures":[{"sig":"MEYCIQDSwY6FCCzfaP8R8tPgVNOuwOYx73jKEOEvUgJK8rGN7AIhAJWICwsULB/jRKDwLtKQFX2X99uYFh8XFLtt/q09ADaG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45748,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenFzbCRA9TVsSAnZWagAAzxsP/j6WtDzSpQ9HDVLrhdx4\nngJJQYSXEQxWLjQMQQO9oIY84TjL0RP0dZ97SYwdpFG2lRlhNVVx2MnnjcrF\nEJfW0hEQLxoPAQY5Xenzm7cYTQbEIwMMTkuXD8sMcH2GC+y3L6h3nT+xptCO\nogDtd2EtLdXSbTFF/KW5lT1LdYlsnoSmWIa4tkCwg9niAxi8+S9/uv5nzWBS\nDjdzVPp+wgqeAq5Mv2I9qDvTFURLOmqhkGpFeEtD9aiWaO0cITqkzW/Zd5OP\n4jEWDQAqC7H2kPcCGmBoGCIoPlDNKbtprbgwb3AgUUARqZ505LpkwTAut07P\n3cG4uv8djyMFLaISpDDNjeOvvGaWwPBXMCafw2BqNbmosw0YIy+HdB7cnUPW\npgsxL4TBduNzDBPKZLS3z8/IBD1KAl2zr+pt/cL88wXVpLPzwW+245cjLK8L\ncKPAMvqDZB1ISM75jRQ5q24cmI4oH95op4bQQEUv1EZtL4KheziTbapQ/ONR\nm63/v878M7qwzo9gE7k4cvNmhRAH0lEO/EWBZHD3Oy0tpSaLr11e3p/xhu6N\nx+Pq4/rAhis5FCnFSLzUQsnWnau9WB58kT7sP7HfkUys34tooQvwNDkA50zS\nWx/pJhjlsNmTjMkBixIefT1w/F0mapggn0U135wFOQ8eSA8azPl/SXMSaRy5\naLto\r\n=QfXz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nnpm add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Named fold - `createFoldObject`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C | D;\n\nfunction isA(t: T): t is A { ... }\nfunction isB(t: T): t is B { ... }\nfunction isC(t: T): t is C { ... }\nfunction isD(t: T): t is D { ... }\n```\n\nTo create a named fold function to fold on `T`, use `createFoldObject`. You\nchoose the name of each fold function by passing an object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC,\n  onD: isD,\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n    onD: (tbis) => console.log('executed when t is D', { tbis }),\n  }),\n);\n```\n\n### Default clause\n\nYou can use `_` as a \"catch all\" clause if you don't want to handle all types\nindependently.\n\n```ts\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    _:   (tbis) => console.log('executed when t is not A nor B', { tbis }),\n  }),\n);\n```\n\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... }\nfunction isB(t: T): t is B { ... }\nfunction isC(t: T): t is C { ... }\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on. You probably want to use `createFoldObject` in that case.\n\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(union) of different guards. Oo reduce the boilerplate of having to write each\ncombination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB);\n// (t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"93aa3eca80a1aac127a06e568fbe14563b7587ba","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.3.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b92bff9-1587305609676_1587305690505_0.35129861753817937","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b644acd-1587334257212":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b644acd-1587334257212","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b644acd-1587334257212","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fee29a62bd54f74c8abd78a220fc171bb017afe7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b644acd-1587334257212.tgz","fileCount":30,"integrity":"sha512-8uX8P5j15qxRCSH21sUXRHM/lm6gvVfPvPVsYSx99Cfwniqxwmj4rEwWaZweJBf19fH7h/fxK++6nmbV9LxWbw==","signatures":[{"sig":"MEUCIQC6lCqspnlMOcAhmZ6trS/t/ZC+vZ3m7pkJWFsQPFC3KwIgMA1xlLggzP3VY67zNFUkKH7FWcQK5nzMLIyYfDBqgBg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenMzaCRA9TVsSAnZWagAAyIoP/jlRfR8yk9oKbHMAmdst\n5pt1bPW+pD2nUfVvtsYNmdJAYzmqZc19eveshOTI3KFuR1t/XZvnGSZYwLkj\nxXYoHZiKwBJWddAgHH2QK2XsdzDvsTZNzgvprK1psS3DXjYaZPDh/IMiJl+q\nNIb5CNQPQ+01XHIyJ9dtVwmXPd28IrJwTTL4yTCphCDNyy8zyrtOK6xYH89N\nxtNS42kdyxMM14A5/j0o52Qn+EfISWxM4KSkzdB1/kv+8lVDJqb/vbU6xRv7\nq3vXaD7O3R3sX7TWUXw6OhymqQSy7FJdRwRD5L6MmW7MewASXTs5Exxebq2b\n+Vn0WzcdAVXRbei6frm2RG0cAFeamUikikICoYPY/jTRHAJjWPayNjzod63j\nI4xRj7gxsDVdVNS0kPHPP2QjgVCrLQLgPJp1/j4c59NG/9C9myATAJYCxnkH\nGtUwRphR4IXxFAo1OIwqpnA2UJFdCviXoN5K7eVtgRuFVClrTl2EQ4UD8V83\ne0iPo4tfi6k4lxuHY65AtPYlqqTT9ICxmbxQHoIWzj8u22kYkVa6203qwpZA\nVF6EiJA+hXCtLn25PjYMoWtPjf0k+/e/wrXBYNgSfw/IJAIr8nbUf9JJcnSL\ngyQyNxr+29lMV67rEGNaRz+Y3ROY8HhgZZ2Ll4gGITNVZcT1F2pEMfUsM6J/\nyAYc\r\n=kWGL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d489e40d88e5b4939c03c3e90269b1f10efd72eb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b644acd-1587334257212_1587334362068_0.17007259996515556","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0ef4d7d-1587335275206":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0ef4d7d-1587335275206","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0ef4d7d-1587335275206","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3cc0363b6262db1c59ab8ed771adde619fe287e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0ef4d7d-1587335275206.tgz","fileCount":30,"integrity":"sha512-2yxFB8eUKQpOUFHNN03Vc5+LlOJ1MImHLfIFh1ndD3agqOEO61lMcSSS+RuN6LBQGKLWA3fe0acdIXgdSDmqZw==","signatures":[{"sig":"MEYCIQCH40Ly4JRKDa7bfQwxqJgB9W2AsaJhhKudnzYGysnTZQIhAN0oAF6xCqeW5C9rpoiuL1cJ5lyCklnlq517XK+T7FfA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenNCxCRA9TVsSAnZWagAAOJUP/0wCtO0B3YeqqEMW/GaM\ndbwvWpChR4jf+skP6FF5LwsGkOR9eGgCA+DnlELOqVZ/PtHxBGSZWdp+sxWp\nk/hfRBEhJuiLDyuuz9KlmQcfUELM0hHLL+Omh8jlzF7lcHFDz4XKcU9Yr+dO\nsDLlyZqx421/GRiaDVKwQrZqcaEXKZxIICZvOkZEVqn2IPwoYM8+ZKwaXo/I\nF6HuHhneKEXNHhwkrCcWxyDzAUcP6eGrXgFMWlnEzdPI3hD+k1zmkimMJLr9\nieknb7GcWxwF1RPyBguEG1tTxkQIwCx+BE3/wW0eEVPLecihGsq7JJQI6BRo\nDwbDMHbUi8XnIKFYUFOgEXyyxyqIdQAX94P4ZhkpQDKmYSs94hFBX7U+IKK4\njS4YsvqzEvNipsTHjyRXPH9qv1QHPShBpQCCE2CRYRT1cyF5pR3XnajBMmVp\n+lfwFZEUiq54h8RpfhXx5gOXJhULqTs6hM4BItggHlAiIfLrcuqz27Wr1lg6\nR7O21VuZZvTZBDou0kJlUYY2xAw4/wY2DeEP+tdnHPRFUz2NIxLFxTH+DGqJ\nHK8/W2WVOjWmvCKcAIDSeO3+8MZEpFORaV203wyULkyxtuTRuNrag5WkwfPL\nfCXO3X8noN7QaDTwSVWocWl+zKUPWsb9fbMt77fHHCbPnCn0Yf1Prm/w661f\n++hh\r\n=TAjE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e42a8ab3154e838b65490f805c01e550f0293eff","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0ef4d7d-1587335275206_1587335345209_0.754191350852152","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-551ed8b-1587499091290":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-551ed8b-1587499091290","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-551ed8b-1587499091290","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"68f296eaf871aa988e274d9841ea65633639a9fc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-551ed8b-1587499091290.tgz","fileCount":30,"integrity":"sha512-DipHiRnxHEg0s7NNn85QgomZWQjphQ4DvTCTNqXcY30NKTknNXj+0xRdjFP8IktSaHTKciLcSdYl1OiM67D6iA==","signatures":[{"sig":"MEUCIQCp5wHzCLGwuPkK5wO/HlNy5cQrWLUgHjfuZSRmN8rf9gIgFE6V7ggmhGIznSKvU0MGH7lwnhrQwtPd1u9Wej2Lk2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJen1CgCRA9TVsSAnZWagAAwxAP/RwwuRGuY6DY7g3VKC8m\nQWk8qmwMX69ojgLvt1pFFKDovXekJUtjjEWzNzMY5GreYeGMoCmgpvWn0WD9\n2GIWU+f3JcnauHBto3nGlp9hXjA1n40rF9ViR3+gp1b4pVCitj5QjUQRUk08\n0a3QtKnOy4ow8dWvl7rnUC2A0SM/Ekx3kWfIecpyJmyd3fbzS1t3TD8qzAnN\nrzlhx+4ikqnh76E/bIGpjTRlYMxUGkAh7TrcA9kpHY6aHXKv6cJQPYs0vRTm\nwKAo3N4N5OWyHOnMHoLON65bt5AwhAcGBFgmQfsC+4mLmR57aA6r3dfk8RYa\nY2bDNu6lchw+az0G53D6+Jev61sjYggh9LOVt7UZIhjO6zj4uMF7BTfbRcxj\ns+IGuBH8wfXGuwopwPYMh8GqDwZ9Vj8R/yBA/OFuv9Rax9ORYTdpSNkqFF0t\n5NEKH5SnkMXlmtvtD3ExUAmdwtZGxssMFvJiRM7Czl0qpxNhbVXmZJWJ00W4\n1EkvU+qOJPkyWHQ7DbadzorfvaNd8ki08VXYF5wPJgpH21g9P0F/UJ22vdi8\nhwRQjf6ZF8hYQ6zavZEgXUWqMKj0HKc6LgBY8g60HTXiKToI8rSnhOiI4hzL\nz8WstcS2DXkZ8jSn6K4YCbfXRPiNkqMsBqkwey3ujoIbjFkokdD4BFSMqVVY\nYlAf\r\n=f33J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e83422739e89768d576ca8b3c4dd11f0854c1d30","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.0","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-551ed8b-1587499091290_1587499168189_0.9440138336871959","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-45b3896-1587502641849":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-45b3896-1587502641849","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-45b3896-1587502641849","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a63a6971992ce251f85cbbceb5ed085aaf5af554","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-45b3896-1587502641849.tgz","fileCount":30,"integrity":"sha512-//Oz8jCA5njKhZCu9d4d+/YNkDvZHjV5NkP97X8POMGQ2wLBPhxbBi3xBND816Cg7YQb5FPukD2GRnuwB1YdWw==","signatures":[{"sig":"MEUCIQCVY+P79SRbIWV7FMyAtYw8kKDxkHBEKTQGLhoJCL4KvwIgNLuemVHJj1gGEYIWVbHvhcAa890cl9+oUztEb4mYWSg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJen159CRA9TVsSAnZWagAAyMsQAJp+ZhcmfqdmKrI+dWgf\nvbST0ssnc+N4s+dr6RFHdZClC2Cv7fBxYvLcykFRalcRHlJuEkKtNF7eZz3V\ngnZuY7z8gMeRrMRTRZNx9FT2cojR2FqWkRIJL86tAFVkVaBVv9ve3hvEl4aK\nCWVn6lemNh6YJpcPz8WQzuJf8Lr7hwGj84dRlqCYMideCv+vgL59bgb8ZnWe\nNhG+WtnVd2eUqNlInLdRDYwWEgn46/0o6c2ex7I9i4L0fl29xSwj3Vh6sVQQ\n8latuDQyEntwchsmFTq8TZkh+B0x5GazsA0OocSEHfg5jXGugUQXR2BiCRyH\n/miFd1Nsm7Q1ycmsWa94/98mv5tabSVZJiIf2+DM2Q4XoY3dicDQk8DNc2TQ\nXOS7UrfjxdFIewDJvZjv4nYT4045EaBNOQa5H2w0Ft0HyyyLI5V7oErrHutv\nuCestJhyhYq6P3PzDlsy8WBn/7bNP/EhIk5tq5sEvJn/ZIqmG8gd55XpLMu7\nvFCarYx4gNih4GSPGOdWjWaU3FxUaQqj3bJsW1tdTOKZB9Qv75y2OX0+RV8h\nRQIvYP+VarKgNyaMVoZgsRmI6rongjgwXmNs+UGYJ1OaLdywVU7YAoyvU1RM\ntPfMBKi+ALhS/irqeEDtPZ+wm4bYvNFvGNDSRI/ybip4ikI2D9I3beSwdCsr\nwdz1\r\n=1cRU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c4965e039d85c875de1aa615d85f595437fa5ecf","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.1","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-45b3896-1587502641849_1587502716997_0.15470700432301254","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a5c42b5-1587582512965":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a5c42b5-1587582512965","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a5c42b5-1587582512965","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"aa381c8422bf509c4306ba3a6e74877f2b9deb9b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a5c42b5-1587582512965.tgz","fileCount":30,"integrity":"sha512-M2qXDC4zDRAmjEm8gne0rxeP1oR5CYAd4a99tsAjGT+q9dDwarsOZESRHLHmXOnhEkXMktS3OD0dRvSCjDP0Fw==","signatures":[{"sig":"MEUCIGJzkGaZC/2+qwjs2fw3EOZdnI+qH6yS9mH8LmEpRu+CAiEAmQ4opf8Kc04InGNHFrSXO8WzxT94UPaIFWMUrfgGZA0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeoJaECRA9TVsSAnZWagAAWGAP/3uUTrtUNok9egop/KyW\npQAYAloogsWDzSWiBYgJhN3W4YKFviUbuXjPowa/4pSzYyUol7RhfTs4HgF2\nd+SEqEA/vYL70WMXabytlFsE9Wx8kFO0I9Ykcl7e9omTaaX2jVj6cM9oTe/M\n+3WM9qrc8tUzKaDBm+ca5pvMWXi+tS3imjsX/p4up4zpcuVH0Lk3SXsZ7Tdf\nVX92LUf09TdBkOJKRb2kDjUG+4773shrqDUfgnbj7j0bBj8XUv2swaQ7Fn0F\nSTHg5j22UEn16JI3lW36YPrbeBgDKEgdFksXVXiwLlsIE2pSFn/4XAgq8r+Q\n83bjyBjwhB6hH+3XC0uLriKU1c1fB6+r8OSxQxDpZaj1P1PVkRV/R4ARvD9J\nUVK13MnAPKUnMABHkoINI7d5NUMILdciS/RNwZHc4euvdeKdVGI3UQvryYVU\nz19x66O+n36RyluAjm67ObVuXW7qOTW7jfW+faTfjL84CYOH6NV1u9iGSXWK\n5iqyxIIy6tilB/rPGs0iye+RYBgC88Ob4KG3dMWlGIB7w2PK/AJBxOPWSX+/\n32OHqYzLpj0desVthEDwE3pzVSBf5xBvok51N8CrrwcH7z9dF0DN3cTWNdur\nAQdMDfuWsaT6bWQGYnwndGcfzJrlWFPT0cVtTXqDIl8GYv+6eE5DBoPTqIs0\n8lcP\r\n=NuHd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"70a2987c59d5d8e866f0c99c7bcc189a7f904a2c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.2","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a5c42b5-1587582512965_1587582596259_0.6315911203011149","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-89f5183-1587879169541":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-89f5183-1587879169541","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-89f5183-1587879169541","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"877211ba7c4be8ad0913678f83166dc7e11de493","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-89f5183-1587879169541.tgz","fileCount":30,"integrity":"sha512-B/KqxRwhb1yNO1jpjBc2vE5HFRx98lGGCgpvk5nGMQKaAol7/Zmw7sRRjHaM0fXcRVdiOlnfmhd3y/pBt4BotQ==","signatures":[{"sig":"MEQCIDSEdxg5Fi+ahJe2RvgHNYLDxZMEHPq00Uc7owo8foNgAiB4q/6B9eUqTH6qbzQ7FtHYNoc61gKsqorrR7qyAUTYxg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepR1NCRA9TVsSAnZWagAA7QMP/Ar+6WXNQUxUuLJNMtqj\nrI9BqHEkBEuiNaCDPq3IMrxFXQfkO7Cg4WGYqNsKhi7LyZ/IJPGEi75ZsT+Z\n71ccbv+ZqFSHegf9hmq7U3fnX2Pn+Ft2z0hKERisp81avoW2bHdhWvhIS5+2\nCR8gTDC/0s4HjXo4SIMgMFNxCgNzAzIAYsu4ocy/VR4dFZfmoXneS/DFJsyZ\nSgS1+R3zpZzJQESBIbLjX/k3xpGe8+rSR6/DhyobzXdcnpApUVKYtIsmfrJJ\nnLcCuBu7nMxDj4K2RN8Bvl8/6PdKw3zOyEn24HmebA00nWEJo4g496RvCaiy\n9DaIqKSN/9ui+9fn8na4wal1Xp5YhMs1F7oGAw2e39sTQEuPHNo+FouvmJSa\nomYqrAy7w+hjSTi4tRTxpIuQwT9AeBpt9az7LS7hqzSAEcqSQrOEhWuykb0K\niNsw0zj1edRiVKSYtuU5d2s7I29Q/OFC8qV+0Mxfv0+xoGxXdw0h2o/XKbFc\nEokiiIZVeB6H9qI5IAVzkoyK2m33vD/Kj/yA7gvX0B90i7wwwYpda0JsdwI0\nG14RuIlmuvkpcCrUsGuz8cqyMUnzd1mIJ+rf8U6zTZI1BsRscgUjzyJ2TfkP\nVmh2GweDnPCF4FAbkhMsofr5PR/+erKrWYRAUVydU3ooC//NRw7EwJUvJK4v\nkd9O\r\n=/6Wx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"04101a69d36e6a7805a16451aa7dcafed6696cfe","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.2","ts-jest":"^25.4.0","typedoc":"^0.17.4","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-89f5183-1587879169541_1587879244360_0.40922934093113716","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3071526-1587921375286":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3071526-1587921375286","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3071526-1587921375286","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"885b5dd14cacd5fa81fa0a7de5443428ed9af631","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3071526-1587921375286.tgz","fileCount":30,"integrity":"sha512-gU7PLHQqG8aY/ym7Cfqo3j81uh6rGXH3tUPDdmxbualudn0JbSxZn3eLHlfERcoHpiPVRS6jDejv8X6XO6nTvQ==","signatures":[{"sig":"MEUCIDMvCG7j97iDTUWp5RNhrwIcVLgAtWJOzqN91HxeSekhAiEAumBUDzFD0mcestRIR15CRvlH5QGa6kUWSYM6MzZzXAU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepcInCRA9TVsSAnZWagAAvlkP/jmoNzTv+rYafFzAH8E0\ncYzSow9DGcGvJfgcmRBW4FXb7hVog6ezxTCemyaOa+0uwEs6YzwtoiNjHaBy\nROcWFlHTF5YtAUK56SqZRi7pSSHWLXcwttSy30Khl28UDDuglwnuBarMkRjD\nRa2Y/UAy71h3+7UtslLYw4sfoxrHRZ76UWHkPn5lbMQuXNt7tDTRXmFLtN8A\noXnWrZkl98DquEFsvY9RbifUnBGBUminecJj8ieeklvSSjDn2G/dymc+t5NX\ndEg4Udh6QF92Qoa9Qt9DaMdZiCHt2lYfrdUjghWEsAbW6c5VM6UjVriNKkrK\noeajvywDi5PGzyeA8MT3wsjVcXkQYtYfU1aQUgM+1iRlr6VwJTXN8YPCipYK\nLktvhy/Ey4q3r9Go13DaIEkdGGpej2LdWKTIMKDKs55AR1Jd9UGsaXYj2p79\nXf4lNgFRROggvDhgSdfO2Cg3uAu/oCMqjsmUlAVhXNzMK8UeNuvCdOsH5cUA\nWA7fJEBRvCZyosvhkKa318jecuBSBunZmlTEVHcpGDkUbAZApWZP9tMXRwjs\nUfclwkth6T+h67H+QP3GRcHg2hpiICfODMrEok2/fj7QMJOEl/+bOx+m/J2D\nnXBCo4SlijMM39QNYWu6F+bN1/jxb9XPmNisUIReVLCX0aC72gEofZ4x+Tcc\n/AKH\r\n=+zPl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e95419525a9ae25c4dca0bf18697b05b977f36b6","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.2","ts-jest":"^25.4.0","typedoc":"^0.17.5","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3071526-1587921375286_1587921447470_0.8261799263761009","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-499eb5f-1587949978182":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-499eb5f-1587949978182","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-499eb5f-1587949978182","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d05ead2561e54ac097e8df2dda6ee21ad2141491","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-499eb5f-1587949978182.tgz","fileCount":30,"integrity":"sha512-QyuXFo9Nr2feOUCQ2o74mbeFQ76q7K28f3RWcEZviNxkvY539KUaYphfnVZigQO0a5/v7JojiYOvr+HlZl8Z2Q==","signatures":[{"sig":"MEUCIQDwP4y7rwPaUQbbYGHYrwsAxGIInl7HqvY8KKV/gXKqDwIgBnYTVWrMXY0ThkDp5KV6XWRoQ26c3WSG0dP9PMW9dT0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepjHpCRA9TVsSAnZWagAA0zIP/1Tk6LRCDLVMZeQfP6Rh\nl7FqHDe5ma+3VmeKEzJ/HiBCUDaXiEo8k76+GR0CJD26bQu0K2XM/UxxM0O8\nnweLAirT/8IWuykzaug8Rq/LRptWTzWTzdu3OtJNg1H8Dn3lKsuwMqPCFglh\ncE7eeWLmnolNGG7CLpzPIHpEnicaJoFQheE+wXEg2qH7whPInDILNuWF3IX9\n9c//pcHK3vf4MhkJypbNDuN7Wztvu7jbhZShp4tacxxGixfXiIvPMBgXLW6B\ndJVo+LfxSGZQutRmlD/gV4sQ00I2j97+4PJDOP2tWSv2Wu1RgMbzhEr3l+jG\n8y7EZ3kc3QFRdnfCb9pvBd3TpZe+KsM4pWTxkTsP9JcYIjuCH/Bv1fx4O5Gv\n/nyrlG/DcS5RRPvEpSW5Ls8jU/Yw8Q4CtXFwNv78B0l0rIjiL7uwQcRDbs7K\nBTFGSQ3/ak4PVvt1rSjh3pOS4hkyQ3aEfAr3XwivWWE8niI3h4JoxKnekwpZ\n5XSlT7QY2IRi4OYeLlUx3zfqs4iQw0E90Dn8NPOZLkKGIcjdmDSX1a/i7kvn\nDxiDs9kWaA+aOlvEl1+kfgWu3sKN+T+hEzFp9rxgwxTxOQD1DUVIzpq5zWXJ\nxQmLTrFtDmgANs2S3ZdCXLUSqpjWuvdQzTgrfv3hAf4J8mFddumdBmm/I3w/\no7SC\r\n=TPkr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"43cb33abf2c3f7a6782ba666281ec15d5b27ee61","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.2","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-499eb5f-1587949978182_1587950056918_0.7907901910102215","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-4701cb2-1588019545936":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-4701cb2-1588019545936","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-4701cb2-1588019545936","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a1eb72aec0f57b572346e9f473697b5208bcbb9d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-4701cb2-1588019545936.tgz","fileCount":30,"integrity":"sha512-PHwCS+QSOkl3nuEfzkkXR0h+H6asFj4N9dbHkwFk+vsF0rKN+Fn9VWejjHTZHTpUYyvfkVdvd+vTE34DVtUSQA==","signatures":[{"sig":"MEQCICJh86EzkV91/KEM/EXYJYbAEE1N5FfONF1uXjAEQBAXAiA99k0K2MTKGzDoNl3uzGYk4hzymZJBOUriomP61HIMbg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJep0GvCRA9TVsSAnZWagAAUuEP/RL6PlUGZgNdnFYoN7bB\nw5+jug2/zcVWNvu0I5o0VaQb+cMDtkuOG5eHvp3bC9hYOO+Z6CyxsPAyqhTY\nE1zMiQ6dgStwYooeOLQgUs4ALBiiYZdgIFN8E/F90+hncQm4A1+aU3VRIcrj\n8GJk0X+jFM7OvsWJ8w7e6YJcUWOb0kzXY77h0UjL6PtXk0d+h4M32SqxH/En\nk3IJYDueGL+/n1/OpHMgPJwzMRVdZBvR2HD6XO0SEMQoT9zeYdsJ6CHEutky\nvW/ulnWw7WYbvie8AR3l9g6UqZhOAKKtNkMdRlHBo7pHqWklvk6libaibiRH\nt/90uzRevpFiYvXjQuohk+Gq5D5W9mLi2ErGN2uNeiFXLk/6phjNjIJMh4v9\nHF7oFeXw+RkXx9ibZKPdCp1kW6unSIsI05IssJMWddleDpJ7dOT5Olo0kK8y\nxKWWK6zQ0dWalPE+T/mdfHCGtRHEOgZgFHuxH6YKLmfd3VJHhoC0D5MfJvZh\n2ocedHaz47LMJXVvW7GKl/XjTLKfggIyFTzAG+THhd31W0/PtaYwW50GRyBz\n2d5FBmIIq0hsMTCNX1pMrKiuyTiK7C50uhSzfzoX4G3qI4V6vyRnSdNZEaYG\nibB+HZALRV14rI389rM8FCWZ6F9wrYq7eJ3bmBnmWMQiF9HzMdOc0UURu0Ds\nPN3l\r\n=jNjN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"fb518483429d9ac0b483b178934559ecc39ae642","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.4.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-4701cb2-1588019545936_1588019630683_0.016419926372466698","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-158d3b7-1588103616078":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-158d3b7-1588103616078","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-158d3b7-1588103616078","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4de282581d26a331d43dc36915989772eafe1c83","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-158d3b7-1588103616078.tgz","fileCount":30,"integrity":"sha512-72f2n16VXq4LtlrB7r8wx9LMxxWb11D2y4IR2EKBr1o2t6urDoK8pqwOgkGsDgHjmBptgZI5nw3ybprLrDNadw==","signatures":[{"sig":"MEUCIBUTLcrNns2upUA5Biuu9/Cr7Hx++R/+c+j8OD1dozZ9AiEAr3AeeBprNcjYK4IqmrqwMxq3nE2tavlUNyViIuVDIX0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqIoSCRA9TVsSAnZWagAA/dcP+waO/IA61y7qgukNQ7w7\nCyP6CeQkVTymwM3pBnBvWBBHqptO6rfcDepk18xb7C8jwOkaC5pQXVV0WwSc\n5RniaV6sS3k1ER1DJqD8i/p8scETZGc9wCtbTrOAN3wz3dJ5nvgshjTbyQpn\nRZzEGG1AmqQ+IIJkm+vreyJu6oKYfSMHRCDvxTcThcDQ0CzV7LwjlQ/Je7OV\nVJmGk7ZL86ZeVNRRngvVfKfXIy1dCcOxVrJ1WyWtlIttGpQQ2x9LmaJ1zwwP\n/NqGi28VinG7MrymO1NTVup1b0aW9onjIJ214KmOzApnA1LzbH0KgmS5ycwR\nVv6jXdzbSvQq5tVmnZsOQSEt2utMWrSIoxKBRVLRz7xET89EIVgjN3Ym6wES\nJ8JxepK9RWYr9bmT83L3Q/u/rI88fsd9/hZbt6LcS1Zqrd6DrCWInkWKJ8AP\nYnxayOvEeWBbE5lNibWg4aNdb+HZF83RJEEjREq8DmNgLLC2znJF11rPqKnj\nyTnO9C5Wnfsl8o0nnrCIR9rObWXSsvP0jlJrRVxATH3kfi4s7CkE1QBYBwBh\nq/u+vVcFfAgYPP1/uSCnt0t1TGoB/V6QlncQMRhkDvjZu8riVCNJRjBoTU2P\nw0V8rEP1UUtgK8JVbFVrdEytkdGMKYdx4538Gl14txqUNJ3RWA/py1OpJGVl\nqrwq\r\n=4Yzg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a8203dc06867316a69e76eede4183199c5892587","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.4.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-158d3b7-1588103616078_1588103697505_0.9213698899503895","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-636546b-1588104551336":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-636546b-1588104551336","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-636546b-1588104551336","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f0a01a93555f78ac08aa4666158c8c2e8406a207","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-636546b-1588104551336.tgz","fileCount":30,"integrity":"sha512-Qw/EMbJniJ4HJRU4L5l8uR69nWHGoIcxgxxxYEm7VOx+2Hp18GEQxJ3cyMoAupjg519jGpH1ZclI2Wj3/RYxGw==","signatures":[{"sig":"MEYCIQD+54rjGp2pqpEtFupXS4wJhvYNPngrlXbfKOUp0Ni0TgIhAJ37Xkf6kdnwwkdd3QNup81TNmsJcUh28cOnrb255+uW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqI2zCRA9TVsSAnZWagAAusQP/RQJ6FOly3jUGOdo3yC2\nvUSs2ZiG/aRGIgehT97j0A2eWr7J16Ry6fQ0aB0ECHci44bWmycHu2bKXiUa\nviEAro+GNBp9vio+ESUsEdZiGzFOEQjMh7SF1BfX+Ej3HrrDuEtrS5fjLd3K\nUGhZNhj1L5dHAuWmsCijsYv4XogDR9gLu8Yqlfy7PpAVM4MS55sFq0STpZs9\nj1qTnMDc0yGItoKHJjfog7LEbsyfVcMxrGYNuKKw8uen/kfJ5uJd2rxtopyq\nop0k3i1BwiRhT4ABjpmZ658dWRZn4Z0tvE+Y1b/hTDavzk/hnL66sqOVYc9A\n3+hQbAo2+p1j1l77CK+GaDilnMot9c3jaN6jJ8gfH9mL7ThQ5Ja/mI4bHvOJ\n/5UzqZ22a8M6BOTXDI7kvgXXtK8Oufhp053e+Yle9uSS4SoZ6ukGaDzEPdRv\n0LZgDijS2wLdFhYvdsY2Cs0ZeTFGWp+ZrWo/qHWlLu7nRFab12TroAhpv45Y\ngW35l551K+CpGVIxq8Zz90UfLvpVGsIteu1pSNp1c+wDkRvij+Ri7zQL9gy9\nyvnlGAg7xQWwo+NvbybbO2/9WCwPZzH2rLoQmJbFjy2UgXhDrvbxXvEvkXt+\nkBr7erUpAKv9Gy4g8Op2f/jnLzpMRPH8TYL06HHg9V/q9m3+5xdsslDw4ylD\nbzSg\r\n=D6wU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9d88402d68737478365a40343a953d5b59e256f2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-636546b-1588104551336_1588104626998_0.8998796059996392","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-993f6b0-1588166144699":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-993f6b0-1588166144699","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-993f6b0-1588166144699","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f4ce333a5d557f557f88a37b7263cbae3cbf7fe6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-993f6b0-1588166144699.tgz","fileCount":30,"integrity":"sha512-RjtWC1y/BNdfjQuGZ7Y6rPv6SatpMWucpB9ak7F1PlQWFEXaY93EjhAXKPW+lWxDa9QYfYdAuW7mpBJjTPfFEQ==","signatures":[{"sig":"MEUCIQD5oMqHTJm7cKfTO6UfZfyxMbg9g9olOJGD+PDHqzZ3FQIgMykNnQVPzRNKtTgVQZ0p+gaHfxO/jy6x5tYQjud3h8E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqX5SCRA9TVsSAnZWagAAy/MP+QGQeirkrNRwa7NLSbVd\n6hTnLhvoEzTuzIzA32nny9asDCoCk1MVO2nDiZ2dmgS1ymXQgiaKPKZdcRlS\nTF00mN3rFyAuX3s/0LMoZkoqenBfpbov60nYZ2Yuee6QAxnZKRGV2IXsvKoC\nzXafkO7yXwtA6VyFYsaggSnT1arjlYk76NnokRrGGqIxo2eNmd7QMHGVKmXd\nqVcYGYzvz8hf4uFEt5COxjrpPHmJWFWN+kT59tM4Coh4STUaUXwEwrcsTjGR\nnLJHPlrwWt8cHAA29lactUk1ktYGTLOxWDoptnuREzv5wj0hmZb3ABdRkkGU\nzZSgNGxIQFDIZ/PFV+lDHCsnoQe+pxoT0WrFIdnJTotdCdz82FbpbYCnWdwI\nOqyIayVoktxuYlHhC7sHqIk9jeFCpPz8ZSw0zUgqS+5eaEA1no2KpLM0gjKN\nJm5Y6uwnONvCJ0BN/F1BVTKjl9ZmfObYm87YU9xF+MOAyDXTUb3eOagbij79\nLR1w3KM/JiUqWB4sPESDB40aJ8dz+xUI8CVDJUGwt3tiLXv45HAQ25KmbBtM\niYVAAn7EId4rrmwLUBsbbeuxfluQR/d0F1sDkt0SSkmlZkukASXqW8tJ9b+h\nGDw+iALq9h2CRJM+HIZ4GQDaoeEoj4ZyPV6jYXqPkHcvMkJe9d3fgHIAyZyS\n2Pyd\r\n=1/ma\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7d62a3b1d07f1702af357bfd9c0fe679b322d1f7","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-993f6b0-1588166144699_1588166225848_0.034307832537380234","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0745690-1588168158764":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0745690-1588168158764","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0745690-1588168158764","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3cbd8d3061f7283ac7df511fa7b3dfca9bb06c18","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0745690-1588168158764.tgz","fileCount":30,"integrity":"sha512-EbFNb6s9DakuocUY2NB3tNuQnlX5/gZan7xOaUtV5SwecpGzr2dr0myba8sdmyLB3pWXYc4qHbxvQaOc5lf1Ag==","signatures":[{"sig":"MEYCIQD6K2icNjts+KUlPQhgwuaVMnlUhO8U/K8qDetNKxMXPwIhAJVZoVfwYBGU3s2IRXWACn3bMmIQAGqUv9kt8pNgDhN9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqYYuCRA9TVsSAnZWagAA04YP/1XKeFHlVZ5mCIXKaPzk\nfrGN+PTkhRzAQtWLcfEcQB9uPTg33YleumBFdU4DQnOWIV3tHvXgeHgZmehT\nSLZO7S/uPl+CiWWhcsc3swCpyFEh/ufkS0QgnSAUlV9PP1nb/EwTOxPYvDj8\n03IsJ6uErI3iLsvPQWrPYPi7EanXzHb+M7gu4RvDG0RFfBPgmFFnu7Wzohn4\nDcF124RBq9sZogN+JZJqTfWEMaWOZxWwAxziSP45ZPDtATk1fwIyLr1krI3w\n/JJl+Y1nCobLn9oIfjV2S4fvLp6ckCDkA9Oc3ME8Mx81H7IK5hYdVxBDmRde\nm0ZorSbXIepeVeRt8QicyiUYlJYEJkP74unpY6Vepdm7ETDwzFxDC+/8nxua\nGl8Ulh7+I4ZM7QVQ14nP7Jh51c4ZXJyTTB29MSd3FY7EtETdHbuUGFqjHinw\nxPum+9LukaviscKCdpjB5jOGY07k1N/JIhyi+zGh2b2MwGHt8VdfQD6+hdCb\nql1ucB7WctU07h83DrIKgw4fdzvfOdoQ+FIt62pldTwMH9aA+7huVa8OhRaD\n8dYz58Ul7vnr1hJVGHJxoUtFmZ9z34Wt6Ix7xUoYbjQlfZAg+H/pc+1QfM/r\nJp2CyUTlrpkfSJ77+6wXSUQTNynPqajE2V1qHT/6Rs7u9W5uY6yvhYZboF+I\nvE+E\r\n=ITA/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ed442beb40d30b5709b54709c8e7a1b419243bec","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.5","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0745690-1588168158764_1588168238254_0.7857676388827883","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a79e1f3-1588186871146":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a79e1f3-1588186871146","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a79e1f3-1588186871146","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1de88c08a64aa8d77bae88aed2597b9defa56b30","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a79e1f3-1588186871146.tgz","fileCount":30,"integrity":"sha512-KmspKXEek8ds0wACWjyGeLFQwLR8wqt/jsSnP8qcp0ta4eOwRGRlgwb+fCpiUVfClouAKbbnnmqWe4hVCUIKtQ==","signatures":[{"sig":"MEYCIQDkjQcMJmqn+CB7fRC9XhtDfT6uNCafw/vIqXC0xSWfHQIhAK1Gol6iclTc5eRD2y44JJvneFO5g1O5980lVIAO3EuM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqc9dCRA9TVsSAnZWagAAQTwP/imTytFLrWvnZJ4XrEkP\nClMupeXrdcYpJb6Jk40Yu4K5L11QagxydImbAOCSdM1Uh7h/9brPn9PzPAwg\nYHEZGUZoEMyRGGyI42Bu9ASEg7jY6LQrgSYl+wPm5W8B75rdGqxJ3RGuv1I8\ng2zbR35o3zSh277auRPoVOLGP6d9SnYDI4oVgPBFcZNPGo2NVcr50fPqh6yQ\nkBnix10kPRHAMuMlrql9k9USlxdcom8oImMVz3s5Tfsgp5kHqwaYPj0WZUV+\nKlaPikelamnOHzb6qFn9BhR4ZXS1wmseuHMIe5kCOkVReKOscXpvYkeFQcn6\nyyxb/nJLkqabJR3C3WzBdLuh9vw/oUMxOI3RjBLVh8l0LFVtPEz/1mRwFsZk\nKCWGYiUfy3b6WqgMLeNcvCypXDkrZZMpukQq+TVKMybT732DNqm3XOl8rZmq\n6LEhqfR0taz1WGdh8rqVwUmlu51gXdSNi5vRl3v+ig3CUMhWoxR1HTxSM6vv\n47uSPOAlA/UyZ+w+eEKhxViDuBoPVkFLzycRXdiq+VdSGcLNwFoH1kNGJhMn\nHoLUrtLqLaSi4hkU2MqJOxF2Aoffnw6eHeepc/5vJkJa5/c5IhgEmyxYJ51n\nfNB6yf+BECpOoC/mwGcEHDHycwvFYtpqCSJ3SV4DIEV5nMiLAACiTuRwQqZy\nRzXe\r\n=pTSc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6feaae61c7182b2a45cd7e38f65aed583fd8c6fd","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a79e1f3-1588186871146_1588186973159_0.003874037927995122","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f5c6b90-1588187508003":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f5c6b90-1588187508003","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f5c6b90-1588187508003","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"13f1536b5bd866b4d1542acfb14779f4ab36c6f8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f5c6b90-1588187508003.tgz","fileCount":30,"integrity":"sha512-7MXjvloknPVykfITp+bmu4lpnaFYRajg4LE+skzoopyrYW09qgU5EHStR2AZTgfUjOP2sHEGFfBBaxfo6w0mDg==","signatures":[{"sig":"MEQCICp0nlsgpjr6rqcN2183lQUbQYPVpINZrPhDv6YBDac4AiB+81JR0Fw+TgpydR7KCf/gCrFyGcXh/4aXVyQb8cCi9w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqdHBCRA9TVsSAnZWagAAe8QP/3A3VB/LI7aQad8Z9/TP\nIbw7zLwZvcNWbytw1HJurN2AZ+1l3WpLV2X3KdkHQJ1p5y5WBUwRLed71Z6X\nGcTGKFyg1OcYxadhhfkMelvf8eFcPAepdOPqM7rIRyLhdjuR7ELzLqP1mAnC\nXnUuJM4wpE8C/KcZr1bZdx/RbXmXOap6M/9GQy5z/KtaT6IeoW4TwQt7zyH+\nwLwq/Vfvluw8MWqeNHr8hQeJR4raUPhjqQodBR9NiOrrTMlnsT1QuEu+ykko\npy6lIkFN3cj9fmMNubc24AsWOgsDw3a1h0Q8KujkY224iDMOP+nDV5Wzt0dU\nBIMrReXnZFqtfgCI8i8hoaiV2vOElb1f2dp3phWyCCxrJITCdcGuE/OgPged\nW1sq8qtK04fyI2H0EfUcyDeMpIMrQt0bAaRL0+fWx+iQQm4Fe1LdHNlDdXxi\ndd0vxFwLQzDeQxl6Ef13GzVofyLViOfyFo8M8oSjqj1dwVNpXg7duZyf+6Sv\nVfsr36rDcoDFAe2Il2P8TD8Cj6C35KiNCyL5HlNFtSR1eaSYJYRoLYcx7L1H\norj7lt/cMa0HSqj0MGZvyjdx/NqLJP/7rBT3R7eZGEMUWw6ZIHi30Kbd99lD\njzN7lTnn4hH4j7crrmfc5jhrbdDjPHxdmIVa4QVItBLfKulmdK4aCLFV7BwA\n1j84\r\n=3KmB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"dbe02d5ae2660fbd0d5ea2183345ab188fb157fb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.3","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f5c6b90-1588187508003_1588187584810_0.07364377233562291","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-d07c5ae-1588188712635":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-d07c5ae-1588188712635","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-d07c5ae-1588188712635","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"93223a8120b5aa4e024828802a9646d8901b1ea1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-d07c5ae-1588188712635.tgz","fileCount":30,"integrity":"sha512-PbfepKRlqea7yM1F4UfhyIud0s78rrWc+0sRjEL9Gh2xR66MLWUhThQx+U4zQKcdE/tsN5QvyBKucZHWgrj6Aw==","signatures":[{"sig":"MEUCIETopLYPv+m+FGKMKSljr7LEy85mvo70Z2MPkamj4ohWAiEAzLQeCJphSWMUenAYEvKdOh01WKbtPoZ4rhAxOyj2XAo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqdZxCRA9TVsSAnZWagAAdPUP/1nDgU8ayhRveY9ZY6Vz\ntKMaJ9ZIIgrYmycPAVSajn40+o7zL4KQJoPLgJRy1rbOe8axvYRLwDOO6iN6\nLs3VwQxErsyI1u6SlpjFYf/5Fksv4O23yu2VPcRGC9GCBYigK3Y+k6mqiflF\ndqOgZxoTMOn6c/Z4htk1poNlkRn9JkIqPYt7OiD3kKbzTqJe9XVCQCM2HPbP\n/1DVUT3FYz3ysVmAYfGx7h+Ny2yWhf/rNdh+VC6A8YZfxLsCXrSZCLLUvVs7\nOkoQ8QAF0OH5owKv97ABBfH/icAOtKunmLN47+wOJ47HWayFzB5BcEoXyFgD\nQHNDINGZ4Pomaooy4Rz95O68xQVcr6+vIj+ZuizBCbIsgk6d0RMoEpv4Jc9O\nhFjinyuW9lmjazoBpfOEFvEo0chRikiG0wOBVKX4L1UJOmrul6QpAnAY2l9i\nI9uWk97mtWqQQiWMGcLHi4lTf5snOaU6Hpe4ehQnCzBktU2JqgArob6c90C0\ni45cDcXXN5a0i8SMIGsLoqd0IlDuebjMTVJYui1gVu7dW4ZmS4W08+vqwztn\ngvnP2f1TMCcEG1fowvaS7XXEQGOkuyxcV4W5+EmaimjlMlF4QXaB5uLghIkN\nw0e6y4Wau1A5eeHBFFKbIQeTX9lu9NSpftgu4aJzquQvVVXrzDqBKIro0Owf\nesRf\r\n=jQyx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1bdc48c1f190bc7d315efa2518e649b2473437a5","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.4","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-d07c5ae-1588188712635_1588188785099_0.5555729594035566","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9f154c9-1588191427373":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9f154c9-1588191427373","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9f154c9-1588191427373","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c67c2c789fb0892dd4b4c4f60b2f7ee813182a46","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9f154c9-1588191427373.tgz","fileCount":30,"integrity":"sha512-PeUJxOWLyjUtQwDlOOuO0j143NSICeQjybErRmrQmpD5dzAvFZ7F29BUfuRPnvCzQTfGJeY58YKW44rQLBHPkQ==","signatures":[{"sig":"MEUCICFexd5Dstl+bgb5KWw2mqFWqLXwV3gwuKPvyWhjnSNsAiEA/kpq74kUlilIzv+2ivGj9P3L3dOSYBOim4Pt6hm2xH0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqeEWCRA9TVsSAnZWagAAo6AQAJjDsRrEjNvzhsHGEN/1\n07natRIqULAZlCHRprKd3QtjV4oW6Vs0KuwEUHqGv6ioQiGLhdYFHa5MDXak\nJvnIvUKvGO642wXZCiD4WYRd8R4JhsYEWfV2N3tUlKjYjcU7X2nCFLpWIsK5\nonDgQ+cRZ7WcRDBlqtn5Mj2/5bjuw2eCk0k/oKP/Yqx1bBO4rPZ5LCGiDwM6\n8TwVzWOQZ2Pff02wGcTGjpuload5Lo0bpoQLDxRszrpUEf5h9ZeunNexVY/L\nMJLzuRzfogXT8t8k5XyTzmhvvEtwt2ir1UIl6MTcezOBDS1CilG7VV3MuHHT\nzkcPdNNyCaUVwd+HTU2Ylup9HXwwzf2Gv/RPOB6vw/U/vH2JkTwY5Gx6qWJK\nzl81hMDvH0BaO7CBA14HK09jjWmywVFGd2tBYMAALx1Ow64A4yXGH40cPm//\nTkyXF7X2tMg7uN7B52EqxwvM3QxECOoddzG2XE+NQotE1jnlo2SFPKRrD3dA\nfPDleXHDMIFiD/7ErzbB8S7GTVYChMDxz3amtSIjRorZ2OKtTay6KNfvn3dH\nkpSr9gDwAb0hwhKGu/GbUXHD6MT/y07cb9lGzJyojXEQHj88oIWKugCtyqIG\nQyV49YZv+JuH3ltxJKZm+GSSRCvVJLWDKw8e2uAVlNlnHy0GUaUpK8f93tfK\nO3T3\r\n=XAUH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6c19c34b6325d8e6e4fbe4870d17a6b2378e6c53","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.5","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9f154c9-1588191427373_1588191510033_0.7388789187129796","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3de0e47-1588199358898":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3de0e47-1588199358898","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3de0e47-1588199358898","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a1d275c9e23e175ac452dc0c979be9f7591ce24a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3de0e47-1588199358898.tgz","fileCount":30,"integrity":"sha512-ScX2gd1Dxu3eEEL4ibLlfyHXz7Gr4gVkmnLdrUYoS8kFZkZXfXA/eKPHYFBBMihUWJ3CEa9Mp/VRccwDYETRQw==","signatures":[{"sig":"MEQCIG3FMNNkufPVy0nGe7ZBPkIkBM6EqgxagCcOSfpsQv4KAiA1j4F+98bsGF4bOwJVV16ejRBTVSAMSBXl/DYr1BMZAw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqgAKCRA9TVsSAnZWagAAoesP/04R5xMUmnIZBZ5Q2F4w\nwurKsjwHtJR2ZdQu5+e2xlAt6o9Tbk3nABLydcZXeZHG8PmBopJ5h9pEW5NQ\nlGOT77KOiZCY6xTV6w+sVBLtMGq9z4hITewKOzLZppKL+56w02l5GTi6G080\nz5okkEdt7QPYuIFtQEPc73XPkHLFleOvZ6OPyFv+Y2dsaTcc8ep949Gks8VC\nKqJsHk6xQ7kFUsSqKte+i3zXNpYALhF9QySkBuaUYNRvUZg+VLgZDUPUlji8\neoxtDypFUX9de4S/Bx3zqxyC9PzMUaul53cS6es9nbo3y/UidHsY63eY9sYU\ntHHVmrMQAOXZZrMtRKBSRv50HOLL9Yf6Pl6uiSbOt840P+50gfrkAJwMLE46\nxYXyRImNHcfHmXzTeXzvE6neHBxT+bljuXXUD2QUQdavjv1suOLd9NpotDBj\nk9XZ6ErqnOPozIz7IEcbU8hl2aWHkM5EzUEDxWQLaNVlIClU6V/AFYyQjpqw\nx48dLFIKYlRzrcMB33O0096CaVoAvINIY1TqvPXtyYhRDT+frdZ5UXV4fKEh\na01l8HKEDcBLlkHwJyvMg/4fFGE49LT29xI90qxiviw+Wo601CzX4/B+vQze\nbtNlxE3anJt19QqhJoPwXy0JHD0+mLLxyFAlqzo6Lp21djkflhSfwOOEKE0D\nIK1s\r\n=sMl7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f377092b32c87cce1bd8e04c538d371633ad3534","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.5","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3de0e47-1588199358898_1588199433884_0.19264571753607762","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-c866fb3-1588273269619":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-c866fb3-1588273269619","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-c866fb3-1588273269619","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"50c1098dc6e07a2cab08ff228b6c370332e1ebaa","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-c866fb3-1588273269619.tgz","fileCount":30,"integrity":"sha512-0EruLWT6VUnFNbd4VHhACTJWhNq6+LxLHNyhlOxkmUdU8B4Zlx+Uzv4BQcch9SUzsm3OK11g3yw8WdQF6WZKWQ==","signatures":[{"sig":"MEYCIQDRL4wsuDoeWjb1hQLtb+f1n59l1TYTdNEH1JeM/dx65QIhAJSS1um1una0Z07PAtnzuRbG6FYBW5N9rmkZ1+iOGMw1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqyDMCRA9TVsSAnZWagAA6nMP/1GvKboAR8Ask/FeSpVb\nrrNXKdyazEmQmtqwTlkR+VfevE09S6AtdLgaP+1vU6Jk/AVRSlup0HRXuipU\n/b3ETsTnVL9/Yp29g6F4zbwYQam3QFZbgXGHejRSYmPKYIQhtAuBZ9DC/sNl\nX0yd6K+LQMsILHSJhB7MfmS8nwiqcYZ4P8c1JYBM1Bij36K5l4ELGkj5oDmQ\nnC/usx3UVaH4VPtp9QJGEzjxNE/q2f3AygDnj+HZnKJnga96lQ55cUG5Nbb5\ngPtvWomJKd/fzBUV0bgPKEijdWrqQjWzrOve/3v+ArV0JGpqvG8NpSxDM5O7\ntGirf9iIDFuhVaYG0/lx11Ftljo2ifzGWXWTXZC8ahjIQlFlUpakj6UlLbvd\n7vDRKZv2ktIKnQyMlCG1qPVC0MYYLAJFQ/5Bg9PUmpMvWFl5kf8KCnpvUJlH\nJc0GtTUY/vMJ63yfCMl34b73oeNk7O5ayYTj28zhAtKwnYKIji+fWTntJ75V\nxNve3saaE67GU9c7AYCLu43ugRLAFNkMOsa8KFQrBRS/MgAtjI1VdcPXiHSo\n30z/9a91flYHEKo5z/gv32y0CdN6BDUyhDsQoS/XeO0cr24vVP1qBIgKOrcC\n549BySamahmRxtL+xvtNfg0lQKWC0sxyrxKkM5EcyakolHQnmySqXWbBE69f\nfUoe\r\n=BrKa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"53ba89522e336264568b82daac9fa13d4edae7e9","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-c866fb3-1588273269619_1588273356276_0.8787733620402041","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-5d419d0-1588285226250":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-5d419d0-1588285226250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-5d419d0-1588285226250","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dc689edc20db543d3f92ca0b4ea67a1b29979501","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-5d419d0-1588285226250.tgz","fileCount":30,"integrity":"sha512-BGJPqqpxLQwqRV4Tzt4hyJbUrbCmMbJ8uK7Rd8d9xiL/7oaK0txayvxlRqcxM+9gPamcNG65iYBPTW1wJOmZjQ==","signatures":[{"sig":"MEUCIAIvbV5KWSj3n1tOgIatfY73RSDNVMrhEgslMX2byy0lAiEAtsIys2H6qSH0TEsWcD1mx6avsWmhVNVu8pNnE1+N9rc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeq092CRA9TVsSAnZWagAAT5EP/jF1vcOUEeF34Pkl6+iX\nAad70HrXNL8cjk+4YlxnW5qauyo6as4a3ANPA7jKZAe2UiaHhzVi01xrG2Dx\nSSAnb2GSf6rVV2HILXbt37n4YNb/OJxLN7RfqH9XyYL4B1fAvSUrFxDP5VmA\nucfJJQrnVkSVsdGxegAtdDfnMoEJdfstrC9hl/TWOB+2CHzPpzsYgFkuYgQP\ntKGtVqXi3w5QD22beQTMBL/ItYLpI48AM6KrOJfcgw92pAzNm/rucOgpfAC+\n9uJwrfDCWUSN2hjCDPNntMrt4F5Clfa5YjcZKS08qUH2HqNsS1PENBO/LzPp\nfFXibHX444luLyha/HKTFmA9q2iG1Ki1EzyigMvYRAh9Nm77lWSTuqlQAAKF\n6aFd/H06t1f+yz0gW8isfXMRRzH7gSSvwe8PHAapG3XUXcUhcENrI6OSONWi\nEEMfEYD6RttaE66m1rcV94sBhqoLrS9ic1l/WjpRS3j6WcA3LLZRxbX6TsKn\ndNFQALQi/RrGFb9XtJjXaEd1EgXh2H7RZB/YEeFmWMN9H1n7Ti9aN2XKl6Mr\nhTRFfcmzmd1Mhhx0IPP8KmZP6l5zGOIMjtJysWlzHbLmE7XjaaJFXEqxzFro\nPqzZrbPQkDyJhkBk5QtnXExheHEvHHBIPb9EVKy4HRangod53ZCAJBZaiLau\n+EAc\r\n=8/J7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"04a9bb7f9b3e94b9a7f472817a01bdeee06a998b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-5d419d0-1588285226250_1588285302279_0.7178280455526831","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-2d14a03-1588407908612":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-2d14a03-1588407908612","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-2d14a03-1588407908612","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a36f9bec69c4bdf4ab43b09afe67ab0fcb1326e4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-2d14a03-1588407908612.tgz","fileCount":30,"integrity":"sha512-UsmNEQgWt10MyhAfl8w5NJ/n8Odeh0CkfTAzikwsopy7eOsw69x2q8NGJKHqcOMJO6yxqjxXL9l9gS4Ty6n3YQ==","signatures":[{"sig":"MEYCIQD9ifOZ0HGZCl5NvFnBk9x4ps5i2UOgeIo/QVUl6bRgDgIhAKni6WrkLO6TaewbrK8pmKfBoln8cn4bMrTndjd19hqp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJerS6yCRA9TVsSAnZWagAAN/8P/2lf7bP47LJWJ5+LIEJ9\nGRiChmYXqPxT7DNsUfli0jbicZVEC+G4e39q7S3Sczdb4Xy9I9Pj/lQ9mB/K\nQf+d0vM9SyFTmXtkYQngeBVSZK1QYIycD2nV4i30TfSE9DWDW3Wc2K7ft5Ov\nfoDSkkJcJFRqDWOzZRftXARwCL3FPNZ8dheVZdRzAbI1vfwyt1BF6jj2NxPs\n/CmqpBMIlRzD/q9X+Fjb2JbUSQ/TGMCf2J7MIanpIv0VdlvVw2frQyrZy7+d\nrwmJfGZFy334ZUnAl0CEM8cR32tyXszm5/3DFbDllRU/PQcnBke9QgA7jqJQ\nI6zHbTXB2fq1QavFTlR8JmnZD6B7AZkBdydrzP719gEemWHHQ9C9jvXouFl4\nhk8eZf5YTODTcixkvih0IXCCkpKC4SlOHwQxROqIia0UEfruSTHgM5mmkHBj\nHtfEauBlU17Y96D2++Th0ilN0xeOAmS3exqcvNpv4QrYF1xj8v4iwTSYDqi9\nYdfKZoMyuF6mj1ZUev+6To46iq8Qon/gdtyy0nPDo9q6h2hxSrKuULNwUGnK\n3539s6obrE/xYHAFGoXdvNeIdh7+laJUev6CdKZI9E8/osFxEOrgW9YwfW4r\n66o13LxgokJnsB3pzPP1WDJ/UWdrp3/s5L2Evab27O4aNRybNwgLMyByVj7f\nYEum\r\n=MNaY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"13a182c56be4771f7ab8743dae3ea486acfb8fbb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^25.5.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-2d14a03-1588407908612_1588407985683_0.14130946969260894","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9579a72-1588629511435":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9579a72-1588629511435","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9579a72-1588629511435","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"778e6292bd7ffe486d3acb0ffba0a56e07379b55","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9579a72-1588629511435.tgz","fileCount":30,"integrity":"sha512-hbNQv6GBJweLHkNaBZtl7nmCNh2xwh9lg9dbjPJIYNwdEc5dxRt7UALq9aXsL+Zbl9EyubpY8PzZ/LjzQpQE+A==","signatures":[{"sig":"MEYCIQCTDEJQpr8t5B2nuS9YaW0V6+/7FsiGCEFL+VFIX7aqagIhALc+9fkcueqNctIsub+KPodafrdVHjmu7fwosAMnl6EI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesJBWCRA9TVsSAnZWagAAvq8P/RFiacTTtlYiH2IhtIQA\n1LMkFec4FjH+c+Qjy5P16CtxuWxKjProcXqPffDRNCK7Cs/O2Pd1gMofpbVu\nTnL1/gLl6EKxMd4Sn/eAP/EKTb79rSGlJSSc7tpybyR7Dg+DTbTcrjSZW2a7\ngfgLekiZb9z+rBW1ps3IJRtVfrF8TqMv1pJcIBsrbTTMcHEaB49DgkOa2z8W\nBtQT/tsovRBxrzUbVhneQ7Dbmtvhhqpq6ydemWnUY1k+1QIqUg0YoQzIdTOC\n0jKi+EDgW/y8hdegUr65Wa1Wza8U+MrWoVTH5lCC7+kYfRuj8OG47KCYUX48\nAX/4uRaYyHUR1LRsO1ge/XScM+Hl9TOf857kxBjM4RIg4EAwXYSCh7cHf/ap\nvFgcaQElow/P8MxTJlyWFbzw7/LuC6YiyA03gBRhNYOMoqMGBcpvw1/KXi2c\nZg9kDXk9hIWleyIh/kXrj5f/Mj+1hY2JQb/LeYBCJRXFptb6FiS9Q8LEf8EA\nTc10pmvEQFkcIUCNb5M0aNOHRBhMD2wffg0LxV/YphL4rTTGUHimmNFHIbSm\nL2LRKGzHkD4PJ99dSsib6F/wBBxulfAuqNlRYQ6FavNkKBMXThNOQdMSReBF\nQ6pw9dhA/arIzQSxhC5IyBgvbuK9157Mig/fe5D0+UwhoRvuXVK5/IBwTtbe\nufRG\r\n=R+Th\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"527f191869cff8ca92fca57ef7ffa39fec2d5584","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^26.0.0","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9579a72-1588629511435_1588629589926_0.18186124055896324","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8f35144-1588689904843":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8f35144-1588689904843","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8f35144-1588689904843","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c5b9da5c1c9580f9abf3d991e64617e304a52bfd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8f35144-1588689904843.tgz","fileCount":30,"integrity":"sha512-HN1G1Id5SPsdWtRKBZOVRpw0ky69StDxgCCTfim+IaBMJ1WkTc3gDmmc02r56BxrApTTNb4jQtlyWLJxEw3NYQ==","signatures":[{"sig":"MEYCIQCRykopzIVU2wQ0AN2DcPQSgx40gEDZXi8KkSgQjej8CgIhAOxx8oZYCwZ5h0WbcnCvbcO/mcLbMhaEkfeK5/sYoyP/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesXxCCRA9TVsSAnZWagAA73QP/RF/NtJVnzFwiaUaCYYE\nr2AJJFy3Al6jNV7ez83yUvLKvKmrZm5zMylroXPjit/cn8UOKD22h/scInkn\n73AS5jpxvY40LgGvvR1NUT4oyAMdJVUl/9n4dXx4e5mZT+qMWu7PTnzWFZFG\nJTNCVtCdPMfn1YpDuHljfDr1J1mH/in/45Xtx9fLX4rRWR02MGnTx3gPz31w\nPEW1Ce3JnwBleZ8L8ZAJ+xWJYiuJQHbBq9ZJbCGhuOZzYawTHWchKVF8P8Cz\ns5mZecgL1caifm6YJ5fb5YCUasnlA9fG3y5VdMxluYOZZb1d40dPUf4qrr4S\nqK0tv56VgLhFOfbmKTcrjAHksAjqy+koeS4r7XFpkObs0IWiANITkX+AQp5T\nYf7k0UJ7DHSPVX+rs/gIpHtwNiFEkImxg8AgaULL1am63LhU5zM/V0UD1kc+\n/liy6JHMxnPLoCr4jOJNIDYhwl7cJNqLujL5IZ2d9+W9p3X5FPZclLmWzM5s\nkSQbMP5+j/E7qp17aQvNN9blC055mziQDe2wkiX6qw0Kg/r2B7PCFgTELOzX\nGL/vLfXLYpizyvbI0VRJJPYN1VY0oOYAJIcNuBjtdD+dkPNynDqXkKpmoJmq\nGDMXo+rSxWrWEN0c3ZXvzHArelMbxwy2F7biAT3NZJbRcaXDyYvsDxkpfTMv\nwwYB\r\n=V+yV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ef041ca81236032af95f551ba0b3a3894d5e2d75","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8f35144-1588689904843_1588689985727_0.6947463393648394","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-edfe6a5-1588722130828":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-edfe6a5-1588722130828","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-edfe6a5-1588722130828","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cb1fc218b60a6e3d3830abe8b0f66a9da55cdcc5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-edfe6a5-1588722130828.tgz","fileCount":30,"integrity":"sha512-Jxe5Uzt4g1kMtglpVvEXUCaXIHG1SdzMWXkZdOHn8wCl4DFaviAr4+m/W2VnMugeazw7gQHIODYw/qaFWEz9Ug==","signatures":[{"sig":"MEUCIBhGuQsSwIh5PrMV8MfQbFvyXjbMkoGnD5DCT8Tdjj0yAiEAmXY23iyG95yToU8QyHrJFtGef/lA6gGxQLxhp6y+xb4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesfopCRA9TVsSAnZWagAAuk8P/3E03EbBzaftXhKa9lJS\nxtEkFDOn4v2iWmHBHS7fpJ1TQdtyPu0i9e3srvSJe6eqi7I1R4C0qT5+1Lid\nduDdVd7PVNnKY0Lxbrkb1U7T5dq7G6VeLYs56TKu8xRmtcHHkS1SN0hKAZ0b\nOFDCXEHLzSiBXzGAY0jHHzeFgYW8IPzrwGichc3lJsWNjHf6qHQxEuI8iwmo\n8L9X4rVxqvxvxjx0GtS0FDdxotTTsrkD05J3zj6lwb6Z9vGvXdTC+uFK9C+G\nMic2oZUsNOgaOQWmzToIRnKEL94U39Ky4jaRvaZrXAIRkGxmRz4Vpp0/ajwz\nY6A0Mp3hbTEMk/oKt5Ktf0O1iJmeGrYlMl2gQqX9sZRizMtNlPbmGYjM3Q1P\nVWwn65NtK1PdMDafA9ZO//dlSs2F8DZC7n+Rgr5ICnhFMqjhK3ajEr5xNZYO\nbHbWDhrOThfALjT3W8VDTtbP4XL7VaXKD3r+Vge+ctrG59fbBXYLdSotLv8E\nGOKB0u5NDoNn+yXxjxey7kx2qDbYM2fyc9MQUZ6HqsqaUdzjYnlSa0l+v62K\nVffy18P+PQwTwaRkGTOxZkWubqORy97hOTWQsbvBHkIvmMPb69yIRzhWEc57\nBIoKYIda1ewz4C9+sIzg3X9ewZw9UX4or3DMdV3Tn52YXYpcmwF/CN/QIYC+\nnR48\r\n=o8Fl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9532b5d10b0a2e9976a5236b02488240005dd66d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.7.6","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-edfe6a5-1588722130828_1588722217290_0.44379504004991643","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-915c5fd-1588756377129":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-915c5fd-1588756377129","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-915c5fd-1588756377129","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"05805afcce8d70f492f7828c59211cdfdd62b283","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-915c5fd-1588756377129.tgz","fileCount":30,"integrity":"sha512-57ylWE7SP4nao9fq32ontireth7DSYvgZLcwCngVOMoMh1LcM1VCbRkd33xYfFZ2JHHQvofw43AWjmmp6pUYVw==","signatures":[{"sig":"MEYCIQDKU9kYM4nR/HKOD475bscXahv5xhI9YndNSTbvcZhJ+AIhAOE+XBBaja5drK5MMWHGIF39ggBtHSRObfdDRAB5kBRb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesn/xCRA9TVsSAnZWagAA8NcQAJHi1DbyvIsFR2+ZJjdL\nUsgrzPOogqOYNAsSGGchU0lQCYqS7+zfer3cWEEpCj6GzqlIKDtf7GVi73gS\n/NVZBQGFaMeU9NhaXVY3KMtcp9D1DtjvKXtZfVK6u1hirNm164QurLucM80U\ngbx9BuHSj0/Sjgu33f7QOtna6mwfjM/LkF3Tx8yyDWI/ewOqiju9xmQYAdu/\nw4iHndGz6uFN2ZNKVq7tP7yA4bogBqzC3tnQXySjb9tkoDPye62hfLxi3u+4\nnfCW2/l4X8dr8W3jBjE1AOhzZV+pSLxBmuRoy709s+/HQSXowqLeEXKp+qe/\ndnwQ/voGziDqmTYFmw3TL4+FWRINO/TTNipDmbkGYWqX3dzSA8BEwjuYL5/6\noT+/O1pVwrV0Y/Lekh90sUNk1USDzEERphDsRNAgHAwn5qrdWQdJRPloyttH\nHwh6T7glMNwnuwHjE4Zh9x5cvcsCECSQ2yxJcdfST22HA2foOFXMNm2BMB90\nZq2GqDZ/UreqBWXo2+fSJb4xlaQY7c7A663QwE6FUrEUdqvoP5pS3e5+cB/3\nKZ+gweqXz6aQ04qcgbGWkUX0U6mOPy5+1cMfeEwmSVDvi8UnNep5VHwKkmZt\nHO4J+o4RExrznlwqsrnfy6xlgN0zyn5fudIUhDGX113HzIt7xaj/YTWWY8MZ\ncMJ1\r\n=ZH6/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"20e218da2ed5fc96cdb4bdc92ccc0aec2f5fb829","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.8.0","ts-jest":"^25.4.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-915c5fd-1588756377129_1588756464823_0.03854134044794644","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-cc637ab-1588769963663":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-cc637ab-1588769963663","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-cc637ab-1588769963663","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7d39b582150ce69262fde8daf1c78711ea984b48","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-cc637ab-1588769963663.tgz","fileCount":30,"integrity":"sha512-3RU0j7yyK3A5fHuPJRQfLLttLFJ9ADWcHFjpOpDbGrgOb773SljhH5W6D6+Xaq/cdmZGHow6AuO1ITikRhSyJA==","signatures":[{"sig":"MEQCIBtGWNSaNLRMpQlSBgrVMWNs3GiwWYu0swYzfK4VJA4BAiB1udDBKW6ewCPDObnyXqKvYV0UwV0MzC/rvZ+pqWD3+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesrT7CRA9TVsSAnZWagAAsvMQAJmrMx4cQdX8UR/dfkW5\ncuKT8kqUw8MX3ZZtJm1Eo/LMrsUdK4F+uA/6j4jTKG2Ospj7b3JakB30guH0\n3VZmJK8uykcQkclz0oVxMbf31vNatJ2I+V53L7jRgscBliJZvtA+g0WCf6OX\ntG+RGuR08lrYvDlu4A0xMBT9TgSFOOQ1jPXjivUs2RE4GRnJozPhOrbfb4ji\nmn3pq8N0FIdeF8iioYVmQS6p4jcLY56vEWJZ5z5fYHttny9cCYEO/4KIYjLK\njIquzZPBjvq9JdeAgT1GRQoI7h0XQozlRw8SMrW2uIl5HmaNz9HOn71eSWJ6\nAmqWH0cHmoch7kpd6aOJMewYIO4GGwpZXnquxfcG02aJ1hM+OAkFX+gihbie\nzgSZXu+8nQUZ/X5bq7dVPzm8andp5baDkE95gPNCWJ2GUJCzPKsA73Q3AJxr\nBN+UPB+ds1umJf1Urk5tPyvyz5HBbdodTzr7VEdaNq+USBWhDi985VWyxxvW\nwUhky4H3WnuupQwVZUBJ+piPznIgWnF4r+J1ubjqx/hmM9ObPtl+/TNhd14m\n/cl7HoJXN9I3mGDxgw7sJBx8+Kk0I6D1g0hMUHzeLDODGK1JylqMSgLTzgO8\nb1hpCYq1xPjZUX2acokjf/NiOH+4jujtsHPP9BwWBJAGsoiOPWiOZMjRQ0Ak\n2lUk\r\n=tmeV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4ce6b7fecedc8a6a98abfcf6cfe255e3d9a75817","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.8.0","ts-jest":"^25.5.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-cc637ab-1588769963663_1588770043097_0.48174272595519296","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-dbbb825-1588831937318":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-dbbb825-1588831937318","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-dbbb825-1588831937318","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c89c401023d8236263ed556affabd66cdf8222c9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-dbbb825-1588831937318.tgz","fileCount":30,"integrity":"sha512-uhCp50TjN/QkzrJO2lBpL45TKkU+MHZwMYo4OKIrrlC00crUqlu/m3IXYUzHtXTU0THJQu0v9dJsxfQ1UN/r4g==","signatures":[{"sig":"MEQCIA2MPoqRU8umANZNWqkA74qJMS79e1STv9L7KdNPSEsEAiAqhQQuMZi50HH3aWBjb+og/Nm5dzS37QHLLsdQPC4THw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJes6cVCRA9TVsSAnZWagAAh8QP/iBw0dNEUT02Ay+sJEZF\n7mRkUO4DNszjLg84Wkdpp3ClZwnkCxv/Pl5t9scJC3m/KSiKbhIvFkQWLjDP\nk1+ldEGZbXYscKJs3yn44NpRgMmq8KB1q9LHyETs+Rj9OYdQXW4w93yHGN7f\nl+8DdIku+X+j5Aejs6uSbTC+Mrw97LOon9NmhqGw0sMGPjL0DLY4Hmbdw8IQ\nO01BNMG5qIrSgkVwMqAAdDUXruHKuNKk71pOYfNfaCFJIx9xBo0sO1ArPcPf\nhDgpp86jtbw0cmzOJUr9ZkZ1c9VTHgOH6aKC4aPpXCidax8UISrU2KMWH8Cv\nqEAsadZGQs07E3W1Bqtd4DTgZ0Ke5nO6yem/3QRto8ZF70WpNyJIO1CZKb2I\nqxnznz1xQJIfr754/1dQ1/h6Mb9bO1mAcgGvjHkhEqCeJ570BffGsXBlybiR\n+lS8vG/Xn+6nuE1rAINq05QBdaPhjnb/wKJGmBjoFIeR29mHv0pUqAVVyyba\nw9h/WjmO1FB22pfrAheQh8KZx4LOo0JvpvcwesFKTAOXWf7ekqFyRDnGqU58\noot7Trj9ngVZ5ihtbyTdSWCss1rLHg+kHbnidjnpdZf4iXMgrsVF4w+sAlX4\ny3vRFJOgu355NPmNKPsmFFtg25G8tLsV9mYqUdL7set8Lb6Qvl34bymvMLZb\nqDHD\r\n=Yf5o\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2d0632d926adf630e74113fb6d77150d60527b7b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.8.1","ts-jest":"^25.5.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-dbbb825-1588831937318_1588832020504_0.0572174507534724","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-89810ee-1588853070676":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-89810ee-1588853070676","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-89810ee-1588853070676","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0a158934c3f34568cd0006b336423f8b471f49d9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-89810ee-1588853070676.tgz","fileCount":30,"integrity":"sha512-IMMHMCIiveshX1nUfc/Sx+QUpuUyTyeCFjOQdgOyAn+FHfLT+35qUVu0CExmWgAtJyxKakGDPiK2/NJcJ3xdEQ==","signatures":[{"sig":"MEUCIDZjYbDiOWHR1OoUSEIflrOrLVaHobpzd6/+03+SObtzAiEAuWq143xNXbPpzGhSrdMt+/cVqmSbx4qp1bNR6aDWj6E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJes/mXCRA9TVsSAnZWagAALisP/1YkUsvbl6AQXgpHx/xh\nRUyyDflAi55C4bpwnqX5n6/+vEM/kyjOAT4DCvLU1ROFnjzXoE5OwpUstd9+\nd600NcOi9Q3eg59xi0Xifha2EBJIPAqFZAR0Q7DuhDgySR9u6YBgLl9Gc1k+\no3FxwnvJwSo/kL3PLe9pJrscp+bqJX2aFgPkbpZ5KC/1snkDprVWDV3ED/gR\nIN83RS5JAp9wtuvErbFCNmK2AhvEDPXIvrAPLJ59LuVZPvRXRTM1Vv9y8khA\nyi+gZ/cx5pjFbKayVeMWQQOp4vPZyZcGcGLUzQZK+D4h6+VNAK1l2BT32kGO\n/0KxNebWcNbhjRRTMHYA9RNdWcl30DpTx5tWTH2m9m4YChsblP/FR3DoCR24\nkCI9V6+UokC+Bzv+pnYl3x3foGD7EPpK2ff64rXuQDmqXUFXSeaI9U1yQoR4\nJarjSbE/8mpECsq1hU6vddFKTLOxDF4rl9fS04w+DgrLddDV3nRkBiEQ/3/k\n0KlaJ9YDTZSmbUatOvACn2mfHR1jd8bFbLQGVgywxTiyhxl/VcmkZ7JKxtjr\nwzRvdOnOIqkfXY1HLwrJ7/iMfjTLwnN3BLH9xV5LM2JfBN8jtwOljYTDeXWt\nNTKrNyL2uAVD4NXgy7x0I6ef3ZJ5SZqQXV/dWs8Prhhg7ZsdVv+SBSk+PM5x\nnmpr\r\n=2Rn7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1d648b4cd91dc263e1f32dfe19a6462cda45983c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.8.2","ts-jest":"^25.5.0","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-89810ee-1588853070676_1588853142808_0.9288240622376405","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b53817c-1589014737025":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b53817c-1589014737025","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b53817c-1589014737025","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"98506f687671a135553d32ac6c6fbfcbed668545","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b53817c-1589014737025.tgz","fileCount":30,"integrity":"sha512-4fooNjF+IbdeVzeH0cTxgLkV36C/LaxgT4F8x7qYE32+2VgGPNVbwope0/1CqPdIE9cGPxseu4d/+nQBr4KV6w==","signatures":[{"sig":"MEUCIAuj8ONywsUSoGYjpgz9q1600rxJPr8Ebzd9RVMXIWrwAiEAjRaSXZJvtSYDb/0DC/QzXviAHYouUKoHZuYfayyFCvY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetnEUCRA9TVsSAnZWagAAhCUQAIqzfuapMEpdOXSBE21f\nV6sfLCK5ZnRg8aLxousv3hf6x8Bf2fs1VoBwabh274daj5blFsy/tBb8iT8Z\nBMSW0Jo8QPIicGb2oJ0pKIQ4MhIbcnt7+AWdiQCZoT8U2IAWelYYAuIsc5tw\niieXdKifbIHmLoXxudKTsszth622/WhaFh1qKo+kH2GAq1pQAcku0ii22TnG\npdStUZTIN6hB9MdmlmfuemFZxop4W0jNtwJXu9ENLHnDcI2Qv9Ya0GZ1MMrl\nBGd8p5UNgck26ZrStbk5ySuI5CYvUfETv6R0kI77Ya52JewCy6S5c1QjIy3U\nlQft79EtcuctlFkkOQZF1B3P3lKabT7Qc4c6cKQaYjfLpoTmyFQYLIRp8B8l\nI2GZtCXXF65tZ+Pt6zDZ5dJNMDo0FNYDRaTvnwRBxakGlB7J4jyT9mUtfy32\nJgfH/98BCIOlmKpsU/SFkDomqi63BbfzwwQlAjtfJuT0kNpwDUvkezTgLvTf\n+LXgfscbnL5BOhugzScAlyzPuvCisli6RK5IU4PoWe0K7wUKo6upWLeSbD/g\n4LZGqVdUBBYUwSJpi66JTIkFXi0EIyOC70LFKyjaw7MnK8jGlXPWmZDsvtNY\n7eFsuzqTqsOUG9jh9lpCHP8K+Nlw6UJPTm5F5sEAGRQ7rGLvQv26iWoSOeco\nMAqY\r\n=6WCm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"30ffaa1c5a619e5d496a36fd7f1d6f7f82e19b09","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.8.2","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b53817c-1589014737025_1589014803990_0.20288024382522085","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-0bbbfab-1589108638680":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-0bbbfab-1589108638680","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-0bbbfab-1589108638680","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e6a4665475f167475a410c208d84ec06a78e242b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-0bbbfab-1589108638680.tgz","fileCount":30,"integrity":"sha512-z3BDb3ts7AdxDtx9t/ab5d19u3zvHR3dIkCCKlYCAIN0C8ZO9lmPciIt+CmRWEjXNfyq6xv5EstHQClgosddGw==","signatures":[{"sig":"MEUCIQCWlzVcz0kZhO5reYWDJFdS9922XrBc+swUsWHRYEV0WgIgUn1SwjB56X4iZGbj2zKTkxUFnGXn44ypkDKz2NTgx6Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJet9/xCRA9TVsSAnZWagAAyhUQAIxFKAojVoMPUfIIkMM7\n83xqanbAOBHtAze+pPBvw+n80X2F4XC5wqSKARr+3BLJ0V0WWZZ03YVjeq9W\n6N0W0XCusLNcZFYzdz6zjP4hjKOQ5izVBw9hPE2BnzNnPBx5Y9olgdrWGUqc\nlLMnvxxXHv6/Wp1dOYhNDzrfh8CBdsAYKeMw8MCNfN39eJjGdlkXWW0wlBAA\nyIIzLmTttKhkdpLOvUdZ48j3orFPf9ScVsvxZG5bPnc3NMWErLcZ766OpV8e\nW4BcMGHsZvd7uSF0B/s56pEjr7KWHEI/QVHgPw6UkjS+bl/zh4astzGv3tML\nOd28DeJaXgHPwNTYygZ99COIYsVlbbXUswZyUpypCMSYlHbt8EZnNjfFZ4q8\ny+Fb0vNfrGNlrTt2sYJQPHDjkntNhy+WUGCk7w2xytXGwsgGMsCvLY/RuGn9\n2DHpWwo8zz5+/Ce6efT3MM8ZK5i8DaV9r6sWH4soqPqF6FxsfMV6t317/OPy\nex0009mg/PgePzwdpC50xH+t39L5Q84DexXQb0WostDCoWKVb5NwMB0st0sT\nmV+NzRKk+JjMgN1XRdS5zeBCqhdo5z3CWGdzrP3RgZFtyc6KLGWSAsGaTnSa\ng3s+aM+3f6EwJRXkMXbWmqVces+OT9nWoyucvFSH78pZWXVOdiqqysvJLVrS\nOeck\r\n=25uL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4172d645843f848d55988fc6855e14e67681c4f0","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.9.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-0bbbfab-1589108638680_1589108721399_0.9768071453186997","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9e2a9a9-1589199762525":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9e2a9a9-1589199762525","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9e2a9a9-1589199762525","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d84e8e56cbdd7faa08d03b9cd79f92db497f2dca","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9e2a9a9-1589199762525.tgz","fileCount":30,"integrity":"sha512-uMhNwxbh/VDc4+LcU+rdd4D0wFpZ9vkfVlKj9gXBzf3jytUjV2xtCtTa0Np93cQaJ4BMIwqrrkeatMzi3o+pVA==","signatures":[{"sig":"MEUCIQCET4XGXWyXQAXBHa4Pwz4l3dclTYn+FmKdApCpxgd9JAIgPhrzGHFFmsQg3G9imgSwrwrR5gg49PHHSLkfPxyBcT0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuUPkCRA9TVsSAnZWagAACLEP/ibe9nRX+du0Lx2ErsnV\nPRaBpXkDFygBWBXalMoZW2wno7jlZBbs1s+lgACTVo4v8GbVI5oByi0GYVaQ\nx4R4uf/28PYXjCju9FUiF22CiJTyW/aWfPeFkEQZiPN9Kuee+YnUvxUXeMim\n3Pccf15kuZO/Zc5UbJr2LC5FXDZWiTKkUyCCWwBQegAb+ZP34yb8M+79G353\nUUuHPl9qSjmytUlzzU2iT3OoNFlSVQ59PF3LlIFyEUHe8+XaoNQVCwMx+To8\nnHzsJ/0S7E5zs8xyHP8Rm3+7dbmZFFfRtz9drzVC8J/vioeh3XmTqZCJZuNz\nZJuXiy2IzGwYAh0tMV9DIyV8YpAdhHLCfup8W1GYc7FCs9AA6e6woa06sKvc\ntqekLROO8l07a18ymX6ay5LZHI1l9df/P6deaRxxGenpERbl4zL0mWPKIv4Q\nkBzfqPBVaDKV0Og+9ipHn1dFiHq/4Izkau44EEVMBAbc/Wvn0qj+bOCpnK4o\nl3jvnOqL5TItZI5ImByxiSYQXwBK3ipXx6VwxJuHzXjZmotgWcnvnNBzmuBQ\nzwX5OUFkUwHDkJPGpxPjEWrdp6aGOqmT20hkYHwO8DZ+oHA2w1a84q5kMRvQ\nzNgYck54KQyE8jAJd0rW5TouxAOGl3pqgBIwDMtmhatw2sISB0p1jpLQ6Xav\nUoqo\r\n=L/mw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0444add14cec82d45110af2df1a7fbd6e0b7db65","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.5.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9e2a9a9-1589199762525_1589199844109_0.4348248744889365","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-d429b78-1589207038522":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-d429b78-1589207038522","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-d429b78-1589207038522","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e8a8a90c158d60cccdda64c1e2d6ac892e956c0d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-d429b78-1589207038522.tgz","fileCount":30,"integrity":"sha512-jaQv5/wTWpyoPsEIdatz6VvvqLbxF3vh8cL6OBSi7WxEzidL8dOoI3mMvvaBpMcqm1tOiaSfQa7UN8eT4cRaUA==","signatures":[{"sig":"MEYCIQC5qVga3TysZ6eEnlecrz9WjxTW1h9YNDFausWEXFCHpAIhAK4CZO6bxhFH8KcNd/KZywSp9S+x8jKqtgPpA6ewAfx/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuWBRCRA9TVsSAnZWagAA30oP/27yrGzbNsPytHX1AOZO\n4o4OqxoRLXGSPqtQtpmSO7HJtcHds0ZOqnKndp/X8fU6StLPe8WfHIBqYZui\naddD3DfcooYBUMcRqm5a+L+SQlC1FKgwQEkwJKZYqMCmczqYRs33ooq/BN4H\nmEWbBvPeelgsgyH6B/4k//wjXkJ9Aio0x9brOLybQ96VZ/q2jjOKyK0uXrNN\nTzlz7P/0f6AIlD5DeMxKgYbqerf+iLN2UbWFuTxWS+yUJgZ4dAwdz6txEBEv\nRYp62zrJPPQeOtuYThqd5ncH2oeRZXNs5Shh2hgpxGSlMQ/HrWJ/knlcf1hu\nvxZiSgEhKdwxrbPgF2Bnyx+M+GC0M26ZYsWU+UwCC2k8WBMdf9+oPo0wayOd\nQD81dD5vcM/nBoNwUnP9MFSLxVqTmfdggbA71z4I/qZkz5Bydj2mpZt9YtOL\nO6OqVuvyKKdfFIW4sLRnG+i1RnX9FcG1gTN96wXFKGXZmJLJiMTk3DY0xcq3\n2frvTnSLOlCYEa0moutsrWsp+DJw3UspR2gvagu0GmluqLVg+4wo911aCvby\ntPg7KnTQtQKNIt+Q5TY8Mf/6FcKvZj1SomPwweTbG1VOBPecNRznCBA/DUqW\niWDPoU0alIs349FfHvfbaNkseWc7Wxq0xfa12hTzNF3TaxDyHGpX1fLB/Mcs\ntHpn\r\n=VZV0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7f6ecdef6ea27256e44394b4628ef7df8335082f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.11.2","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-d429b78-1589207038522_1589207120769_0.410954051625251","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a95477d-1589307139620":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a95477d-1589307139620","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a95477d-1589307139620","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"46fd414f4560e7e2d1c242b2a425a2d114d010de","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a95477d-1589307139620.tgz","fileCount":30,"integrity":"sha512-71eWg/SbCLxwrWEfGeLJWgGND+06cHKFOFPpIiMY0DIKcRNIs81EbKDH40usZ+0gtFDFdjmwVtuKTonMNzVkGA==","signatures":[{"sig":"MEUCIQDJjz7jU+0Zsu0t7OWc8XUesI+kyXusWcA9SRAB61Yi8AIgbwOgRWhgw9HnQTIUmsJfjYoiOWMEQc9io8fnXZ98oE8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuudVCRA9TVsSAnZWagAAwNkP/0Lsw8m73KYKpZzR/S2E\npyhjnikdixZa/Ns+fOgs3BUoQzuOTrMTd1Az/GEaxtWsUJPzDXt+UAbzaSKK\nBfXaTCE8f05PlLHFPD8IvVTtvgTE/NM6VoyEbTRzxTSciuDTahlviYu04wL2\nKblJ8LYgD+Hf6ySQfeCDHrDolzNP3HNf5+cVwU/oPd2M8JXwdPMlMLK/n0tt\nJtTG1GCmjkgNBUx4xTq9ApsSbyhUB353jYcxbKgz50hFVlq/9F0cFSANQ7TA\nv2M131boeQRQlCkA7rIp2ghaJZzV8GkryIahi8Fk3mFXz1baEHLI5fbsiExx\n+Q3BWhIgoumG3v6uLtcl/O8b+dxlSp2Zl/AOHxb12pjTjGu8/elrery5ylLZ\nFMj968oS67iaM7xQmxUmHLpFb8zPzYjTcVCNfl7g0K6zQrcN/b4azzRccF9i\nM9M/FdtjhG2cwU9i7x5KIIY9o++dO97tf4bLv6TrS6A5kcxmJ1Xsa0HEyr4f\nSjTo/zuOhRwHLpiHFtVoarkRcAYR2QfljxU3xZj/zzhITwlQhSkdJaTOiw64\nyD+kO3JgeuCVRC05DSJjo4P6mApHYpFlXh/LkSnuTuoPQIfwc9AfW7d2T8qA\nsr1L1mWT1iDWraxpWOJyVS+qucHyxxv1nOBPrJ26yWN7r5yB6Q7ncJn5Sshw\nBlKl\r\n=WTHp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e516deadb12655753e343028c403f8c2f1ab234d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a95477d-1589307139620_1589307221431_0.5841853452039572","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-4cb6560-1589311738827":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-4cb6560-1589311738827","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-4cb6560-1589311738827","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4fd7d773bd046e1196099359b5d8e47f09b2df8b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-4cb6560-1589311738827.tgz","fileCount":30,"integrity":"sha512-8bYusNpzKUXgtdL0REC4YgWhSul6T80zBvP13kD4ffEah0DkuhcQfq3m6Omj4i74xkp4L9YuiUn3VhVN2gE/Tw==","signatures":[{"sig":"MEQCIG3pzjVmGj1QmebQUEjZFJprOmSPYomHfIwjgh5GtbDjAiAwHDSTSzU2hEN/EGlkVYyO/WqMTqT9oa1LZLUgqCe28g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuvlLCRA9TVsSAnZWagAATpwP/3L1wt21V6b12EPNtB1k\n5wEHwqEtGNul4qQFRxQsZFV0rUgXMKMszocCuisLhMsF8CyYzWIPkDwn08CZ\nxO4B6IQICjYB/7oeTx4s//PyHrjhjc0xmpzeIqa0cM2BvnaHkpwW2bEPSdYN\nXjU9nj4rrmjRfPyO077VxBcX1Loo5odH6nkZ1HKltu0dBTSpjG2gS5TTaA0B\n/wvp0xIoNoeSgpSK1v8hAqKvP0b0tmi8m5W1M9nGdp9QCsETmJELtkt6qVRa\nREsJkP6r2rDo/14483O8lVWgns4SgdT7Hhwv4pFGFO5q6aQZ0kI79GI0btEP\nt/VCJ+sSW+dg+3jakBviGOcz3BF+OjQoZ53ZbuzyqpijZ68FcRo3vkTtk/S/\nVS0eOQjAtw92RHkTCow+ZdcTXTwCxFddqtR/Xeyj2csxd2e6WV/XG9iQJBwJ\noU3rO69ub7uEMAHURmnyMkdS3IR71hbIBTMY/qpng3NJu5DGCVx8CiUWj95Z\ny19hMBG8A116kczEHXf1n4EVLEFKrzcIFccmohihojj5MkJxuZ/cztUlWxgP\nixc43pxorMHBCc5XSWho0RrqJ+he3m/vc9wRqLXnQ/kHQMFGHMFCXobx7+SE\n1yKWjIZaq2eVs9IUjTh7NWv98epjZfMunFkY4qYU4/45bZ63RsWXuJnRTg95\nHgxJ\r\n=irt3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e5e2bdd2891fb89cad423c941aa14304287da9fb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-4cb6560-1589311738827_1589311818625_0.726165948711635","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-1a1fde6-1589320775026":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-1a1fde6-1589320775026","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-1a1fde6-1589320775026","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"19d88c5dc2ddf9b5721172a8a4751285ee1373a1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-1a1fde6-1589320775026.tgz","fileCount":30,"integrity":"sha512-BryTxbIEwRqVI33DciMVt5mT7To/eIa1Snp0+5aTV2HwCtDA6ACYYQqvxpy/V1CUKJn3w3OOQZKT33Qeip1GqQ==","signatures":[{"sig":"MEQCIDBp0pNfE7ugfydXeLtLbg3VldyOIRLinlPgrrqomDh9AiAuhtiCwj4XmiEYxj9vCFhdjUbWjTvindvv4MDmvxX0Fw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuxyRCRA9TVsSAnZWagAAYMwP/A0Ig+FtHjn1q02ae/04\njjaV6xP8xh3wMSd3fjG40GWwWGB1eUTUO30YTSNr6hVIeXfognKkiY1AX0Nt\nkpWmIdh1TEDXoBOjsowF7q+pgNRhSFfQtxTICStwZpHqfFJYg4G6MIx9FmFT\nOtqcvLZNEPEStXNcRuaoxFTy4f577BsrN1kzVNcYMrKISgjhsBwVeyHe4Os/\nvcu52g3PHaM5WTIMF2UAi0e3dTz2/RmwjhOWvH2pppTYG8v800zfzF7VnsK6\nhpeL4zqY7NqwocedPWiQf6u649n4jGs4Cit76cXtHuX49r84YS7xRgvnSibs\nt0eORu680i3+8qrW3Lfql4uDup3rBGu3gzXytdbb6F7ETK5fOEYck6VWcoM/\neOdIRvdrLSYNmM/jvJc/ny1/8dtBBRjiTk6nHApse8CWWBNcgQfF336t2CDK\nxxy5uiJClRUGDIWUsx9k8AwSEudXBkU4nSLzXDjSIwH4o13upjHhmbZnDhTR\n3663HdliBC01I+hAplzQK+iBN1yvyPBAIyrs70dFTGgHZymEUrOhOrnqTwuo\nUWafSzYbm8iX1am9n9Rrac2BBPUdqg/zVOvOZg0KdRklHSSq1bWlqGRGZ45Q\ngKtrEBg7EQC09mYxNMbrP2TBfnRopGL2dQNuztB/5VdRXqrPkrV/OOJeZ/T+\n/Q8f\r\n=bPvd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"312c5e4dd1596edb5c4ed61ab024215ad54ed84e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.2","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-1a1fde6-1589320775026_1589320848656_0.5627498104283708","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-326937b-1589350237906":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-326937b-1589350237906","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-326937b-1589350237906","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"564d51710fc0af9acac5aa92710e8e81bcbb9844","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-326937b-1589350237906.tgz","fileCount":30,"integrity":"sha512-Ie08YFdYoB/YgoAiStWO+suD7zxus0t6GUyGD2dHZojU/cTeNVvv+F2ZGyaVFinvJwN+03PWg4kXM0dneMfOWw==","signatures":[{"sig":"MEMCIDYSnbPneBLIWX1lf1isqG87QorL6hwsKZY/J3YiO6YzAh8CFQ4tZl6ovE9TRycBsFSPPz3OS5rpFcjkyp47m7g0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu4+pCRA9TVsSAnZWagAA6rYP/2PzTEuPVSAm2wfwV77a\nWtm3+Nm/H1LiHbymBAb4jeacwe7DVj17hjb9kLpD+QrPHo1vvhE2XZe1xl4O\n6GA+iBfLi0z8IOOC+tfmg9jRpDxp+CMuHahne+j1YeENR56WPS2LqGAq+mhk\nkWQrVnVicDB9hAfQQmrx+vxiR1To9qxnBPI2gwXVZFxZF6cVssV+YvOd1N4R\nNSjAqT3KB7veO2e3zgzVkKKU3gDXI/PJw85LpwAwLYEyBAJJN8hbcMTM13zU\njF9G8APElXHlVJZzhxhsPokuTkstkUKjVqckxqTvi861GMYKcaB6WwFCkels\noOMk8CMQgcwCUv/QifUwC/ibBu1Za9ijI8GHJ+7sVV081E0Myx0RGkEDI32x\n5/vEMKtlH1IeEZYJ729n62sr2Lm4hLfLvPEEw67LaC+3mmSYUhdGueHXx++A\nJzfUuqgU6i3cO4Y+2uW+KsLzBbip1n94wsw4ibFeUchMWeVDZs+bY+xWw1Ng\nkTXiFGI1F9RpnEr7ifWd93rzJJxWSa+S+Qrwpp5Wsf2diIJT03XLL7AiKmy0\nLM6Dr2pn9mi4vymulxscZ2lCJU1iSWywjMOzbP0N9zxd31+6a9+N6gE/EPU1\nMc6Meuz9J2JEO29XzUhRyylk6NWO1sIis0TUTsK3uQPnwuIvBy5nJVFz1sME\nr8/+\r\n=/i+v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"20df14182778d77be7ffca0b7df87d20e6e59f64","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.10.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-326937b-1589350237906_1589350313195_0.09857192950381033","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a4aee9c-1589352376286":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a4aee9c-1589352376286","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a4aee9c-1589352376286","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"15e63eb5bcca49c2bbbbc68554aebc677adfab53","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a4aee9c-1589352376286.tgz","fileCount":30,"integrity":"sha512-LOzfLMss+xWiKX1JOXXryvXdUkv/C/wc+meXH2bDF63J28K5RBTISp7ZaSmlpxUPROXiX0O2/STWeVi2ZyWLQg==","signatures":[{"sig":"MEQCIDp/WcTz8HzCiBUaWqpzvdjPxRN+2DmtXdBwuxrIognFAiAHgAg5QamNrAfkPiSChViw7eMXW0ZNWAhHPIbr54zr2A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu5f5CRA9TVsSAnZWagAAbu4P/2MCTuBfd/b3eK2V0gDf\n/KAwxktcz+sa7nKQdvShp+dWCWcXjGkzELZTFZscCWuzVNvNe4co2JfWYact\n/P8ejyDHHVdlWxny/9mUiNXYfvCiQQxl4taUWBrITlK+jXSoRSJ8wLZ8+Ye5\nvQAM64iA4xna8//I3gHswN1qpgAXbFuPqs4+Zq03S/0C0JwLPx6nBsZ8Kopz\nqA7y+lS9d5zHJvn2XZAtrGBCu0E/RHLTHQ7DgEvVT9uHOs1acy0fOLzUwMzO\nJ7f9bpNCVnHkcbL1TlLVAYcOCznYIMvEX9+gcbdp9ZHNqhGaHp3RUqgJBL59\nZSMv+8Uo35AgyHGapfW02qedqMWYSzUMrVb2zjODxgTaVqIWLFyehvJer08r\nX/26DHqw6P3o6rqfMoYVDgMaA9is8ZCZXLVEQ5VCWGwVM1W4XZOGbUBKPHtQ\n9uizH6vSVGrr2OCVD+a2xb2/X5mbPnC0+lZqqwFXzdf03SYn5QXHppiDKItQ\nOxWTqwqYcCCHB7xGR+qyseQyvBIIs5opooy6e4rdOTQ7MK62yuU7pAQrU+kM\nO1FnupcupEu5KYKk1fgrJQMTjsj/NRxgTJB1FmioBk0L6DSa27R7m55eC8Fp\nStlAq4i1J+e6yhx/eZw3ook1SYVtNejBlo//bUUQP+t39nJRLZtsEGKM2prv\nLpHF\r\n=t14h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f6bb678059fbd5828b7c46d0c2b21df991c1c226","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.9.1","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.2","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a4aee9c-1589352376286_1589352441037_0.628265489765178","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6ec4e83-1589352655220":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6ec4e83-1589352655220","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6ec4e83-1589352655220","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c184e3effe4926480211054a748ffaaac3dc4c43","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6ec4e83-1589352655220.tgz","fileCount":30,"integrity":"sha512-fngp1dyNKRIBp/1Y0yVqqlKRcoOQvBrzBAN1eMbfVzbgysZocpiPBEyg0jDdCN0dRWpyCkGoYJmdC0LT8cpKwQ==","signatures":[{"sig":"MEUCIQCY968JNuy2EnPV3j48G5BZQsqNYFLrkbp3sCb/7ID/jgIgTOYEUiBPgFeihLk3Gl4eYorkLFey6iE+hmlXAl+8Bhk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu5kNCRA9TVsSAnZWagAA5GcP/3DOcfQf9BvLy4LhCKCQ\nDltnWKez4xuDQFPcMM02lhXS8hCNS9P84c47DC4GTRAraAsxQfg3WHCGWSxD\nESqNAteTlZT8GcwRys05UOZyQ7DEGUy5OfjCgegwaQK/kk1XQNqQosQl7Beg\nICXv04aaSwRRceEOV0X+/vyWu3CK+epW23dHeL3PWFVfFPNnGSNOYFN533Zl\nStyGaibZwWpvf8HVWRMW3PetajUtUikivXyZSbU+ziqkOyCZSEbIIhy7N+c2\nAEKEh1UaHkqsuN/TpiQOU5giJ6YX9S7giJPx6fkRJriMYuW2A3VHQ5ofZl9Z\nAoRYFT7a4ylDV8X0G5ulKaTITee3VgYT6zMNBG6DxbBgzXscJ0uWc/HHHGCW\n/Eth2aLThCDXw7O5gzU8sgnXdI7UvUWQ74uetAD5XORNPatbzU7j6ywBScdh\nAc9YHp5B+ksMQAPKNyhKtjoeqcx0DYDIpdkDmYdb3EzWzKMek5lM2S8CLfKR\ng47D9ZNlHk2ASB+Cf5jHqZ203hVPqpciSJ56QB+Z0EW8WLUXm41bXy9tsWbs\nP/GtwpqlvfOh19Wjjg67yE5etxJ7s4mYvEmwwDpau+NPR+Sq0LkT6eb+rrVl\nFIOKCa5aJQksTuT6iOOsVVXu3rm+6PBYb8ROmU5t1EEbxiI4uzVEQcldIMXs\n0TwR\r\n=dnIT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c706992675417824c40717aff17012ac87e93808","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.10.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.2","@babel/core":"^7.9.6","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6ec4e83-1589352655220_1589352716883_0.3323643463666406","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-12b4d2a-1589396248595":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-12b4d2a-1589396248595","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-12b4d2a-1589396248595","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ca8f3149332457b17c82ac89323f48a4c47538b8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-12b4d2a-1589396248595.tgz","fileCount":30,"integrity":"sha512-Sl+j2C8Y1FONcpFmcCrsDaBKVJKagjF8YWJEG2e8qwqBYsnEPyZxu0nxFWz1c8/bgPEZWQXaDqJsF0Rd1eyILQ==","signatures":[{"sig":"MEUCIQDVy8STfyiaScJO403czt3IFp5X+5ob+7IQ3Xre8QX1KQIgPfAI+2/qT7JuYutZk68B7vamb1BYVSyxpoCo9onmOm4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36553,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevENlCRA9TVsSAnZWagAAVUkP/2YylEGGfLylNvgG/U92\nrLaNj/YCDZ2YjeWVdQJgkJq4jzqSrX7DNkI8uHLbUYIOpjwAgLKAMmsKfv1z\nmC66Z4WXyJvpFEIPcRcEtK5KxccDfN0nltUKJq3323TRMbeT3PfiRSwKhNlA\nV4UnY9u7gG/kXAalwXLVPzWcBtlJYIJQfhvf8yePQVLI0mnPOt0O1b9k6CJk\ndXfJFkjDLaL9RwkJOObWd3V8yLyyQA0bVJ6Dfir5Y72khMXvBRkFY3AM10fG\nWWlD4yl/8gGVcGIxJKhSb6tmElX73AQWdNHUGGM6kFrBHlJipmLgjTokpnZS\nmI/FGMYmxkCF+4quTE1DjrDc2Wdo7FlMxdXABagD47fOb7XacqeWcI167o6G\nhvXLvMgDiq9tKniy27DX6AEmavTQIAqzr3zcuI2y6dVyskuYhUBEpUasoeRF\nfm/th4P7ZRZvG54SejG5WT5oM3cx0FQwa4YFuT3gwCN9yZz6YwPMdgP22AxW\nsHJpgufU7YDZDA4CVtkA5nPt0MPdPpgUHqIqjhrh+XFJwRUS11Pvhr1w4YhJ\nw0+rgQDI1N5ELPiblpiWH98ILzjYGXm5iuEplc8N3aaNkXH9u2SWSADXSQrq\namTZx14oV7X3O3Oe3vBk8EN42+ZFCgaKbYaGBC9g3jsy4yC092r9ZJfgL2gp\nps7+\r\n=rgZ/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"383863067c95c188378ebc509f9c3b31703044ed","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^1.12.0","eslint":"^6.8.0","rollup":"^2.10.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-12b4d2a-1589396248595_1589396324920_0.774314436338162","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b46e8e9-1589411464927":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b46e8e9-1589411464927","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b46e8e9-1589411464927","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"14e799ec79ff5466073a18c8c5ffdccba6a2aa63","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b46e8e9-1589411464927.tgz","fileCount":30,"integrity":"sha512-f3qmwfu5ny5XxFtAZfPuQPUfnROTsWNB7KZqbYTvgPfsLB22SNLfRWonOy4xPT5YelxDMIayfYAHlRzThUtzow==","signatures":[{"sig":"MEQCIALFuERjZPQUEL4NLQOupxnfnDnBvK6Wu4tblnDO7tHCAiBECgec16cGZiCMD4EXmmpIZGsqRjDNMvChDGRxE9rRLA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevH7PCRA9TVsSAnZWagAAjhQP/AltgdmbcCrqCtbePSIU\neUyx+mYTlcMxwNkBI2oeS8gQT4LRuiRKftCVCYdNIdSyzS6mRAI0GKiJvj4P\nU7lNI7i9c+b94ZlORU+s47/YJsgF+rf66eHJcnUtw92hpZLbTR6s+uMQOoxu\nqNxdHkLuwp0A1O3Hq2Lmk4TYDxCWRvC1whDab6Z+U4CELckIdS/6+QN/8nBq\npeF/jKheBWooX9zpp/xmkWTexF5L4Ah+DECA+CVS9CwvVFeQv6O5DPX4Jbu+\nSbce+pdokLXdou2smJjzjBbUrJLPm9ReJjCkcAU8Ku5/eMnDS7pEmL3ESsQS\nN4rAS4a1GWSB8ka5l5Zd1izU4YCw0XVBzUIlKMAh5Zc0fuBjAnURbyXSGFx6\nAFkVoMk9JmsUOOwrbqqgurLlXGaV1fNx/ArHiKFqigLZeCAdVVJ/286TfKMa\nCSgWIlR1PGKWBBol+EGA0Z2FPMzjsSWgY+VH2HGzlMGUyupv4dNtTwtx08le\ncdDF8ruL11X83d4poNOm3YPmec3ClPwRDYgek95kxY3LqiEHWoD1HDYokNSh\nLsGX3W1PTzcPYfe+DCbS7v2Qfn7tjKaLiAsiTTU2En2ahwQFg2+KvG0Zh5UI\nuLGI6NAuTZ9qmhKd1AdNuTySEQE6J+NfnER5HBT4EnAw+pknnDYa4FK7NY9t\n9dmC\r\n=OP4l\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ff81dfe79039b89cd2a553458ece033a92501981","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b46e8e9-1589411464927_1589411534960_0.9277990451144376","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a6e911c-1589485887209":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a6e911c-1589485887209","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a6e911c-1589485887209","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"730788b57cb5cdcbc7e327dbd7eefa7b7e65d41c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a6e911c-1589485887209.tgz","fileCount":30,"integrity":"sha512-t2S6fE/o/C2iOaRk3jbiz4nFKlRn3ITfWQffCDf3swEtyc1Oq1alb44DMJUgvcVdy+Pa5KNx/l8iQe1HliGdWw==","signatures":[{"sig":"MEYCIQCksBW4fALQ4y8SKsKTATu2aLyD5v0MYwKdIhyUM1Vi6gIhAMusOWLWeW1XOmEqEBB0d6Ef/ptUipKRM6bRwXc8H6Au","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevaGOCRA9TVsSAnZWagAAmMwP/jjZvAXAubVFFyzITWQ8\nmJoZUdNgjOrqlqGkYtpp3PxHnt6t/tUqhqDMrLPlUvglifnXRdvbyLQx/5pB\nwsO7hu+o0quxSctsbJIL5a2xWQwGqUd/a/zrHxU1VdxYVA9O95d5CJNp00p5\nAIuy7i4/MNvepbn8oyepPPpXgYt0CU4HwOgAWCMJpPTEHnpHv9G8l7ycyyWD\nW5E9hXoNQHzxqUhd0btw71+xu98s3bD2CLaHRE3FxMkn7tie14iB2Axo9NZc\nhA7D60C4XD9bRZgJyGPMaBcyKF0e3kwdo9QWNLeFa/hIjQzetggT72/6y6t6\nY0MRMT2HHh7o7J4DzMoPthrCWkqo5YOx0T7A6JicMGzBPVXNYoTnTvue6Epw\nZHgQuDtiT1tnsPFZEPCIyKkXD4AsD4YpJHH0CMnogpxHEbY0GgZE/IP/fz5q\nzIILQDH2l8YJ4VVfCg1NHnzV6s8QWYR5FicsL9wHV5ggZ+79F5Jg9BQjUlqS\nq52izXy8mm9s2dQSLBK0FqlQFZGP6ChWxtdhYx8XFuzygxADr6UDfdK8kLyO\nIamiNp5UrxsK3L21AsFKgW8RJankrms/MbI7p8RphmylU+cNMEZPM0CYUZZA\nZqykp2SAwgOe3QrbNIwdNTMP1wduWN5fweo9Z55zhfbd2AUMaLA4D9KW6j0B\nyTK5\r\n=meDq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8579bbb1710ef647ca02340aaac15e50a1e38557","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.0","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a6e911c-1589485887209_1589485965714_0.5838240867788385","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3e0ffb2-1589523577762":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3e0ffb2-1589523577762","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3e0ffb2-1589523577762","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9173acd87020363f16b885b949fd3e57021fe7fc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3e0ffb2-1589523577762.tgz","fileCount":30,"integrity":"sha512-0nRsRW2iXhYbU14WxH+ln1rECHzGgWFQLod6GyqDyk33+bmAIMAf7r92OhVYmSQqZC94g6rBnLcth+4NorfqBg==","signatures":[{"sig":"MEYCIQDbmn2xvtd95/n27UI/P527WHEe+jx13aJ7iJOipPsSHQIhAJGV0mQ58+Ir5LH8PU5Ywxczh4RpGl+DZlRd13mknvCD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevjTDCRA9TVsSAnZWagAArZ0P/i10VT1jVmG+FNX3uq1F\n/HtKvEpFFfBaGFXvS5yC4zD3aCkewYPC2N46KY3s3kFNx5FnMbtS7Lxk+Zp0\n/c76d2Q5TDLyDIYDuOV1BLeb2T0WBlT4Cz6UVYiXZQcEuLs2DPl6UhQzWiz+\nqxFiAgw3028dpxFKGyh14r0hlZxD7ufyW5m+f13QEcxmKwl9dLaaFK5/Yv2Q\nWWpOtIfxMV3uC1jDt4USgf1suudxxsAIWk2lq8GO2NfH+DuejqhWJg5Zn+iH\nREXVjXw3OzO/+EC1So3EieInL7JUnIw8anSJZ5OzluyFGtUFL9paBQTJ3oVd\nHV3Scf61XTAxBWJI3qCBn3exHw7C96sxQfDyFkZv5RaIr/W3lC93aHJrD1tb\n/nLGmnf9E1EiqhwAnUQ7KV5V0rPQr90ys9i/3g4Mvx8PwmLwDIRt4NNnR3F8\ntB7bYK2eSYLqQBd6TILpkR8JByMu7e2Y4EbcGGcHZ1Qn1yGykwe/jfODn03p\nM1U2oN0iIkOzWLCRkC17zdiFvxuKf6QOZctRp2PAjY377c4aWY9Dc+GyIMJB\nCCgyeLLi2WWb4FVnqKms458tyHkVVxmkuh1Im1CE57nJnop8WT5+7YA2QPyG\nAO/oKrPcuuwOaqxAe22Q91u7T5esarZhNGPa6VQykT65RXw3FZ+LCDX4rsBz\njYFQ\r\n=bV5K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ad91cd91664b9f04d7fe6fe994b91330160b230d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.2","ts-jest":"^25.5.1","typedoc":"^0.17.6","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3e0ffb2-1589523577762_1589523650705_0.22021262386291984","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-d25271e-1589687931970":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-d25271e-1589687931970","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-d25271e-1589687931970","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7ec775bd53fb9d3e84845559704863ee45292a7c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-d25271e-1589687931970.tgz","fileCount":30,"integrity":"sha512-zM5bFI9NYlXM0iUOsXyZJH5CaEZxLFOhw5J2T1PQ9q+J6p3JqnDbLBpkQFJF6QKGHa0F9J39zJ6yTGT9lcdtWA==","signatures":[{"sig":"MEUCIQC+UV/1IDqsAZPLP7Ct8dniiaoPwIIEtkdea+KgYEScZAIgJLUeEHxHtwXzg2OwJ02KI8Ein5zqwrisCSMNbMBjubw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewLbFCRA9TVsSAnZWagAAb2AP/3tU2dzYQVMc+c6ExWju\nqpHbhSC5fOj1I1Y7ykvhNQ+Z3iS7snqCXwM9sptpEQVI2Y7EKVc0ZpnQYKL1\numqAReV95sStqzsPWXMLdJiAZNDJlJdkj6zIqYOJC9Qf9zhyt3NLOZDXomvn\nEAieE3xvohgRWcIWK1OoszY8AsDm5SzjpA8r9GTVynjze7BwbZFtVkCdBS/2\nsefsDvJ3lPONyZpGCyn6ISij++GdD5xircSTGjoq3OtTue+ksuwlfGdUXPiL\npDE+Ykis+uOcmwPBZoMjhEMqzDK9nnA7YCWHCfVJ+3DSVoMIUZiVb6EbxYCF\ngbQ3a2Bbkk2MheOGzudcmzImzUDJ1/BurKt071iGHVKYKcQ4AeUWceH8qLq7\nGAIpIreoKF3jVhBK/8IHBETgmeAUStNnshYXxm3ztOfiVqDPCLYTtD3Ug32z\nONST05isgFqYF3sFInn7RQU3KSrsklltq2tA5STKWfwX45GmrSCadQIAEa5C\nbDS6LJneX+oPEN2EsKYiyhcgD8I27cNzaz0+3e9aV4EZux7Akm4JymQ+9KI9\nLSiQDWOBUL7pIBBb9rfqZwITVxHwjjCpHSZ4f8HJKIXSrlxQqFNhQzJ7w0m/\nJ5IaM5OCclU1v9S3tR3A/ottCXgezeaLh++ZxPuEcvDD6mKftdyN3Drt+Lub\n6oZW\r\n=zzLx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"add16b20ce0b393e02c5ee611a6a886df2e5d071","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.2","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-d25271e-1589687931970_1589688004958_0.8302463933506017","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-815c321-1589840893522":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-815c321-1589840893522","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-815c321-1589840893522","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1e0e760db07d0d0a9bbb8d5aa3671ece858c98ea","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-815c321-1589840893522.tgz","fileCount":30,"integrity":"sha512-l9DCt1i2cLzSXbqxdiKSzWChc0IBqq8yJOeAhnmuTUqiGDtEaQb4YL5FZlYk6+TR87VzIAEzXigkHSIyI+0/vg==","signatures":[{"sig":"MEQCICx4mlM9hTFdvy3LX4cyMnrEGiawzLsjl0e9BO7UmkhJAiAjH/tRqN0I4iihHUtCx4J9UgnJTkQkQXGtAv7Sc10gkA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewwxOCRA9TVsSAnZWagAAhkAP/07hUNAmddU1bUMKmnJY\nOC8wX2USZDhxcD0tuFvysPrjmndfsfRr/zwyd6pNXhDNZ3Qd1hiW360g2FzY\nWiCClivinDVuQ7fboDgpROa6vM32+L7yQ83SVdzudWtC+7BcfU7UiDWYrzC3\nVtxRkeRI3Ic/fu7qpI/qwfDjj4mFMKbKSsFNuL58fyGZTteWJgJzFJD9C8Hp\nB9B4abJ32zrEGA54UDPoe7tZDMgvyBUR8CIA21HmSnGHmZcqsyJnIx9CXwzl\n53fGC+ExqDxGpli+8qGakfQBwg5CO4xZ05DcTuBvdlRP8zbM5Wb3RAQtSmPe\nides+Fn1cU1duJFpqm3nRAYHnT5+FmBZSDwZUa6kSh3FkBXVWwdUMV32jpsh\n1T7VL+KPa/ipIt8CpT4LTOmSZfe7esWiKwKR2d7Q09Yzwz3m/OwiC9ie+hoF\n1RD7fTYeDLjA+wXDQ6h8cMT428xIibtuabP62xsmZnyPyCD4Edxs1PykKakE\nq6TaCL907/iGArqlhZGLJejWhgVhav/7b5o3BpNY0bQPOqMi6nHMKbezQqF0\nGzDvKHgsOxNf5LYMiBBSLUDho8Y/TbdEtmUL8nsrGuVJMxumbsN9/M+qw8u5\nVPUIY/TjJkroibgG71A9oe1+qBYor9Cjkt2jbJvEJftOGN+MPBaxLVfGAwBr\nJ2Qj\r\n=Dn8n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d4453ae8adb1c530123178654d2075ad298aef4b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.3","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.2","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-815c321-1589840893522_1589840973643_0.3302727464109172","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6007f70-1589844491862":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6007f70-1589844491862","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6007f70-1589844491862","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"32ed8844c088d96912c7a05f04cbd75ff113719d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6007f70-1589844491862.tgz","fileCount":30,"integrity":"sha512-FQQE+TUKTFNApv24TQT3TjJpkaOKQshWeG9Ou2jIBG/VntQx7ywv7iDf4XDtx6tfa6uDoffuEVSi3q8vha7Irg==","signatures":[{"sig":"MEUCIQCzYnWH/2V9/cH+JJ+xnW62gonOQqS9cPq8DRHoZv6u0wIgbNgdG3KiwQkT7aHxARtnNIzRKvV85qXiODMjzHXFRDM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewxpdCRA9TVsSAnZWagAAKxoP/2OO3SNnSh9SLmbx6aTG\nAnV4RY9p4UE+Olp8ra49REQrbqwgL1Vnl6Y8GaJXu2smHc7WQSuZH2xA0Rwp\n8xFh8LRDsHjCo0MpUKCepEUEeM7Wi2iJUwJPWy7baTX/YR3rYDzzsKsi+7P/\nGX++Fm3VeDSWPZbtdz0FMWU5fRDIHoBjUl+ce96mYUoeOTRwtdVU97bODFd0\nMkof04/OuXishuzPO/Stx3YuAVipuG65iOs0MQZtL9/SKm8UxaysRTW6uzMl\nek0mCGFoowGvm/COIp3zPABJc9eJqPo920RU9g2Ucqz3Wd9hVbGBpGAVTEsx\nvjJSItIvlljL6Ovhhl9ZzEFS17otYVCkpfI2m+rZpPm1MFk7005Ewkw7IJUX\nrhwpYeJ5I9lZf+5zjn8s74pBHbuZl3jrjxgmWK7tCfvC9WFgVAu3VkTNfljO\nxuEU4KuseZM83g2KbKquRzWppIq+34EDQ7pJpGsjg5xKa6s6k8uFGU+Zly5h\ngW2YSsOeaXR72bWf1LnIZT/PqTph7DxHEmH44ftjeEsTCgWkEmC4udw3CWUh\niBJvUMxP4Ylw83AseBBdDVsroYPEhBE41tAIS0ovZTCN1cJIk3qIfU994HS0\nuL77y62DQwKyZZqxM1n+E4FfJ+eK32Rho0E1L7wRndPPowuww88mLdSlWy9s\nycX4\r\n=4i1m\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ad69e09f988b3e3dc47fcbe38558177ffe74d31e","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.3","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6007f70-1589844491862_1589844572589_0.8972404092536024","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-233e11b-1589870298937":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-233e11b-1589870298937","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-233e11b-1589870298937","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d0958574ffc9d67eb2704c0cdaa2dee64c6fa48b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-233e11b-1589870298937.tgz","fileCount":30,"integrity":"sha512-249Hw3WHlWr77n457K1KfSg6ttRB2A0brZpuuO2gRmTHMgYj7N4e3IyeP4qFzCZKhih7URhaT3PAP1XQ7ZqnIQ==","signatures":[{"sig":"MEUCIQCP7MiStZ0ww87VmAE53W6b2ISnrofnYVexurfC82GqkwIgXf1mg6bnvaZo0n4BwQ6pq7Gwa00dPw8MlIEqKKNbHNk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJew38dCRA9TVsSAnZWagAAyFcQAKDhRURXodIBxIGI5KQ2\nrLjWTzsGaMAXrOksBWRtJ5tWdTC6al+SX3IiAuJP1ERp94d+29oaM1XVHt0N\nJ0nyh+NMsMWdx0Ckb2mZQ3lx4N69IR0CB1ZVuEM5yD6abXGs5NwC/kMrdD0E\n0rDUPy97lrXj5hlv8p++lpw0ZpLXsRPF+2fQTnc7Bt72UamTVT6BT/WiihSI\nUhFdfDv/ewYjjOstXRQjJFxvwHf0zZSqr0TRzDVGrvzp+uBL2D8BjEMRM37h\nTbhjPxGRmYH/vc4kQkzp90bEnQc6e1gDm/Y9PhtEjV5J0G5IEU5R0marQ1ir\niDV27cCRnkt/7Dj+pD3Qpx35AinlQw2AYweATjLvvkwMN3TL7XNqZ5MijZTf\n/J+svPjoaVqE2OUuzpkNMuwI90dpmsPqW6u0RxTcFdRCFWmdXo3SXqhs822t\nXOsukk1Lmb6A08dUJFJgnD2undFU7Li9Lf9EHuz6/sCn3xmNK5cgya+nNrBJ\nGD6D50aqOZdaxzxrDoEebHK9iCL4vpcqUEZIIFAf7q2PhR7ZMgIDJ6RP0AfA\nCdH2hvLrvDzetLJKg8FHVeFEu+1/aB7Geodk2jamtSFPJfRdWcRQt+GVGosZ\nyXLtglMBvN5XYsLzDFKCRcwzG5D7kSS52TUgtNQ/bTP4d8CwP4zQENdLtnls\ntl1s\r\n=THpT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4539cb16abfc929742a97dab2a11931adeaf23b2","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.4","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-233e11b-1589870298937_1589870364711_0.1399758684814263","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6e69371-1589924353343":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6e69371-1589924353343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6e69371-1589924353343","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0009c4d058a2e65ed8702174743be23539424ab5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6e69371-1589924353343.tgz","fileCount":30,"integrity":"sha512-dOVpmCkRPxrmX9DIxWsQj01IuCWeGvt6V8AjGlYcNZ1yZMhLMuqar37P2zDslGU5ZZjDYzyiU2kmW+mV+qoDFg==","signatures":[{"sig":"MEUCIQDgW5XkYbssXamM4n+MSBE2DnBHNofzJk7b7TWvzy0KHgIgIxk/6NIY404sT7IyQO8ofCIIV13aUXzcWp80yc+PIa0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexFJSCRA9TVsSAnZWagAARTEP/R2dBKnseJWsBd9yYYHh\nfiAoccARWwFU6tzwzNgX1mhihVk8036Agxi4CzQS9fxjbEZNRJ8zrqc4elwG\nNnUybgDNP6ZKVXqDpamRjoSGmmzHuCfzdB82HjiD9vAqICwiQgwTDp3m9KQC\n+xTI99fj7+SIjNZavVnPc24sli9PW/UU7XDfoaZVtXSY64bEHEdq8h/IGAo3\nIgiajVAVrGIyBgC10NZy0WpQYjrBPsuqL/t0ZHrijiVs5zvyWgiJF2gcBHL3\n4zB+hpuyuQ9OdIBRl/C77Zy1qp4myxAyvopeNHXz/eXnhBlR9huAHAGgeDBM\nB6QLwQ7f/XfVwbD4uVGwAyEZ6LRFMyr4OSAmU7ovRh5pDEWOIT4QHdgu2n9h\nFmoHgzIG+tAWPe2hpviSA3V0krJC4CgtoRjqNj+IN0RrFelz0ZCnvSSxu+Ur\nrEr7WE+oJfzKTiDOvJw24LBNS1U2n8DzflpdepRGeKpJHBuERfAMq4E5kxdM\n9e+9jrkB8nk7YswbCtdqxiRnXtHlBZxdOlxSDNqQcnoTinfB5zYKx0ACtzGv\npZnZ/2JRvLBTvEvNSruyx5WHHB3EyqWgigCd9nL5mhcnFcpgKB/MuEKS9ZY5\nWicVnBISRSm6fnNZA9OIueeLU527Gc8E1KNFG4GQhtkt25vJVZC9o5eU6jCh\nAQbP\r\n=3zB4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b109c5fa82015999ae8ec6c60ef026b78a1ff569","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.8.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6e69371-1589924353343_1589924433378_0.363754690227061","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-c2577a3-1589956028157":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-c2577a3-1589956028157","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-c2577a3-1589956028157","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b8f2a28c89e22c92fee4b3d9b5d159ac8d9f187d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-c2577a3-1589956028157.tgz","fileCount":30,"integrity":"sha512-tRf0sQVJHahEh7ft7/J2JRjza7nFTKT174MjWHQux18YbOUN7POKyw2WAsALkpMvCr01xZVyDNg401LUyEAlHw==","signatures":[{"sig":"MEYCIQDPrsvEK/3mpg8rtva/oJYJVO3OXApydstD2XvxLx4l2QIhAI2tmMdhu2U6ukBx5mqDqDC1K6M8KSY9P4mKzjY9gUMh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexM3+CRA9TVsSAnZWagAAIe0P/2rJXn1q0zwYRAB5x48w\n+oDrC2DdjT/7cZyufr7t9vlmSpNJ1dwDhDsvidSoAjS3x2y3pUx2ZPIC9j9M\n/Ie+RcOdgfHA7A2/xsWf44LQrKJLCGnh3FhWOpsfdq+4/N48GM7ytMx+qcsL\n8KUE2Ln0Dj2mNYW8aEu1FvA3LzIjmkPaB4ArifsR/sXxtLTXntJOGkuC8Z0j\nDNbGUm0BinhhToVh/AM2CwphiVnDFZh8Nj7Z2CHzqtlWfgAwNiVDrO9s/dK0\nTr3a2xrukR6glHFeCfuY+xPmMh24YVI2bbnHisjNn5KJejaWVuvg8u+6ZnWI\nadKzhWAzBr/MgFk3rGEd+se5QzB1upXSQMOegtdOeKRLnOyUNS6K8k+Hd1vU\nhENCUubuyGzizEdSrgIYi61HAuJqZKBRuleRVpPye28JezGoR/3LfcesGHH+\nPJGvz37DKURocOEB0LcjP89F7PtepesV34tLXyKUr0e2RXE5SiWkCHYQuqXR\nyV01Rxrdz3JtHnBnwxiivQe/8XfESx6fSJFoyF2SS1yto2/NzZmDknXWITF7\n/5UkVIIgLX/RxLwL0exlk8n0ponK+Z32ZZB2pHM95QH/Bb8+zGShff3NE0Vz\n0XrS/PeszgKSoBrP4+i0NZfGUb2X8pNd/2SGVhriDu/8NZeeb2vjjAKxp0p9\nTCNc\r\n=1I1E\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"cf3c15fef8a286519ba8b9cc2c0b2b5e8f69bb39","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-c2577a3-1589956028157_1589956093790_0.3876313978570991","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-4ab6771-1589958928113":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-4ab6771-1589958928113","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-4ab6771-1589958928113","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"14074c9ae45dda1f6a008b60b9b2f0d2c030c07e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-4ab6771-1589958928113.tgz","fileCount":30,"integrity":"sha512-jrKQJi5qMkzDUVoPXzA87aMjucSgMtRBsiSFgRoadp6UZobSXGktNXg4Asz2JJeHCTeC4kfob2K67DOwE0bL1w==","signatures":[{"sig":"MEUCIENKeYgR1oP1PFMa5GYVWx8l6G9Guw/nFtk2MlZU+kgiAiEA+0kTgPCgwLZS4xDw/N6wxwd3Xg0QXwANNLnm8Kh4JvU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexNlNCRA9TVsSAnZWagAAzhEP/2+m1ArlRwKUycuacZNg\ngNL23vBMEw4LzJfakav11YKLwWV/6AoSwAUXhuuh41D2AncrJlSwCmyas3GS\nUP1dtE/vg2mGnRIjDMqvK0O9KCR1wEMBhswOvmGcAT7f31aRLenrN4x7L4yS\n0lh3zA0useg5FUObjZwMaOaQT/wuzlWx3J+YE+n1FbyoMn5CixQfacwDrHJ5\nsem5jQGhKsfBYg3gF9d2Vaai47haNEC29Vjbu5IPtrTYLdkYOXMtUOrTDzpJ\nSUV7MxtjbB5gHI5/FsXu5LZ0EhLyy20GF84YrhQCrPF513yC+607yJ8oeoAU\nflinVnl4CvkQzKkCror6a5CO8/QjD90dnG5NDILW3A5em1X5PqWl4ptJohzN\nAgTqt2DOOthl9T1TgCcnCny5Gq44TinEwfe4asX7jklh77+8FH7kpGmmDxFG\ngIUVEVMdcmi2F3lvcaIuREvTl/7T4K+MriVHV7XsPKnUwIT+OPk2mvQPGT34\nrQ5Z+X7jRTo2e5tKr10sqSUUk+9ZcjxLChMDma7GwX39YCRfkKuFplCCAbDR\nAeoWOYwZlmO8pMc6/M1fA+DjqyUjTdn4nRd1ihAY5mOBxW4Y4sLW95Zm6fKL\nE10H1SolqPWnY0tXLh83M7y7Ss0/si7JYBvkWcTQ2x/5q7COvPZ3VBnrjLQ3\n96H2\r\n=TlSY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4e4074873a6c298bc6ea2aff4bc8b6491a1629b3","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-4ab6771-1589958928113_1589958989032_0.012791079634629332","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f0685c4-1589998015622":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f0685c4-1589998015622","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f0685c4-1589998015622","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7dd8b6eca37013850395f5353b13147f6f7fec9c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f0685c4-1589998015622.tgz","fileCount":30,"integrity":"sha512-09a/3T8lBQeEr9rcHLkXFRBphl9ix+ghUdZ9gl7MwQHL1xzv7Qdne/9Jwblkp770Ps0WiMc6JV7NQbHhDBdldw==","signatures":[{"sig":"MEYCIQCJcHpbBw557WR3HsnqRvHKb2ZweH6JOPcKVPR52qvTSQIhANZTbv41Guq+uWuTwuZ7Jqgp+6jUwf1959S8IDVv0uCl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexXIWCRA9TVsSAnZWagAANT4QAJba1+HMHOahavy1Wmi7\nmuPtJ4a/jpCpppfpRq3Uv6oiJ/ZRiFjDZ5CA8sB2BTaFeGcOnMm8i2q2mGf2\nrvI8n3W09E1byv0iRo57vM4dzajxzek5kKLtn5VN85S2EXksm76NB1zz56T8\nNkC9S14yKBzghTNVDutcpgCCbWm5vgRkU9JveD7MkelZX7x8f4GBHVzTNYfG\nT4iB7KrCUnS06710pnRkC1n58q+9uoocm7yptQVtal2TQeJahDjfUOz1YGx0\ngbN2PtA6cXcrVTSheXUQ2/lNs/bawYfOQ+4nsFDcnixJUlSiUUdsEB+LPp4q\nzNZpHgrfiH6+HEt5rgvcXT2gQz6JPKw8jBQoR/Lnzuyb5Qgc8dg3whX1D7ph\nxujkT4ltIVuDF1GEUW3iauo0fJ4RIyYAOks/UbuOoYdoEuIkAnxhr0CmhOL+\nQFEPl8nJzfiFnX7ds3kvpauXKQXV+nKhmPnIaO0mQx/W+glLrThoPE+g+A4+\nyG8Q+inr/Xu07WcGV77qriBPlKqf3ApK7Cxjs/uljmYCxVAFsqezsGDzEMpl\nJZZnRfcDPS3pum99Rz9HtqkdK6KwK0Ci5ukbG/Cku+Uha/GlwjDlsj8CoiPK\nnbTWey+tE9uruK+7ooz5AnJEn4ql9VaayDFep2veCpw6zZzJjvlyLhy8NGvV\n9h8H\r\n=s2de\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7f0f132d3ff9c737d4b31a7e3d6cd449ee89ade7","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^11.1.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f0685c4-1589998015622_1589998101584_0.2960998921117659","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-b1ad45f-1589998172622":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-b1ad45f-1589998172622","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-b1ad45f-1589998172622","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"da8b4ffe1389094ebc36642532aae1349e36a340","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-b1ad45f-1589998172622.tgz","fileCount":30,"integrity":"sha512-CqLZ2ir5bQ+WD5maQL5Hs6IU8bNTdeg74BgneGPX0fwXtMbURlz4/bAqGAoks1vLpVFfSTyu48DW0vi6CiOtag==","signatures":[{"sig":"MEQCIH7iqh6qrf3m/6K/jl50s5lpVBlElgCsbT1hC+Rhl4tfAiBd0HyU/ttkSu6uETz6zDis9SquMblFyZvq168xCMiieA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexXKYCRA9TVsSAnZWagAAD4EP/RygbYxKByXl9DEKBJcX\n8mrQXwKZNemxiCVEZ2EFonJI+szznB5vzsTILUuEPnm2Ms6papddRYTS29GM\nxyjesvh0WTVX+nc6meziZ3+1b0tieuCe1qAa0HFfLDA1lWfFVEk4nOcLzh+d\n2xaTSB0FAwz/IBQtlIYxb2k2ZdHglIIYYCJ3jNeWTZlFdhCTy12V+j8RX4Gn\nmmQr7KBj/gs45NygvJ4EdU3DisFMwz2ws5Egm/9vrK01RCq282BuXJls0hDH\nmNUmqEielYaHoeIqukvlDp5jpho5IP5DDC1kEf8Er22/M6+FhQxmLyO42RlI\namuHYPRb1cZbEDxkDra2Uexuc4Xd0lo05jKcAeHbnTm3QrSTwLS6KwOIujah\nF/dtyeVQd+TNLwxB7WbgSc2XYRlE9wyejUbiKm819TvlFZ62QYK7FX0FKSA2\njZpjSIwgS3cJ8KxJPAgPGFLWShq9Y5eSLuDHUljFfx0243PBzQRlrrkp6Vbx\nmjJVrvyQxHdWPVjF646W1mH1gzB0XS8/MVWoRUjZR/oT8kPW7uvwZFds2Saa\n2OgJQzHAeY8ClJm2pYsCezPPw8+WQeLmVlB+k3aUO4wC6wv4d/EVtp89O2mJ\nVHG1vXEveFX5wmMtMRBAkrs7xKrm2obRoPMVTnlskXQWcNG7U0/VDCfp6sO3\nrqSu\r\n=REZI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f8cc0ce38591e8ff81a20621c2fc29d6ea131376","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^7.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-b1ad45f-1589998172622_1589998232103_0.9964584632621116","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7ad7516-1590059711971":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7ad7516-1590059711971","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7ad7516-1590059711971","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9d685cd0757780aaf57285fd527519f46f86683e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7ad7516-1590059711971.tgz","fileCount":30,"integrity":"sha512-bRgMqvaA1nqKzi7kWoNu0oFNWjgMqkeXhjgH+XM/FKR98ihSELXe6udi73Cx98kUOT2ICDsjZfYp3ovA0ydx0A==","signatures":[{"sig":"MEYCIQCd2xiix9SVVAADOmqX8fNW4F2pfCXn/6QZzTZzRpWQ4QIhAIfRTiFWHvMihnqvsRcfRGUiPfKWGf11bFQNMDqdUYQ7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexmMBCRA9TVsSAnZWagAAIFYP/jt3NzODXNKJr0CtLzfn\nzVMPlrmjx79puynOo6rz9Tusabi2p5WEsT0U2E3kvF1fpUxS1jBETTiIXtwZ\nQkICCQP/GnR4rFvDR41/hOuD5G0zB+xjvO5V0/299/xacascncC4inG588KP\n7QaAHsYotNw5ISsdFtUbboimzFunySEs8yYQd0+I7EUc/BTzAiwkMuo33+Se\nomYzpbPz9/iiNVBtXyqahb/iQGKPZjfVzJ69xBOj6fWy6DvcklgskVHmWN2p\nYlS8ihwokwVn2eEtVGCZEDjHkUFau5mskM2OsCNX2ksjZlzRMM3dNquJddhl\nJWBlVAJ/4NJFPwJVIoLzfP9euDy+OI8m0azBpLQ8VYHjTYBWxCRPMp4rtjil\nJko0US3EhWzyCJF/ZmqpGbGxy+4jM72KVK1EDIcFFQMV9inTq3iwlho+XbCL\nUFvoZcbMRTQ2E5a3ay/KyihtfBiY17QBG3fvM2Wz58v/ll7oFjExI2r0oNbv\nxZ9HVyZ968uvzsNPgCXVjmkeIQzxMc3CRjd1keXJM4cKSg3TcZ8kSDTAbR8W\nN0HIqb9KmtyFQnDZEPYyEG/FikUi+Y6WvUw5MFPbpUcjQx/rB47OH0tRf1M1\nDBFAutBhtol4jTR8C85gi7vSvlE3gf3K8o0wUCE0pf0zvQNw66z00QyY8oNs\nV927\r\n=Lfi6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f77292caccab7acf048a9d187a39c3d6086cfcff","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.5","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7ad7516-1590059711971_1590059777165_0.8306549311153024","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8ad21b8-1590128180921":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8ad21b8-1590128180921","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8ad21b8-1590128180921","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"06024cc11fa3d2b4e9538857b2c0072882bb0016","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8ad21b8-1590128180921.tgz","fileCount":30,"integrity":"sha512-cSgsWQB4JR8XTYgXFWJqdIIHlrm5JY5yQkoSsp4PRLeL54fGhfp4JLTn1XYykpIppNPOIW21WOv6CyaAAePjSg==","signatures":[{"sig":"MEUCIQCbu8sHl6cIAlucDO0kDyb0HfJ/qEPziIWAqb71CuloZgIgQdQTnn21fAQ0W8EDe682GmrEgqJMUPcIwvCqD4t9fow=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJex26HCRA9TVsSAnZWagAATzUP/3t2zwwvOsOA6g6uYR/u\nSJOouo5ps5/yzLStycWQ9igrhE7f/ly+lHbaCm24Vrrm36LylP6LWS2m7/2B\nTZZm+4O08hdK4lNQO4gM/oHmzIGMKdxnA5s1IOZa32C4dnL4+JBBe/NKk13B\nUZlqD0QuYPO+iH243CX7hoEspiIwCPBY/wEc0ai07cG310Np/K3sdgzrvaBH\n+zLISW3pjE1V75SuN6sgM5l3vJYorA7s6clyiCV6qI/B2OgS6m4X0jh90Ulr\nXbe4t+yywnRfqATi1rpW56s89crdm+2sM8l8lVdjQx7ejuEdHrhworHzeGBa\nO/RXlzM50Qeyeg4dYciz8k6EvewCNulaUg8/C3iW+YxQN50w4gneh3q5iMqd\n4dSTkuSoioUMnBzVzb3FLTvOI34+9ITZX2m+yhgnfY+6Cb6ZmK0/VcvH87ip\nX8KPKDhkvbzdr3sWSn87giMU1NG90+7wMhAgpbKuO3L1U0anT4jh/sqt/NBu\nZ5fdBuEhT0zrtR9X0zw+ESjDN69tcOlSedCD7eFenCQNtFdzpBkRKU1TC8DY\nFcfXWbIRwHGU/8+YVbW4dPMgp3HuFJ9oPJjPZG8UnMmBFrtQCYqicX4j5qky\nVfu5l9uwWThI+luhoSmSl2DtVPTETHwh1td8BJHu4vBOrIjhvDwhyzdBJfQs\nphxq\r\n=/ssQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8fbf1077c2d967b44f3fa66b0156efce2ecae1a4","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.7","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8ad21b8-1590128180921_1590128263032_0.9529845424286394","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-4edcf0e-1590214094022":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-4edcf0e-1590214094022","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-4edcf0e-1590214094022","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"67539ff253e33786171cf6eda81bd970781d0453","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-4edcf0e-1590214094022.tgz","fileCount":30,"integrity":"sha512-2iZvUnCA6oLnnkuc9P4BnOHzUUEgsuoI2GtK2mDHRtDSUrIvOGypp/CnZYfSuyBVeeCBIDBGHvre9/7lPeIrmw==","signatures":[{"sig":"MEYCIQDNzrLjyRURXM+vaqxeHv3QBlnMJlVFeS8lnUCU4JYwLwIhALb/yedcHQ0X6+ESBCJnGqY8cL/t4SuBS2Lw8tO0vgib","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyL4MCRA9TVsSAnZWagAAp+kP/0RwE/bZg1r1WLIT+2Y+\ndvJRQKgnLsVHYBtTJYO+4SLwl4dvdYDLXCLWNCg2koAbRcBnKGvgmWU8TZWI\nGrNwXcqoxu+57Zfj3zUOsI0/quf+cWJwiSOyO0RAl27z9GAsiz4z69afLakS\nrQu3NQPbXdNNaIvXjziDC/CllSmffuHzd8EscIU782mdKwiIwc/KycP3vncV\n50lYtUZRLxMkK/ghcocja0V8xpe6mmD7YUGJ2a5M6ADgf4b52TTZMIP9YFvo\nPaAmJmG5zCQIA08RBXbgxAq3QKBaeFdW9YuyYJe3DLLTrNr+y6l3wteHuBzd\nvSznUCjlsRTOV0wG4oRBJmAmg8PgAFKf1TxcGtDzwhbdL1SvjvC+oWlq0R42\nbJed1YJlCZpN9/7qm8Yi5Jy3XxClwscItGR70JQkP71k+g2F5IXGj7xS/qGa\nGfmBBpa2BXn/OBecoa+LcyvfAsxQxLxbSoSpEJ4buhQ53LoW+54TKIBWWCtj\ncMgOmqs6g9CtI7uRygDkJv5DkrZjIEOTQ6YESDaAHmV15lzEkOBOl9iZrhsV\n33R/T1lBDYcAxFC/Utpr+omABunBTYtRmtIOHp88b8aGzfqkpd80267cgCMB\n3sXU515SMycy509Sjc7yFBZ0b2scLj/QZbzcYhVL6blegTVUbyu8mAU9ieg8\ncamA\r\n=BpYJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"88db5299271092e01991d88f76c88c4cd5f745b4","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.8","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-4edcf0e-1590214094022_1590214155472_0.7720028289019707","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-3f65a9d-1590228758815":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-3f65a9d-1590228758815","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-3f65a9d-1590228758815","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fb0bb6cce2a046fd219a3b27da66a79c2297e93a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-3f65a9d-1590228758815.tgz","fileCount":30,"integrity":"sha512-e4Vf4vG0zt7lBEN7L/1bk8vLubNtuHd7lL5n6GuUb/yLmB92WC+db+gyM1OpRDf5mqWb6KxTh5tk3D41J400sQ==","signatures":[{"sig":"MEYCIQD6rSa+z5GVgqhzAI2Ex3wS2ksdAvX/aGhF1EzdGZ0aVgIhAKgWAYdmxKHOHvp9tBoN6V+sMf7kVIjY+f7l/mprhVQY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyPdeCRA9TVsSAnZWagAA2AUP/iW89ML+c1+69jaeq0Ut\nA/xIhyCl64PpA2rk+p4ZOb00GGq0RQggjejPIoH0F/OjVIejK8hl3AsTdbY9\nex5PHPqqWQz3kfFlVIKGjYJQ1dqDdEjYNhj5h7xKBVlzUMSlCbo0fmuivbtj\n7tAKJNVtfp5TrX1Y025+5FOgdt/0GbKDEGzwf6aLpITMyqsnuQg33TU/O3HO\nDm5h8MlMMv9+mc3LPtvQrlMl39spJ7rl4ISQUa12CULDSeNCgcYBfqXXxirB\nPtQV0YH2kHf5l6u4Bge8fD8Y8WgdB4AP+mH126OLdTafXjsx+e9VNJGadP8x\nVDmPGAWu5STNlOoRQmOZI/BlXFW7D8zj4ZwB84GP1V540qNBYlLjXmFkfJjN\nVU1s+BjwxreZ7baYwVlVmgUDKVYIuODXniBJSyXg78Cs/frki5OKZY+AWLV9\nwBna8sqvk5FTLaGLpgp4GEiMLwYByA4bRKKZq+VOQGcRsrkFff3k9v2+Mz4B\nI/gmIHw7Iq53vDOjEN9gJG9ggemmtMFKaPhg4Xx5JpXvbCJnedUAbfwe4rIA\nfWRyfm1gdFs1YHsn+u0/co6EJCpfUItb6U6XnTuhgheH1B3egodYNosgFLY1\nUTflvIeJratAIanZYeYYVXtcZ5hwbYs+jhSTel3pZEaxLD0cWQ/gMMvPznzY\n5uxV\r\n=GmdG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3688730b1788fea7fff60d858cc6048d4609656a","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.8","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^6.0.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-3f65a9d-1590228758815_1590228829638_0.12932101779968086","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9e48ca8-1590233006234":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9e48ca8-1590233006234","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9e48ca8-1590233006234","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eda5038379d1bccc5acef276633192799845337b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9e48ca8-1590233006234.tgz","fileCount":30,"integrity":"sha512-9DuRqTO/5OHZiqxkaBIwqKMWr0B+twdue4UjvQq7ycsh6PaWvm4ttCccSr+ZhrI6zE/gx4/GUpByOzqmN5Jc+w==","signatures":[{"sig":"MEICHzcb8vTRzRHBYEgVn2fr1Q9smHzW4Pd2sqteS7ccy+YCH0m+4O8kWnNCRLZ+x5AEbVz+loki8wuVfTaQR2ChZiA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyQfwCRA9TVsSAnZWagAAui8P/3VgwUNdqcqc93TV/xlG\nfHMjiku18qcret/esFZJubgSao1ik4bVq9LSycsKhxtGuuGoVmfZSKtjeIGc\ngElfH6NKEF8qrAp8ruBo3++Y5eWtdjC5WGztCH9MYcboqs4BonQToEmVXs02\n3XIuvTnATsf7nztQGHJR9aj35h649XTQnZm0WAomD7vCOJ9S2TPGu6oJf5mr\nTPubWfZJNF5qcFdqqoXYVs25Kq/oft/bw/mq0HBB3bjVDH4OVhykl5PePLAJ\nQ81koGkYjjfhqQZC9Jf8hNaisFMoQKI2GGsT9LSCtawSJrJFeuJ7VmK8Pkbg\n/dVvleMwANJkjQwDRWinSHz7mMrJS+Hgf7F7mDpDpojYAdJILwieP6G5YJ8O\nyqraVYHFhJu7B0Kq8rGEHKpo1jS0ykfVFWJQPNNyQmnVJwZ1MqiYveDOLg4K\nQcZ4yXvUA+h+bSm7kiu1T0ZVBIaeKt8V4jkQ14ETdBUHM6NcDUSzayrRrcTm\n9HXuYT+SzzZXmtUShGrEYymaoWujsB2GUHmMTEW2BSOwSNFI8eo5ZwOa7gRl\n/rcUrg5l94jGM1WMsE00qLGTfeLh0sSNo6AseftpfU7+pRR4n1Ehsix73ZFW\n70ZX2BmKWFAmQFmQ7qwJ5lmqgd1xUADk0CnjslamuCTXRbbSe6rILPJu1m+r\nxH0h\r\n=lwuM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"68ed91ccb8aebd7ec76cf6017fb9eac0c38b9f4d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.8","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^6.0.1","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9e48ca8-1590233006234_1590233072338_0.8848670491039932","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8e6c45d-1590302766098":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8e6c45d-1590302766098","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8e6c45d-1590302766098","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5a45fe8d44599a3a1ac6e93a0c1ba07fd09ac5da","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8e6c45d-1590302766098.tgz","fileCount":30,"integrity":"sha512-ofXG1C0o+lf3r2dBKcHTYDccSwL9Xt+3NHux190lTnXXsBzfPOD/gq7qi3ktTJXd7Se/yFTOhGi7Vwa6mU4hpQ==","signatures":[{"sig":"MEUCIQDzTHCFORoNNeUdvZz7g8E9OoIVBRLiuvvHSI8HKHXqIQIgcwa3nuDs89OFRSfNxt3OG156F6rpUaQ1yuJ0cAQ9ZkM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyhhzCRA9TVsSAnZWagAAt6IP/juiGx838Grep7oPDW6R\n140EVRbRYgUIV42vW9Ibjm7Nwkmdmng7NxkxI3FnpQ3yv8XstEePGcRDvp4o\nkFDv4ezWGgoMbCrU9Mrl4sDglFuMjtC+05WVU9QQsn+Ce9CxXqY2pOWCChS0\nXcAyK0JgmC2IUSjaTeloZdKwMPsfGuTqEZkwosvPcMSFCojlYHa1qwAwNAcJ\nf68909n7L8g200S5/ZXaDBrgMe0Swmqh+QG9leS5nIoq5DlLCygJb5puVq0u\nLP5pamzIcnznXEKcXHZsYIq+xIUJt/IcGGfcDHWTOkAs+Rc7q+wAVBWmwmki\nIaV9wRDOCb52yV0NWmXawETU2JCNNCwVV3eVvjyOVohBBuF0K2KMvZBUsKJN\nFc54qoQBgoGuuf0PYxo4bIzNypLyeUR/9GQascPqXFK30mAMOhgNdufma+RI\nrcafsQVzPrm9Og8m56gx8Hw1Y5hEMyJkVy6j4ZUBs4KXbBlfJ9hg16QAT/Bt\nx1x+iKvnAMnScbemDyDZFfOvB1rLJ4W8fzUvv+OG2ynLtVI+V5w6C39QlvJm\ntftfBPMTcfwXAYJsPss4L0mPs5b5RzK9b+jcP/6I2bXEUdumI0ML5/jOYbkf\nTItyAhoU/nHS/itHSrE2viWGZFlMPosT0MgGTN9DKe9uaEB+eUc/OHv74xvt\na7xM\r\n=/EJj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4e3fa5216124418ffc8fee9990351f7f0f21d193","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.9","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^6.0.1","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8e6c45d-1590302766098_1590302835312_0.10940140016250077","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6594d5f-1590359171584":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6594d5f-1590359171584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6594d5f-1590359171584","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8fa139ee95b7e14891911847adc0d6c455dd52e8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6594d5f-1590359171584.tgz","fileCount":30,"integrity":"sha512-bC7cst9BT991zfhl+WsW6qTriQ5V6BUhsvN2VzPVnDdboQQLMs5d6nlvZSxlaeuLSjYrv2ziDTwLkh3EBE1Byw==","signatures":[{"sig":"MEQCIFOt5hHnewYLUDdZ+f6oVg4Gx1ehU/5KSU+vPSbpO1PkAiBI6UNZCjkxp7a46Do9hzJedUYGvuVwNXTv95n+rX3vsA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36416,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyvTCCRA9TVsSAnZWagAAJ9wQAIcKyMrxXC6txnGWjs6P\n9yJGSD/vza97ZnMgIp/hvQNaKECVucxDs67p6DWZIHyT3pg81xp5lwjTDk3l\nY+vXVdCqQCo7GjmRUvKqjb0yQnX9hj3+RK2IbZ1lFjU4pOKBKx+aIr7WzrgP\n885sGCu8/TPnuIlMq3LPB56roihxeuRCQmcb/sFBoPaWKwpv+8X5z0y5QTH6\n3HCXq/PSEtz60Xotv8q+50bUvSk3XQ7uKNQFzpwqIMdBgqeKshOo+8SqK5iD\nwR4/hXT73DHagwnO95b4enek70B4jnYDcI0iu4jf4i1MpQb1o/nscfOQ6Iuh\nfVczOpmm95bOGsG78ctDKnlt9Z4hOBqljqShBal7VOgnQJr2l40cxOOWZAn4\nww/o8s5Ce9MmLNMA3rxfu2bPgyecqYlWPcvVYQ2VH5EcEJYDLSZd2SUsTbZa\nWaA0bXG014E9tCmI8wB3rjc5kipRqM/dHk62iE0WVh8zspqEhwQD142npfGX\npdioiHihu8EcyKZsxEDo1kUaW1+POAEIyGXyrHp5B4n2TIPUkElBX/x7M+3T\ngQ7U7vkwUlCpMKDHKWRhthPf+Jzu4P77jV50dGNIcc1hz6pQa7iBBJSn4NX1\nxIlO1XoApEgZHhaeL7YwboyaYg0gljrTpGotxnNvS2tO/aUpR5pw55Cl3rn0\n+/WX\r\n=E8UN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"17faaf2632a6d66e252bc831bff40dcbd1eee02a","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.9","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6594d5f-1590359171584_1590359233876_0.9974895799645405","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-c5557b8-1590530828017":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-c5557b8-1590530828017","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-c5557b8-1590530828017","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"53b5116ca4f9807543b05c8160b8e8e73bc84752","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-c5557b8-1590530828017.tgz","fileCount":30,"integrity":"sha512-ndVL+nu/sV3/0hFxF83DQl8QWgrGdAO3zfd5uaUBzFqPYR12LMdvtpY+qc70THizM2KS1Acq9cFJTuGAQ1EgxA==","signatures":[{"sig":"MEUCID2hlOOUkTou83ja8fJTGV/yS3FgvNQXS+d0FQ6XVFtuAiEAq8KjeNPasmhyc2BBR2fSD2TAIHuiXma+JAcwn/7KMSM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36417,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezZNGCRA9TVsSAnZWagAAVRIP/RNt7KuUhQu2LI7Azt9I\nA55P6XfQHJZKx03gHAcgz5Fn0Ns7gFKmSsI3sh+mddt8nyTZ65A+I6AAhi9a\n12oWBsN59g1F0l8rBfgO5UG+sg704IvvW77gVxXydpPnQMCAL1Gz5Rc43GeI\nGDfeMqq1Z6M4n7ak5CEm3S8I6YUkcp+mibelslLdauzcaAfI8UUinP4BQQpM\nAbEsKN8ExQZ2C5wDx99yPTbh/TF4a9Kww4AwbykWwIThFj7GxgrF3dMq1qsK\nPKJBXC34QNQP23ZHXDCUCKJX/hani3l9oBXQ63Wrj3oSyB4Hr0mKMQGkYesb\nw8GuaV9B/nKodnsViiLHw/o0ffb6AyNXx4UKj2FLK7fSweus0+ESTW5cYi0R\nhz9Cm7dL5fqpreKNvo+XHRcVaLMIFC8aZ2didkaLF/zKUldwNp5ZaU8dBzcM\nvCpGd4iGgY+bYQyk2YOhjsKCDIYcDU8732xBVvISuCN0I7uFQfEDOXCzUw6U\nAfy9v6pilC3N+XYKr/kfOkMF1FwOrES6e5cTppXXFzFytWwGKDGqILEwCrrL\nCdMyZqdM/+ZYHZTeDU/ZyaQgNMPUvEFcbUeIK/QJinrTBI41LbyViv2Ed+a+\nOfGfEQysmu2zgWdNlVC6Ho1mln0N/qT5br/k+eXeg6/olG7ZARH6S9MBa5Lp\ncfcX\r\n=ATHw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0c394ebe67110d03a2953207db3c45f2258a29df","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.9","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.9.6","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.0","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-c5557b8-1590530828017_1590530885585_0.5852799100347743","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-bbf25c1-1590531607057":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-bbf25c1-1590531607057","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-bbf25c1-1590531607057","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7fb44fed67fd9a9147d8d2ee5439d84a1d953a6a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-bbf25c1-1590531607057.tgz","fileCount":30,"integrity":"sha512-szssm2MnxHUZxi+dn2REiDA4VAgliOkiWgBwRWfb2Egqkcch6OFGJ5I7Jp5nqg4zPj73aBtv9bfP2icSSXcMcQ==","signatures":[{"sig":"MEQCIAdYnotBeSVgnHSxVHlG0TnO86pmwTWklWet5tZ0YbC2AiALty70DA1bMjG75tdPXiwjUWR75jO8bFKyympMC6X9dQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":36418,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezZZiCRA9TVsSAnZWagAA2MoP/iX8llcWPg042cNvNJmK\nOc+C8LWbaEoJM00zReZP4bnDgMNLhy3olO8KQcgMt9JAsusjCutj3M1JmzNp\nW7wjA4kc27yRqyGAtAGicZaehCQ5OICUQcj+ix9QC1svZH5C7fZDJIL4SoVH\nS7818VlbtZhHYLSdUZatMv85drBy7wCEenwsGm6wvggDumrvpYMIyLE7VaXT\nciZ8bsQmhvo7epRQ1gqx4UicXeFuoguHRwFBNRENtpp7kswQS85IYV6ePr4B\nSaDBGEhLTe6qe8p/lWnfvPXHAkO6QfRNsAZYr3+4wslIabwm4d5tkWpJYNfr\nbQ4rpTMuodzOOy5p5cTTZwC/ef1rvO0gk+8eRZC8721gNQyt5IvNC71Itr+F\njYpRyPYmsn66AtBfbWyxHMjZmIV2MoTk5rFmZaoOhdE6rwpuLSKl8o3RFW8z\nR/B/hJA8qiY8YBlCaGdAEsFRKu102AsDud0KwJ/UeE4lQp4RadkEeiTKhuy7\n2wYaR5B7Fp7eqxf5qJhKiXXMaqZEm8QxW0uvj7AgsQqIymWzKYyKCnwdJ4hO\nsM6avhMP1rG36mabnvfCk8YD9LHug0YYCXZBlC0nZt3ldUp3Fy4QQGoqIqpZ\nhJ/Eya/B6cS/qyokJDwdiqCNQ+Fg+VjCwCALJBf3KtJYQmg5Wszme2lRcSWR\nKchY\r\n=X3DX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ef99764c3bd9b1cc2ac10589e94e980c71dd1bd5","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.9","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.0","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.0","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-bbf25c1-1590531607057_1590531682294_0.46101781701902866","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a4fe5e2-1590585435360":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a4fe5e2-1590585435360","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a4fe5e2-1590585435360","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"29073c3284e4e3bf3d695685da6793079ad207f5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a4fe5e2-1590585435360.tgz","fileCount":30,"integrity":"sha512-/srJumd32rZJhg8Crj+RX5gkzFqNuS6l4ouiRyAlvTc70oX63Ld4vW/Ufy33X1WFOch5RIm5LNHt32UZDAfWdQ==","signatures":[{"sig":"MEYCIQCcjh13lAI84D14j+I7mhkhsArLu6vZfe6vAex0WwqbcwIhANdLx12yil7GN1rtwD4B4pkUmS57U75L7CE5STUpegvu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezmihCRA9TVsSAnZWagAAow8QAKHWIBddAl3O6cRguc2T\nX3voIwwa2vYo58xyQkiEhJP7R82NIfi0dOBf/S0E8mWD6crb6mY+mbM9Zns+\nhn5oifSFTbAdS7qZSUZyeN9AszjswKBsvOVkORKiv6kguOKVmSv8wA4dYdvQ\nNXgRBMx1tLdFdwo57koPDQSUYVmmkOtMccXPmi/h2Fq6lrZE6ioTMBIVd8Or\nEqFTHe0kvJSDtirKK+ayp5+P+2i+T331ESk7h1RhRhGB9XzXUGvQhTJQ5mPE\nw/XGkxbuQuLBK7xqqpq7LLd/gr7d7IqxqhnO/MeiDPExifSjWwXMHBFRHnTK\nDrlMwdTeBw2ZUq9o9dh4JSz8GsIG5zfA+yhCuNMejPxr0Q76uGWUjEoco1eI\n752Ve3EPfz75L6EwkOr4+CWvy3n2ua5accuBdFCbujLysIVEf4ZHk75afm5R\nRT1QGtGDKTsa1RmZqh/8vkBAMpV7IWUGJOQJHnlPHxrjcdxyOcjO+lMi7Gzz\n485X+L2jC2/3du84OBJIpS/3R3CDtOpIHYIzwPg6Ca61azNDZQ0KpA1EdhsF\nZ6Kya9kcDEiILSq8DrQb9hyTJvdmd4Dy0131LrGDYa4TqHhSQwVy5rD4EbAG\nJ9lcNK5QzidlHbFUaIWOwtIZr4PDDBtgRW4IRjvVwMRH5qIKFRs87vZrgIZ0\nMDHv\r\n=sg7D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c100fe9d8789ef1b7362e352275089f2ed1249df","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.10.9","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.0","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.0","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a4fe5e2-1590585435360_1590585504617_0.12767533760007943","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-c597184-1590611557015":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-c597184-1590611557015","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-c597184-1590611557015","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a46e0ce158e27dc2b596dc2cae56c4c45888a646","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-c597184-1590611557015.tgz","fileCount":30,"integrity":"sha512-Kw7EIkp1caCToz9yFwnmBPnBN82I0u/N7TtnJ1Nk1RNzsbC+RVyil1QI3jfkMlDLlFQ3JnusghS4i35bo+AR3w==","signatures":[{"sig":"MEUCIQDh1LnNHmc7non+/4+Fpuj6Ph0+Eijeyon3NYyWaJ2WqwIgGwDCjlllWwjNOo0XnTnpuZzgcoWigtdsS15S5e2spC0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezs6hCRA9TVsSAnZWagAAFmEP/3PzTsa16BF/ejsJhXY+\nFL21oJL+zq8vfmp28f2MRi5eyVXxPD8aVAipQ2TgK5zuStoLuXVizM0RdGBT\n+6++Z3NRtKEhtAFIPqUWnDWu7HzlBwvs14TtHnhte+6zZPK5wrQrkTvmZCRa\nWYHUxOE8PjOnzQq4Qd5HMlolL/l31+I/COPNes3ztz4YetTdmqAw6y0oEunJ\nmX+PYOy7uMhx6r1w+Yt/sRZCKlSCO8gQ6WrImLWx0CNcCaXBgaKPrkdIZQT5\nsUFHlFEdd1HjQX83/yxAwqyF09Ef3I22T2oRa55jManXGGS7lXbJKnnnZbmN\nY2vIsmJIOqn8iK5D+cnh00jLcQqENTF+k5Rd/gZHh4mQLUdPd9TBXzIrsZIw\neORiEu9sPXbYg2h8KNan/U3SiB/gHeUOxU8NfzEa2kcYIHmzrQisDTBNPrIK\nOg3/yJjXhNQttJgCACExuognxYtMcPjULW6kDliEpZ0MXeTh7CFM9X0KTlZh\nRWWHnZ08MLk0Ea68lTB5Uy9KSnMUiHjMrcvqFu+nRDhHI+6QfHdLiO4FygDX\nQ8w3yENgCAtVPZN5+XyB0uMJlfWMhd9NKV88ZCJCJkd6loW56pWoInPGYQMW\nAVjqHXxc1FglD2GlOUSrbws/FpEPP6CFF6RwS5xBzQtdEbtPneeFhnvnIPp8\nOoUc\r\n=N7vr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"92bb1615d4df52efbe5a6dc306130604247129fb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.0","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.0","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-c597184-1590611557015_1590611616746_0.30371666178026846","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-21d62a5-1590623145112":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-21d62a5-1590623145112","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-21d62a5-1590623145112","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"729d9e1dc266fdf3aa8f3e5fc31a23038edb4a98","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-21d62a5-1590623145112.tgz","fileCount":30,"integrity":"sha512-BknR/Rc+RzrqwaMT2p/0BU+4x+OrB+TC77xMT+43Besos+fSxd99PJtWuVpZdsMRM7VD5+NXrYNjKr1CY4hivA==","signatures":[{"sig":"MEYCIQCrJOIqQG8rjScPpR9C6EUE9Vqvyi92Rb5dZMdU2gPfaQIhAJ9+iWRuCgWeUoNtPBl5hVfmaX5lNQZam5REbAMqJ6l7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezvvrCRA9TVsSAnZWagAAIqYP/jIiImXJuUDwD7RQ7i6b\nlxAsaiZFEoalwZBKz/KMDdu//GIXw8PhcUZP5NvGpUtbSjWtYu+r61q1hD4m\nmH+5vMhU9csijqwotr+LBv8ub9VJjmhQI3nNlz3USvU/ot3c/x6fXJB/r0SL\nviOZBd6OIi1ZzNO903E1vFaInkE6iikGs9hrEXtnBacuf+Yix7Kh1upnE5L4\nu9tENl/Az1oXO114WjTlxVvr3oDLofXarZZE0mSf14BStct+1EIaLyR0Jxn+\n2fZmEJqUFPGE/eBMq0tYynRRxgbV8I3OuXFJvGWGqKNVdsDEsTy0B9qk15PU\n6r8xrncfVXVdSI+FP3bRu86V1nlW7FGCmp/P3hq8IWQUgpc3Pbv+A4Dkb1on\nEG3XUCPZjQ1XKvDocMorpVNbEEBFBWnQmXxmHY0F2r6jYQa5waMoQdtU1XYq\nCIx1o6jtn4q1DROZJHQRsBsTsXXO1n/9C2Wb868eghdgg3sjbWf/BYm4yI4G\nBMyinWTVk8NPQtOPuVLEZJiGrui5d0gluqicS9a3QE2nuE/WZ8/DUpjS/Qbr\neFq3VywAHfC1EDwXFIRLy4oNIBJ9RTLV7Ej3oxEBlShitjVcvZqX9a1KxmD5\nU6nwsM9lpUPPqtD3fouiNKvrijrbdcOizkaklCIu+1xBHuihFMowS1JGdGjn\nktd9\r\n=6j+H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6692ca7f3f374f8ffed4fc4d6f5a5ef07c395ff4","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.0","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.1","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-21d62a5-1590623145112_1590623210868_0.0839416820912251","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-640d168-1590624206671":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-640d168-1590624206671","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-640d168-1590624206671","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bbeeeb4db685bf521670114f33e3cb1f6c43cafe","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-640d168-1590624206671.tgz","fileCount":30,"integrity":"sha512-IoDmYMnEcXByAEf45Kwfdmd4pEs0qxRkQFMmXq/wFuNdTiyXTRgVsMB5JUr34da5CrO8AYtxgqxTvrIKuj1buw==","signatures":[{"sig":"MEUCIAZ9yePq/nLc2cTv+Mj8qKVJ7dE9Seof0WAEVtiWUFzmAiEA/Q+pPHmaL1hk7iZZcoFX64XrMXrAheIibhazAmyPjVk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezwAoCRA9TVsSAnZWagAA18MQAJ3CAI5N+cx9rjq1XFmN\nrMP+hFWuda60TZ4D9GLYXpxkGG/dg6GcLVuCZ4Fct0rTwFwiaa5j3N3LFLqp\n3x1YtbKNhvLNOSlGM3MO7d3a8Zo7wXAV/FCa40JT3vvbe4PI8aOpBFo4d/3c\nZ4j+Y0cofWkUEwda7VxPsOqys1em5ueCYQnLCfYb7YMfotYr64SyUBN1JpXP\nVtfCsHIt7SvzQ94JgLcpB5H9w3nr8920wjpalT4mPNeQIYNge8YjMkiU7cpp\nTvYqJ7/8f6zvW4J6PpHV7Zn6HrbFJhBNPLKORnsplr0PM2mxM56FKEINWK7F\n5Yacb5sa0Lo1n7Fx/EkQFPf3297zYjC1xq8xyJtRmSKhN0hiCynFOluIbxYd\nGzn2ADkFiqa7z90477ncelqm68fJ+l0PC3eFSdlI/ypmO07bz1nOEqTSPDbi\nMwgDwBBLibHHBay63uGR/cVm8Y4nDfERkQxMGLT3F4b3ulaY+E9XvlPkeL81\nxbbTAAjAIEN6dvBLi8uKucmIa9ZjCojLABe1pm6MwUmF4Ym6zeU05SFo++Dk\ndssMe1CXO+0UmB8x21XCIft3jYsmNvngtOnmP+5/O5nIi652w8pncLb9X7FY\nEe5FKfJVwEerDtJOT5cABM8lPcDY+BGfWHqHA399hFWMCXxTBgZ4klWGaizP\niIJJ\r\n=8wpa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"fa7b8772d94e14085c93c8e3de6be1fedc98d2fb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.1","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.1","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-640d168-1590624206671_1590624296483_0.8100936483862178","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-e8a4bf2-1590646985820":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-e8a4bf2-1590646985820","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-e8a4bf2-1590646985820","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0cb91d9622e5d4b65116af90eb54546089db63ed","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-e8a4bf2-1590646985820.tgz","fileCount":30,"integrity":"sha512-3zjM1CkGRfefY6ikM2MaK1yMlD+ICOeVTJteNEqaEEjq5fQmLd7GngwrWJHKVQQuF0gCuoIkGM5nFXSKE7OftA==","signatures":[{"sig":"MEYCIQDcoBe6qx3PF9Z+HQMrWVlfa1TVMMjMBT3lJg7rS/r7KwIhAIjuA0ELtPfzkwGvwSSdXQkTDW75+Pd6sDas/tKHS3DQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJez1kMCRA9TVsSAnZWagAAiAUP/1nunoA5wIjiq7fMrJ/m\nNQwKdn4B2sDHmG67aLOaalGPr9w5C+omU+kD9LbGdUPfF+IFhgfuAtJEOZdX\nXqDSCF+9fNZM/+e53uxkfIrhLfJVMLfSdyXFQBMMOmGH5H+qsBov52pUi6fA\nJiklcq4TZcAMVkp1XYp4ltxovZoI72N+HAChCz/QqF2CYNuz5t4p+nUkds3x\nD97Y1tPOoF7yD0Uw7DjF3iBapUTY5CkBsdBBGDdE1gcpk32TCh687ze4mpln\nhd0ZdAW9sFYI2lJRc/h46N468Ed2ceZuLLilS2SX6/YQtotkktvj9vQUohPj\nj4z7AZRkvkvfiSFe1Q9aR5wf6Txjl3axuFnmGeHzNl+PJB2IbulUAcY7EpQ9\nru5DMISoeTP2g04fYPzn3JKmMSQA4ON678h/RFT9fjZ6Z8WQf1+Ia139f65l\n+mdhJGHO4NrQUIAM+G15nq72ZiW7aLASD1PKXmPKCvldnW2jchvu9FKggfH0\n+5NSSJAWlrcVY2UbKRbH6RRtEMko8tB6MOHVkhMVeKt/Xnbm4Y0XqfpH6g7c\ncgek8n0bUANHCNsrJ6LkkoN+mZU1Fd6U7GzWrqIXu/Q0WlJhY7i1HG4kfq1g\nGlsPsNdRixCdf3eHVKrc58UOWgUv5fmcELJlMjsq5i5886YQEaZjBNFQ5CQ+\nlU4u\r\n=ghtW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f6dd6ae65120eabeb7fe76efc6b2c826c9f9ca7c","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.2","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.1","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.1","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-e8a4bf2-1590646985820_1590647052042_0.9956497817798369","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-f019103-1590870386373":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-f019103-1590870386373","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-f019103-1590870386373","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"558fa087ca08ff94147f4b67d59cf327eeaf7b42","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-f019103-1590870386373.tgz","fileCount":30,"integrity":"sha512-A/poFHdl42s7oTVQaigKM5JmbkBVqm5M2JcCmfZEWSqIIy2bPA3RmXk5WjSYu5HYWn+sqTjS8oE4iUC0TXa5Bg==","signatures":[{"sig":"MEQCICuVK5UuJGB3XbqAo/KlOrDH919/SAmV8RQEsDxjQhkKAiBZNd469eQ8mhTroTXHi/AnPR+aaor1EhRE7jhtvCcRxw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0sG4CRA9TVsSAnZWagAAalcQAIIZ4108+IUyge6m1FAB\nFcsiCZ3i2vLmGc3zuTj6dqX7n8/6+0Zk+xDxA+18He9mQF+JsBniHqRVp0Ii\ntI5o5tgwvOFzg3Q5zI0Pk67FVJScIe9yChi4g9ZMMN4RN2OvDB4d9FBTShvy\nDiDPJCLz9ODPJjjrI1PjIhnT4C0apVHDZyWvUZrniIB4s4qzJiK+Fyaaeo9i\nrrf0QL/lfo4WeLQfTHlinNT3cJm2PsDymx5t4ps0WE2rzHfFLWg68cknlQUb\nx0XEEiSKdqZ5nSaO9aUTnvHHJKmNtR/TsIw0EX00URIKtMeinYT72nTxSv8x\n5fMrpSKcwTEEOxVIcoMGdM9GAvpd2DIvVcb4Cwd9ryEKQTIhIPXpVOUH1tCF\nqctnKmt1v2pmHsSyWIVCVZOiWEzse8gc4ciWEN1GIfAg2D78Idhl0S5oMplr\noNm9TIzXaWU8ytH+EpeE5VPstwjrQy+LtHYnoVLXxOAkNxw9tA/lHpMauTNd\nZFIFtB9bmSwM7HBgolVbGncavRPdlWuQky+Xqe9FafxOpW4ZyRlm4YwYw5kK\nz6jWdeDj3W5ufOAD8zIcc5/zXiQu+1zct9MbpRgkdTQOGDGz4BFaDOtZW9v+\nkAzQ5STNu8pwx2ycaXx56HBN2mhLHXrjHmp2ROuFcZjcz4P8wq6lyRsdg7K7\nO+Iz\r\n=r/5Q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e456c2db37286fecdf2d39ed66117c94e1d95247","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.2","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.1","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-f019103-1590870386373_1590870456174_0.3148482577996534","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-768032f-1590871295630":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-768032f-1590871295630","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-768032f-1590871295630","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3f028d46701423f2e883f6645f84b48a5a095409","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-768032f-1590871295630.tgz","fileCount":30,"integrity":"sha512-+FgFbcK9s/XXYUVpESR52GT1hmB70evYCEUrloPKecKIIlIcha14VZG/JeKnSB+mMu9kwGxGzVri123ewN5LIA==","signatures":[{"sig":"MEUCICq6Ykp9wrzG6TOGowezWWNNVw5J3tDC2JT7BnWq89PIAiEA3p2go1vi8vlunL8d6hJ17UKcjMLaxzTt7oVilxpkayA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0sU6CRA9TVsSAnZWagAAbvoP/10RAV4k+rT1kTe1uXiB\nKUzcozzHejxwrr2kmDe1ARX0ieIeANHBzMGn6gcO90mFxWzsD2KgIhVwAB5d\nB/8V76AYFfltc5DCUTsT+v8xX+LF5q+fISgqXMr+k0CigKF8oeJJIkICrPoD\nSYqrf3OiMClSlwgVHi/KgwmTkfqN39hAiGlbvERyrFPc8wre0uxytXq8S1+4\nJl69ZtsRn2/x6rgdWlq5PIz0Ej/cUJIS/o9F637jKOPx3b7vAtV2R2jx6Or/\n8aHJG+jX8QbPIG9hSR5ibR2kL8k708hBKu3R/3innSvtSLncB4kX42+KVEgo\nuHdmwso2TuMRjsX3UysFldBJVTiyxDXmvXaKTGy83xo5CD0zZ3m1sSjCrAPf\nt3xoNgtbrA90RkCWaPVOFIxCGClnagnTl5SLK2RH6RQdvD2wi2PVNXrUGIq0\nWNzlJXT9GGHFN3WzIDh/Ndr4g4UNfhZNNEHEMcWa95yo7n/Syyevsf192pd+\npgGplb4DqZJcUL4UYM13LIkypwZdU8TLcM7IYI4CdVpRlCRYmSwE5Fo+ohea\neJTamvTRHxcGzqY2LG/yWxY3ytqsg2pnOKSeAsVg1vgohOsZbNzD2iKI+yh2\ncGM678e/FHxE7AnLm3Xc6GAkGIhpLswwkgkTAk+/UmKUZXNXRi9HjBNrkmUq\nuCuM\r\n=pATE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"411fe3f2f3862866c4727685b601e6a6b50e026f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.11.2","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-768032f-1590871295630_1590871354275_0.7729322016421323","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-82ac238-1590900361556":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-82ac238-1590900361556","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-82ac238-1590900361556","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6c4627bd541763984ff77211572f9a29aaad6446","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-82ac238-1590900361556.tgz","fileCount":30,"integrity":"sha512-GDt2ZcLGbEOZoC8osLoooSQbKNDV75OTY+l0680cxPXUMgHUa2kWvGNSaJ99Anl3EQP3F20SHX/FVBdneyWepQ==","signatures":[{"sig":"MEUCIBXeyaxslSCwC7A0BS+tYp3mnukOPZ0mvYxntDENnz33AiEAzMjYrnXtJWTdtDzxP2eWEtos0RgFVqLvDBYAYeVBrvw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0zbRCRA9TVsSAnZWagAAKYIP+wQrKs7wh8UWnv5343F9\n2m2dQenvbTInXCbrayGXEB24NkXbNlh7tkWWYXlwx4jnF6+cpAQLWLF4GIGO\nPfGq02lpKyhmmwLq4nQ8pT62QQ4Pkj20x2ne5EPy+lrxJ0599qBaXyWul8/H\nsD9k/M4spjMEDOPO8MBlISU/zf1BxkD/rN/SWqrNmpmHHhVkyzIjsT14R4FT\nOs+h/CgqQE/fRQIopwpMSf2F72BNyG3rXbX+iCHo6O/ZWaSeXbgjCNvTXffl\nGTB9N3yUF8a887hC64uhE2gie33fMdZqrM7zT8D3yxl604/OR14sXKllaebe\n0Mi1mFoyswkkrYFqKbrkdt3KlMOQ49ZaRryf//GD4iN/651ReZgJIfJXIdvk\nDBWcgVm8/QnpTsLU4kWxYLQcuTXmxmfRCp3tmQD4FAu0qfw9k2qmpLnDpeiv\nOEGdvNw4yUdpQZo5QtN2qLPw8msXc8uLPYgHbPEUqZnX0iGfiK0ueC0DGd78\nEnoI8IuR355sih2uThqCJT/B+9uqUYs+a79kz6mkAaQJRO/ILDF/Fn9iRZrp\nx+Os5uxJLbCeRHAx2yS0KhVf3FmuofU5a37a05de49D420UKNfgop5W2SiaQ\nJo3Rgae5CyvcM5LGhZBoByQeFHP5n/D6MEjaAP79luKvkDKnNpaUQ2wzv2ep\ndeFK\r\n=t3Bb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"58239e5fb3b0ce727f49171dfd4d19f50282d5c3","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.12.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-82ac238-1590900361556_1590900432583_0.5393585510742711","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-080a0a6-1591132013942":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-080a0a6-1591132013942","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-080a0a6-1591132013942","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c859ed107d1407ee7dc38065c85d5ea816edcee4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-080a0a6-1591132013942.tgz","fileCount":30,"integrity":"sha512-sdEAKO4CUCawWAfPPH2bDflMH4ne4WiUL8YMxorkDMT9AAUw5c+Iq7lw6X14KsSADM6LZ86tgui1SsoM1bQgEA==","signatures":[{"sig":"MEYCIQCcM4uSaZEpo4RaQQTQ1dRly6xG5FxbR3kijmIsO0UaBgIhAKMDgr5cbTKmecUVcOXGzOZolRG3f4/FMhOvtJsTYBf/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe1r/DCRA9TVsSAnZWagAAntEP/inmrSunx3DO3Viz/ccq\nIHjCbJgLcctFI08+SDLM0ziM6Ya0Jp7xmYi7U3AQcSXfMjxhshQHMFH5DJ/K\nKo48ptu2zbXhaV7Q10dGDRoZhrM6/nEj1T8SlvvPumMal/bf7685DDbSr1A5\n2B3jtOwOAJGuASixlAzizNjL2ZD05kehmappbFq9saVXt7OSOFfrj4X70rEE\nhhZheamljzxXoXOhGcyJH46RAolZFrgEp/6emOJzfmhzvwrQbkifbOgwwI6H\nsIwWVHzdzE3IGYzzpzvNXOq0IKt0h0ZlpSUal6HINb6Yc97y99d7G6U9l/DE\nuP+sl7gCW+qyCcDUCKtlJ86DUjDheTPRKYnAaMUgCpkfftHTYVzp3J/ggj/W\ncDK9cc40bFPOLhXOGdMvdizVv1F7dcAocLtlp5VbyjqttDILf5SXF+DUuS5j\n6qykkeRymezAdIioEKzEYugWuhl5IKwi0TlhV1N+i5/U844KA7DlQC6ZdKa7\nqVrDEq4z9jgRkB9SkFDegPkvOVhwOOewGqtcJ5qLPdFGHmOyGNlxkIwPxYUl\nPboSIH5b2yrpotYGGJcYV9Jo6ZZ//urgRJzivpGUQ5N3myYLbPCPVTrdLhgW\ndLfzhKqJUKqHv2dZAAPzb23pRQXmDfAMLn4fUWYF3ymOjSdmYsEwDqvnRy1O\nHMpm\r\n=+fvS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"03c7539ba5c0a8f797a40163a4ba60e9af5c2e5d","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.12.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-080a0a6-1591132013942_1591132098640_0.4399347339204194","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-6ad4d6d-1591215224235":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-6ad4d6d-1591215224235","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-6ad4d6d-1591215224235","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b5e76483c0c5dc5b3ea900971b48f22abd026bd5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-6ad4d6d-1591215224235.tgz","fileCount":30,"integrity":"sha512-Bk4ieQw/7HB9meT2Hb/tL5pxQV+VKok1YvpfJPW6/nXopCH4zmulQJ9yaLleH6r/0mRfXIJrYEqSpHd/iYlwgA==","signatures":[{"sig":"MEUCIEcenqLAhnuuBJLlPTUmVdxQpHQeSi0mcVocnYEkDLA5AiEA9TzFyppFIn0NLRMcW3Fgpickv20HRhvyNiOGwhcVrv8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2AS8CRA9TVsSAnZWagAAODYQAIKUFAZCUXoXbNmGdnbs\nvfY0l0CIeeLOQ1GV4cfONQieCpbABYVwZF0xheAzB7Du3HTgDILnIpOZxEhy\ngPe/AS0sATp3o2D5TTu+iYDd5ILGNsGyjATJNcmmDfqUePI5vBnRB5V3gKmR\n0vprnpmvqy2CemJLM8SMJzbj44NyhwT8xJah5W7AmDf2l1gvjg255zC9dE1u\nXgPW/Zocjk/T3ngQUj5VG2+Out53iRqREKTOQWAjxKjhEVbDwBXIn0/tLD8V\ncY1KqjdJuQ3nR/NNvTe6W63yVy+qFqjdNuzbzB0J4/b5g7X3WynEKhcs3OiO\n8S7cu/3qhw0/pqBQwTJERrQyGZQ/cKT2gp0avEalhOKobNNssHb9gWN82Lex\nGz5tvjoF7BHH+s62El7KIEqvdt888ZVNXp6B4fEun5RKxo9AI/fmketLk7Zt\n/TwZQAtdDYG+gvOqzKSGZWBv9lbvq2jDbGUQVSQ/TdtkrPedRuqpZB/Cn7rQ\nqkro9QGWqcfKhxRsMqaifP2rBDCaa8aSA0wVAR+D5kPxb+mGaoQdJP3iS3S3\n/8lJdmx3Lo0PlClgrdi0haG+9jmF6j/RAVRNyE46JjhJMOkWGo8JITKU2JqS\nKxw5WKfjjTkjXUMUtj8kra5xNUPA+VTbauobbnyEcv9FvbqYVYt/QmWnM9jp\nRqXY\r\n=3454\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"71ecd7a3ec6cc3f6b6095e994431b72325b4014a","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-6ad4d6d-1591215224235_1591215291264_0.574566240147691","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-a69b7ff-1591251306699":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-a69b7ff-1591251306699","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-a69b7ff-1591251306699","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"60e5e1b7aa5c332decddbf6fb3845f6b95d00168","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-a69b7ff-1591251306699.tgz","fileCount":30,"integrity":"sha512-pPZQFVMHdodiZFowZnKChZVyWAKmyy1RMLmAXdzO6GGMUEvUznCtVYUxxuu3DD+xGOZi8o2cRswqAGn5JfkeGQ==","signatures":[{"sig":"MEUCIQD/yK0L20a1Vk0Rw8gKbImQnF7xjN8YfXos2zwaqnrZqgIgNvQHkwpjJElsGzmfGIAYxQwcMJxnrb4GdiAqGW6ua4Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2JG6CRA9TVsSAnZWagAAijMQAKRrWk9Z3Zfh+mBtef+f\n9g0UyPP9rmyd6RAbrFyZDOYgskRl4VeM+dM33E4l6u+FILZKXoq84A6pEHPr\nJgxhtWj729xGhJgAwlbmRfqY6avwg/pPFxeHyGIeMYjZ8FyX/pGKR6IQzWxc\n2OjCjA9BQbOu+t4NmFdo2IJcTdD361bvSeJFHsEQ70Q2MCyiVkQwEQIs7Gj7\ndOjhbgz0saoIesuQxQYomTxvncn2GDotZdicIaxPzH+kBDpIomdJ0rlDZBvg\nXS+oo9Tmz6y7/ktVvAhwb92rS7MNefhJwCNwNO6sdL2il75WzcBBUHuWU+DA\nDg+VRl0F9vDZLSN6EE5kh7KmA/ZPcvcqxvAudwQrVxAZ/E/lfKbDivDR6jTt\nefBikd45gzizj4wXYuUe4igQzr9qFKivsP4sJyr0U8WykTPzJUWapenjyvEc\ngFUPhNvV24XBpzFNQsSKwkMn40oHuK5Py/P5FxvFcr9HA24vhQ9WfrljsRBA\njQYxFf/248bjpFl7Q9yEZPDeSxZllBQ9b8en0P8uiYcahhe7M27MuMozy4Z4\nikf8owe2RzpEBMIJbeG1Lx5rYqDDTnJoZ9GBVgchR8nsjDyyZr+z1XHOXyZE\n44uAxOcOPkqkasU5cA9STYzTTiZuRVOeSKggtPGXiXgi7haqrVO3FT9C2h/u\nWd7y\r\n=uzvp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9f28660aa14e6380e185b5bf15ae869174c5b5ea","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.3","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-a69b7ff-1591251306699_1591251386358_0.371929969698958","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7bf0eeb-1591304634904":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7bf0eeb-1591304634904","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7bf0eeb-1591304634904","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3a246b38f2ba4687d2b6e0e20dd5aa0c0272158a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7bf0eeb-1591304634904.tgz","fileCount":30,"integrity":"sha512-DOfgF5nbA0aPDbCS/g/r/dBOfIMNMpYJ8qOx3HyRgG3V680i1LPsRULSuovRak7cs+wHDC10DWPCRYD+hyq19Q==","signatures":[{"sig":"MEQCIHzGn4VWwj7zwR0UEUo9oOBhdb8o3m77r2aDHWUfnGqlAiAhuYHa3uHi8ynJrP3Qp2b0A+eJOwrt4+5EmITBqDfjgg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2WIOCRA9TVsSAnZWagAAwRQQAIU67rzrhowL5imIyLhz\nHGh6Nu1xvaqNd3RQj7BOL01BeqNBej0o4CegJHj+wb/dHbAkU9H2p6vsVnN+\n9HnSGSSyp/5uEsx8Z8GGgnRYbGJcJwrHTMEIEmAvcOqWkEMWd2FYzQfkiymG\nCSDUQbCHZERSk8TBp/+tHvULe+2wQkzjqjDUNGGW2RG/kJ1Wu1Seyt4ET6hP\njiCKKrWJYS25wzZ3ezmLFMaENtBGJy2aKBaSC40deDmUu9c4UKd9WyfVVvJO\nunq21ZlEfptK21hH35+g1OA9s7TxKaow6fplncmhTcrZe54wI0ye/zKz0ePx\nknygSHbJeshksJMyAxUNIWSLzh91O1r5IiZtpFCWYJ4l/Xq8zR1NtWy/xCOf\ntX7ylVRPIOmFydJ/qZUghRhuQF7K7hZ4dgafqQurw0R2Sg2MfNoDofXBhUe6\nructU3UZyvJb3omXSXQvqR+umCExycKU3nhpFR1TgiEU9HNz/ndkvtTgr2iP\nuyZqF+vJJXEaeGOFn9ZCTb4BPwDFRxOSqhiJrOlqJyC9Yawu303JRFpG4O35\ndZhBiXNf5e3DaujrGA0V/wfpO5VOKtrtKIxmVvCrmXpFI8ddQTG5IbIJKwHc\noGmVR6xujWi0SDn3atav9Qbz2SFWoyWOMfZnKgGaz3tPnspRMmxmGaB4G/vb\nRNcg\r\n=jOHF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"948bf5b758147413617f009e73901e182008d0a7","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7bf0eeb-1591304634904_1591304715556_0.6943479071592418","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-2f5f22c-1591569594163":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-2f5f22c-1591569594163","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-2f5f22c-1591569594163","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2da060f9b1d13a339751307141e177f62a4c34a8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-2f5f22c-1591569594163.tgz","fileCount":30,"integrity":"sha512-HnOvln8KBxEZN+/U2S558lu8UFiRGgs8EaJIRRwtp7VXRwaRZtZnkabLnKk7wD9hcwf7LB0H/mb/fUljQoFE4w==","signatures":[{"sig":"MEUCIQDpC78fPWerRsKnoS808VpIkRbZwHYEWQjxmObQIw0dlAIgRz5a51mWClWM8HPFGI6NDgIKivGwnkD2i0fsQa+NsnY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe3Wz2CRA9TVsSAnZWagAAhN0QAKMdu4r4LZHZX2tKI0d1\nRcEot1XrXolir8kUkCTToiNV5ixPt7GFjG14IL2dWmH6YMZzbV3RSRfp73mo\nmbzYO4a77iRnseWYHhWawrcnPi/QBdhbT+g+nyETGH5oBJBzJ1DdP/aMqXok\nl8k6AuR2J/ctLfsIA3BCBOJETgl7Xn11q9ke/K42rf4pvkk7rjFXFEL4aeiT\nd+9xZLkyE/drvGdf8TJEv9YZX6eMcFqC58+S+AFdl7Odw3/Co6oOoGZ52jAH\nuGe9jCWXmjDD10Uf/DZMbR2RgdPAMjHtCNeI99pJeTpDKujhnMxs5OCDkhDG\nkn6Go4/OIRt/7W29VSdNKWMqdU/siD2sT1XemQYapraS60+JftgVqnEq93Qh\n0r/DceJlXjIibn7ggGQNw5feW9s6qyLlZ/FGUpUnH9juM6mz5EyDhtMV4Qn+\nQVnc5owqbsK4xNkCVcmHp2SFD3MRCTxS4M9B9M0w3s8/2+4BoxMsvGPDV4Qq\nIWAS4uwk9jGReWr5NXfWR3FilJxixnBzvLj/S77aGt1oWPkO0INbMMuaF7QN\n6UYArQlhs50AZ6vtu2MG+FBCJ4LMQrdnhfnATWOvAwgRHE+cpPAkkEtFSLM6\normIHD8m+lcCYB3tWGMvg5l9dQR3mAzEgSG35Bgqas/4IV2wNXomMYrUKrOi\nyw2t\r\n=ic9r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"46cc35a89a78605a1227ba00ff514b11d5d521c3","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","@rollup/plugin-commonjs":"^12.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-2f5f22c-1591569594163_1591569653594_0.8122445509315583","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-1a0c653-1591657432696":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-1a0c653-1591657432696","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-1a0c653-1591657432696","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"72354d651410d9e59406cb157f78810fe7c5822d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-1a0c653-1591657432696.tgz","fileCount":30,"integrity":"sha512-Yt3AVG+v5DR/S/LNb3I2ukYdtG5vVmSL1OG0C6nWLDvPbCWrhgXAlguqcAfgKhpu9ucjecK6ZMovX30JqbM3iw==","signatures":[{"sig":"MEUCIQDKes/S4qybtkln5KOzySrXpObF/gzFErIKlYeh6moQewIgcK/IdYpR7wha4APpcrVruK5lKpDTISAZQvNyZ/UVhIs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15948,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe3sQWCRA9TVsSAnZWagAAqlEP/RrDUXSYLnrODjugXLTl\nCG+1D3or2cSC4rgoXu80mhjQZ9Yh/fbG/1sjKmYfftkmNCAX30v1mM4yjhzk\nuCAH8jDVEb2eIlv13GxuiF7X3jZ2Dbj6J9t784huBBXxifgDGmi3LmCR7VwX\nDn644S5Uch6HFVlD6eZwe3kLOBH2AhTjQOwuejXP64GUhxl3oM/qJyhwzmO1\nI5A2mg6D2tJN9BfuqAN6tLUeP0Vnw2tikKK22hmyJT3GYL4LrCj8W27bM/FQ\n1505LDhkSXJ61p0KCajI50lGSZl2j5hPDNRQczcq7fBMDChokKGMdYskXAS+\nfwQISFBWfrcHlWjv2DpkMuu7cOAObd02Lo7tfYmlv36mrWEXNE9tUp+0flIY\njhQLpVU6vYnVWw0Q5xIXQY4ZW9butk+okmprXUgvhHENDDA7T35m8XgCLfPj\nt4hVsgUruZ7M7284yfJBuFAVFEUJFVeLHC5TudmLv0incd+9ccXdR89k1GWo\nQFFKJcsokvb0nKUXcsDNDMd/MmDGppDT1PM641xHkveOPXeeKB3Y6ZTORE47\nahY2baglLWXpTWroK8Rjr0Yix6GfYtHuI0g2PIK1QYKifkNyaMQhMdlsfUWM\n3IFzRN/ZQ36nFLvUvu/pCIQgegTCsGVYkAWg66OeKAbzAV4V5rY9oxINf+Iq\nkoKZ\r\n=t/cF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"535a6dcb9bdc673004f64687200ad95f758e86db","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-1a0c653-1591657432696_1591657493576_0.9058245669435971","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-24104a6-1591741307343":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-24104a6-1591741307343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-24104a6-1591741307343","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8a7960354c7227b613ad5fa3355b6485df0e9e4b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-24104a6-1591741307343.tgz","fileCount":30,"integrity":"sha512-Td0pK0sX3eYV1YKaIbAQsSjppFvVCK0Fg7HapdC7Qyf3U8TRP/X9p5qdR+AzKK07R9131eDH8kMLF2H6KQw1hg==","signatures":[{"sig":"MEQCIBiY1565t1gvndR3kSWi3IOBUYISUd5GEsLL67Pso5rFAiBem75zLfslEM1Bl5Z4laA8NBbWUN6ImPQtdXBKRaOFqw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4AvACRA9TVsSAnZWagAAFz4QAIdRxTcuwqpue/Zrfktn\n4AolsgRG0W3VBhREI1Azc6mifVTZQcrckrfmKzGcn2O4uwAq0Sd+k6lvB9hP\nxmlF6odNWFOLyzJNks75/Xk/Wdri+07OMsRmAj7U3eSOdu9SPTFZZ/5QTca2\n4RYmbJaiBvSPBFQVqwbRgBxwlVrR7pLccsDI5NnQKmd6DQ/KcC9ILDzJi3cG\nrZQ/0TXrp9+TTJxDE0l6EOB2fg8XoIaCx6c4XUqzC7fYJ6RRQW9hwEHgVXUP\nk6iiNtDDMKDtj16OJd4sMVrhYqahKCpShrVatfywyA1PUrnezgUz/UI1rpJe\nLlVLTuxyWrgcuXsAP9qLZXL2G+FIbwTAOkFyHBkm991PQNUjIG/Wd0ayKBmD\nmYpxqO4eYo8w7j0ngJr824RlzfCE0WTuPFwBHxjy5n690KAYhXAFgxj2+ttk\n/LAYTEol4TQZCgXSGTB6nEIiRJpscEM06iwueDZzpojnPhuXPrJK+vnzqLsv\n9zRTIqRy/Di/xIgXdI39NmqN9Mqi8e+fC6sD6L/hduE5rYbksvUFZOqUmu9T\n57ga6+8Zl88Lc8qwpizTB52W+zMwirM/I2Pd7kPl0z6hZx9/t1DXnlenLQpf\nitZu5Kk2dakHq7hZZHzwVfsrx1zhQkyn1R9VDb1UrRYcXZ6iIqORniu4wxZH\nZApq\r\n=CkET\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9cce200b4c43db3b1d1f4fb85c0d0a651c7e4867","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","dependencies":{"fp-ts":"^2.6.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^25.2.3","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-24104a6-1591741307343_1591741376147_0.1857189383944775","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7fe4cb4-1591827987591":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7fe4cb4-1591827987591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7fe4cb4-1591827987591","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f90962e283cff8a5c18cb34e53efe567cd4d965d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7fe4cb4-1591827987591.tgz","fileCount":30,"integrity":"sha512-DogCI1CvgvpINSWYajZ72N+L9ljgaN0kBxXNSZzsqZcViqrqLpgEQfDrdeVEk42YYSh4Hks1e5OdjkGLOYf1tA==","signatures":[{"sig":"MEQCIGS+SBEu46MEOAwRAjGpg6YPaA7QrM9qj9Vh41PF7ffnAiAmIYJAu8x1w6fv6UmejaoRofBYfTAiS6N65hQm3N/MMw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4V5UCRA9TVsSAnZWagAAre0P/3p0ay58gnm+7Optgu5A\nFTTeo2Prfi9/OHPxUAliaXDYlEnoYFVd26IERq7nCsOL5ukKjfnnurg4GY62\nBml1h/nFNCkkMJ6y2DNyyu2nlVHxaKMscdQeMcvdiazKe5co4IxEQ3qjC5eA\nRnkgRAngWXS4DfBIQGiWRTPG6riqthb9dUE7do3xnmlHuFHFm20xeo0KLKki\nbkMSEQDEzJ9Aw9p3juYqc9ysQuhx+nwn+FK7A+QPNRydryoxLpON9fxG/BOL\nr1ZB7UuU/BSd/W9rDcNlwiD11jojJNpY4NZ1uxQISb6oPDftVdl5sfaoFN6n\n7kLxohXAiphBDWD7+xEJDEaOXE7jDv4nMb0vtEeE515QEsKrKIxPJWhTg5sW\nBVEKeJsMvCA64c/q9zgiZ0II1SuCbrwysfk2FkxLhvKiSyheVx1zxYJdB6F6\nOIgmKV4E285QIasShKZbuI4UbRkqvyaQ0iLIMlB+MaFbyxXyrbpFjpsV8ze5\n7iSjcyv53GVU9tSjgkz/k1hxOSHXh0amn10x7oT/uUqn2xl1FdemrtJ9vDKN\nV5qaunY5hX2EgwNLse/slHeKLSfY+g3yMW7wOparVOHTI0g99i99LmBNEspZ\nY96uvZ/+n/E1olkP426H3KeW3JfD4K58mksNl/0+ccPdes/FPUN+C2MjVrIA\nYFPR\r\n=K7XF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d5dd26299c3302891755548fcfb7230c092d963f","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7fe4cb4-1591827987591_1591828051846_0.45094250592971297","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-7dddfab-1591914034446":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-7dddfab-1591914034446","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-7dddfab-1591914034446","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"280c54e1a09d8cbe49d7e424f37113e11ffc716e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-7dddfab-1591914034446.tgz","fileCount":30,"integrity":"sha512-ySNDs8NJROSijSHPm1gC0epEZXPRMWr5PKdwqxXKNcrnXFVXWAebPF8NXBQ+Kp+zzB4/LSIsbIXpZ04ppquYwA==","signatures":[{"sig":"MEYCIQCZslqOtblf2SxuxrLpoCn7oyqNHC3lPf0gUXB2eO/YNwIhALfowmWIaT7sJj6RvWXKtIRVFP3hKE2ynCe0WiUgiApp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4q52CRA9TVsSAnZWagAAlgsP/3S5Nncqi3mI4p7gIHEp\nnEfzKlDqV+jzRBOx2QakmKIIgLv3MYEqZtRStdt/c81fQI1QkdMH1N1etmt2\n228O2YsHJEth0yqLKKnVeA3uavcjKwCN5tNxPanDkbZTjWBhYO3SVnF+RvKa\nccC7j32+IAp54Z/Jm1qUaksxw8EdoVd4I0y8GUfhzEMTaJgRwaaDA5PPqU2P\noOhJBhAmnttdJ5VcDrDrUI2BUs/Qv2bo9KPI9tdxoUI0IieXJTFWL8Ewm1Go\nFbQ+tEQ0lQAzpc/E9njCnOfTf2VjGnjHInwGv6UKRlrYEIUlNPsPZfwyHxCg\nm6Fx7txmCZH1PX6DZ9ANZAbEbMLvQAhYbSfrN4iiThKzpJWFY3KLR1mkNysV\nGV2ezak8Z/gfLc4CUAwFFT9mpPEspN2ZpnlDBDq0EZH48+4gNofpheXbEkj1\ncKIzvNmAz6JL3ot3vYUtFnlP/nyQ2Zv2YwGUtWLVLDkgc4HF8XMD87b1Mjwp\nfUkG2epEjtzn1YPT/gy7i5gY49844MSx8AUXr5wf8O5m2gaUSnfQSyUb2YT+\nsj4KVsDCgcZJOcXha0YG6VZmsCk107MRwHEgdw01ihDaYG4TIudMdgAJYpMe\nzBocyvtfHUOgL6n63wj2wQ/zjpfm4YieIIDNfFo/Yn+d9HM8gPyBnG+5LcQD\nMXGF\r\n=J1HI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5df61d51fdd1a19262d306763f6647ec6e757eb7","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.13.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-7dddfab-1591914034446_1591914101395_0.7027467660542903","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-17da0a1-1592176135470":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-17da0a1-1592176135470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-17da0a1-1592176135470","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9c116c1fb96ae819cf981393dfbcf501324927e6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-17da0a1-1592176135470.tgz","fileCount":30,"integrity":"sha512-iApq2Yr6M1FlCeMdIaGpD0EA81UevDDJpMLivaMPNdeQ/BAIiWYUDVwQ120IpDGAyq5QlcRt8wFYRLzqX1qifQ==","signatures":[{"sig":"MEYCIQCZIjyJcobgVcCuq1AYwAosdGZZpR3lfe8kAtTrd+RcUgIhAI7h8ejMFtyL1jgMTl+gLBnHM6OJWYanqlqn64fEuCBH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15961,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe5q5OCRA9TVsSAnZWagAA9nQQAJj4bxvePEu/4EQrSlIT\nBXstWW7anR0P1jQJYEP3T2yLcZJeob9LhTM5tMH56mPf/bu98GJnh+hRN5+o\nk3NNpKTrYaYa2kj8GVdU4NPfQPmD/6Saseq/hMs9Yi8JjYQi9m0TC1gifo4u\nS+46yQgHsIKPdxap695Nyjc3W7Dcste7tivGFRu7GekW9FbAvwHMa0SVHeDF\nP0tRueY78u37Ha9vE3e1nHZl23yw9pwLc+fULlrJ3/SS90UeXFC2w2G297Ja\nOehH1LGzBWZNyDtxHEed+/0tU9ZBTrrFlxK9DaZSPQYNhvjzCAb3T4JFtsiC\nkO1Pz6Qx9155pAXpLkomnWwMsUiCNNGCegtpoUqSUHWDLIb8EpWdBa21QPsT\nWCPRXqqO+evlpw7wXtjuxQIRNF8lBkMl9qjniBEMOUnLaR08Lmcy4KQql5QP\nalr5CC8/OWBobN+VbfMx+y1cb+PE2IXfh8w5kOZieGEn9JUnXJF8GcCwJthK\nKOne2jk2XlgZd+V6xmi46T3v6MuUqR1BjKk971rYr1OVfsl/DIg6GZ7H48uF\nOwgXJTm5j+GgUiOoBYtykjFhORgX2qtyqnR6mdteXtY4ICwFTdErDNDyvSi3\n+lImlXYUTbRQuWZDfoZdzchzUZZGCZMbskN3T5yz29IifkocU6n0kATSykAm\nh7/q\r\n=WG2U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6138ae813399db8036d449cd415abc82e95b5edd","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.16.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-17da0a1-1592176135470_1592176205967_0.42860578406784944","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-8d61cdf-1592347002946":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-8d61cdf-1592347002946","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-8d61cdf-1592347002946","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e227b379aafc69fd896f5518637647bfe76a8e29","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-8d61cdf-1592347002946.tgz","fileCount":30,"integrity":"sha512-aTauEtVVIADaq+UQCuIICkDxSQ9ML0F+A51YemMcfTjFjgZIXDTBZpb6BJSl78MEkMkex2NQC06a+GJIlH9TAg==","signatures":[{"sig":"MEQCIBv2epKldM7rxHKtsGkGKNsaOwmo17L7eq/CpGmXojLdAiAHBV2MyiiQ2zSp6i+zWrnF3JJgxBXil2wjY/k48Ok92Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16041,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6UnECRA9TVsSAnZWagAATEgP/jp5AcWozXHFsCy4mDu+\nGm3pJQdF88PVHxDMy6AKdCL/E8CYP+m0Dsi2q+IH6GSSPIgPXaThDxd0UGPx\n7lTElONmo8VTFS9bu3T+ENQzYSWk4X8Zp4o98dGXrJCI29e68EhJdGaochae\nwon//bKjaqjkAdHe24myzRH+JsQDwWCJKMHzS+wjUfGOsL2STZNLfyiixnJR\nXRoQXWSz9vv1DFrkJjNVniswWe9kyFiTjUXcdgHyrL+gkwheDCboscJHZe9t\n3KDziwNF0MDIMwl6yrnLP03L6TcoqE3BkJ1AnxVQNHdS3153mAecREBfRpbd\nIPaOZarulpXGzgwQK35OV6oalA56DFAOjtAYunBLYJJD4AFQ+m8d5xWGUOze\neObleuA6qGLFE2VH+Iwq+nzneB7EpG7TXVCH+ehrgQiBjUTUHx8SDF29+1lG\nDs9GTAkWcozqZntKEZlyqQqdZEA/MWNCaxh7M5d3Gm0eiglMrbSTXT3YZ5gf\nQKPhDhq4b7ydHyx22nzcBJWrDKvHc0O8q+S5bt8b1xivafwlbaF+vupQpSX+\nFkPcYgqzdRiN+lKbZEz0arMOk4daK40LUUliIJzXbha1kO0z7kPmQnAhDabH\nl3c+07B1LtOnHrSByqcrMuU4VRlBkYx3YL8V+IwX4GOSSidXxSMSeA7lwi5q\n/S+X\r\n=AMv9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"17f4e40adb3d4b8e395edd1b67774c4fe9a792e0","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.16.1","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-8d61cdf-1592347002946_1592347076208_0.5048785518431829","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-be0679a-1592430793046":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-be0679a-1592430793046","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-be0679a-1592430793046","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7cb9efd547dcc4138a18d0fb08794995422038db","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-be0679a-1592430793046.tgz","fileCount":30,"integrity":"sha512-AEsgZxEiGi7owpwCoSGEypA1HxTbsuwb0AI+XMz6bO2mKQ9IZT1NkLOxe0+Q6lPZtIxTm174UK3jnHWujuoYFA==","signatures":[{"sig":"MEUCIQDFPwuEmb5XspQfVqw0dsKsCH7TqRNk8OhC1Gb1yonnXwIgRuvI0ImcfWjEXPeSc2T4BRn6km4uC8ZmUbDWhXAFufY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16041,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6pEuCRA9TVsSAnZWagAAnPkP/1+vCyNrU71bz93xbpoH\nxDdXBxHcZ5duafc+QUVRmFleC9K7T3qX/OqXwfqXw1MtwoYHcS8E2w6cTtGF\neeGR21rKnmGTI3/4Le37WxkOx2CmkAfwbLEYD0raelwnCLtE1fHbWS/1Q6rW\nEl+L87aTHueVPP0sRtaXWYp43iq66ba9uGrKEzkaYZVrgaxWhpYg9uOTmB0n\nZCuBziib4kO02xUUdMeaJzfUBHsEHvrNYxuslkCV8whjLM4HkRUl+ijCWcyE\nIw0Ski/Mym3EOglz48gpJvY+GbhP4GrGP8x/w2elZnOuCfc8uGCfA1mwf4+N\nU8YFak33bvCCnJmtM1mWExO301y8pnLxzys7Uh+alG0kEE/aLoMIfHzXL/sb\ndGSAvyUCP8Zl8CjmC2Ve5x4lUQVYKgviGHfHqMYJqNOCeowUSJuc6KweBRLf\n57KVq3TSciWrDyHmSjhZgmBLdwiq7J83Z09yIEngLbzTj2ej3yRgzJmx9juf\nW150WCwcSh5UJF2CwewOUvnZTKEQ9Pd7m5MN7ceI5qkP6fCoHohLkuL1iyh6\n0IE5EBE+xNFSic8mWSm4cYQlz/Bbzuhe8oUeYBEnDTbFu8X59Ui4KXBA9D47\nDpt+gRM3A4gBiJvno4/Be9oD9zVPtIPfuwegsvGHNL8iWlbvdwJzYLFLa5A3\nmDgq\r\n=2y+/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1a449834940d6603c0b2d4743354ab73bce1ae8b","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.17.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-be0679a-1592430793046_1592430893999_0.5166312711235257","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-5b767ac-1592678297787":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-5b767ac-1592678297787","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-5b767ac-1592678297787","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ee76ec71be3d3ec88bd15c66a4738b0c26d6b3e8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-5b767ac-1592678297787.tgz","fileCount":30,"integrity":"sha512-oeIkD6d3H+yKGy3lGwXECiJRnCN+Wq/L9s8iSWYlLO/JnGDexw0/7snFKBv+iTejBMOT6DmGmp9Nk89VKHamcA==","signatures":[{"sig":"MEUCIQCNwrEW7oTVw7JX21WG3K/T9YzEGGHIErFwtwCBGPtRCAIgAYWZUGCfChh5g882aPSTUwrszlL9Sum/MKfGhz7qUrk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15708,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe7lfbCRA9TVsSAnZWagAAve4QAIo5KgMwPtVQ3rckxl9F\n/W69CNuaAkTFGj1B+pgtLUp1KXjBd1W7UQ7RbCfepoSMQSsndPhMBWirT6XC\nH2mOPHpGWzm8s+dXbAcn/rFjTDhDmsu/akqrwMvnaAxUDZ/XOssjRHqXYm/w\nqY+sfzfkwZfazZounuKAAPzaAPfbWkXapRINtiheCtmp0Q6Il5jg9/XlTyVV\noXU3q/DVqPcrs5+pGBVP7UqUB2vdf5BgZiRdt07wIO8UxPJFKKT0vygvpV4K\neeg74acqMVXA86Q3nuWMLS2UvKrpGCBwTeCktziBbxYXdQf1YUIKph+Qkg+7\nvwx/9OQ17oNiMaoG4sAwnpJwxaFl84fK1ExVLv3iz0cqxFSuSGAq+rvk8Txf\nsio7dvGhp82rPPAeofygGPlxZU8o7se9hxkinTuHF3RCH6dOzIkzgf1itATN\nIx5TLijlBZiQr8fJ37n0tzoHH62Chrp0TA6Cg8E/2T8QXuQpufTLMF7VjVuZ\nHpsMkIHOMTJO8VgWegpoC3upyjdDLTcJvCZJa8Zv/sc7Uju85raKSJa74X5J\neyPaMnUfXSSge2Rtxr4rfa5GDFhDm5M6eBUC6J4L8yGZHVKDYID0gz+wMSz2\nxdzQGiAuPTEi/RPcqUlZcWlGk5psM6+Vw6FeExwLl5BdGBX8/TfE9oEQ22OE\nlee2\r\n=krIl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1bf2b774fd74a144ef99ffe059b9e3638fb5f7ed","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.17.1","ts-jest":"^26.1.0","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-5b767ac-1592678297787_1592678363123_0.5098429151171597","host":"s3://npm-registry-packages"}},"1.0.5-beta.2-canary-9000b08-1592678417059":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-beta.2-canary-9000b08-1592678417059","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-beta.2-canary-9000b08-1592678417059","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"877252eef5f843c3a19342ef6d34739a8555911a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-beta.2-canary-9000b08-1592678417059.tgz","fileCount":30,"integrity":"sha512-K2iUgl70Uv2ARNwrW3wUWt7VMV//OynYqXeOJhVYzPReS9j0L5N35cDLyWxEEE5aaisOezEZCQvJXVeZIsTDQQ==","signatures":[{"sig":"MEUCIQD97q6Sn8M3nzegKnK3FqFQddy5To0y4AWhLfFDi5o2QgIgN2xjXkKekJFPuwKiR6stEAf1T8fADuk4e1HDt40KxoM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15708,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe7lhjCRA9TVsSAnZWagAAVSQP/Rr2lfgahOB17StfQjPg\ns8iwGjSjCxJB3zpY1y0P4csHLNbSzvQOI9zeDuyaBhdFDyLrx0E09logHtph\nW+1m57k4DbtrEpp4iR0qM2IiLZYYXnZnyD91+8jtoBiv3AnDjI8qfPeow0f+\nHh9zIjbDJYqtFxewsqV1GuZmO5X8OqQ1/a2ygKXfpuTVAVbliydE45eg8HIz\nrnlmj/M1+3Cp3xKQOoD6z5U6pQIhWBkYvtM+aDotgKV/32BQYWYuX5+0QXDK\nEjlxdfyzvtmI2KhrOfpHJxKoQ/Z2YtODA86PVO5pYmGOeQi2wjiPBZGn5Yo8\n37M+DgLVPhg7tJAoX9jsY5SwEUr2o3XX7gnwBQ6nxtn/IYMoq2lYPV3zXr0b\n5LuwJxfakL9lPRjCsLb/oEwJL0AhEVc/eha71RBqUZTwHEX8dLRM+YgsLZbu\njlawrBjfG7HM67FSht/QN8QyArsohfFbsXtIxXf5PWsR8slgcJdTZFFvLTSn\nAjSIjSpeKxeQuZ1kPyo6oB3nhHdmTPrk0ImAcX1TUD/7hsHXVXAKUkiODk3e\ngA3FW8IZ++3tP/Sp2SENeziSbUBEAWJkqynK8QKqZDKKHG1X8wjQ8r21m3i0\nQXmEmubIE/HDovunV10lWBM3v00csXJO+ceG22CZdNzvNH3KC39Qp4mMqDay\ntIhO\r\n=ow8x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"269790e634815f1d6a530161efe2b506f857d4fc","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.17.1","ts-jest":"^26.1.0","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-beta.2-canary-9000b08-1592678417059_1592678499263_0.3190993984841788","host":"s3://npm-registry-packages"}},"1.0.5":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6cf649e5e415aa703d9110e9fb000e6877342da8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5.tgz","fileCount":30,"integrity":"sha512-hrJcp7R67Xa4iOyFyVgobVxlZarHj71sfd60TaPmZliaB5ehvVd2zARqKcu+MjCe82yJS5/XIlwoFcGEn/ZXyw==","signatures":[{"sig":"MEYCIQCzb9T1yjFQ/Pt4I2vsGEQSYVUgwFc6Vdf0k3w85JxE+wIhAM2avdZUmlAJRg7gQ0q3nU+5BLFt9t290mfQ+rOOwkJE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15770,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe7ljYCRA9TVsSAnZWagAAEngP/0K1Bogr7Sg6nnAFJK6U\nU5DHXR/6C0ZkLcgDevQKyjqeoSGTvD7Q3gaGUtVcfuFqCiTAsPlxmINpX2qb\ncCqH0Om0J7HOxMwEqB9FGk7mRh/OgGJdbDRf7aqneQLcAzs9Kf2+kgSxboPg\nEtR8gkxyKXXJ9Xixk1PYQ+UU/THoJ2mgHQOAO37R11iRZjOHn5wMTmSWHqVF\nBvVD7T10aZhQRo47I/Ac79GZXNaa6Du+Boo3kssqB/0x4j4jSr1SOkUHxTcB\n6LwkK0B1WMGU2OliTA6lpBRaXsruybzXWwpA/2LDR9jJr61cF8qzqrRttl4N\nhFp8jyio9a6MHxaQ4zezHgbgIi1zZbIdGNedh9J3bVINyV1ArqJZbFSNCnb7\nkaAOvRw+PMN9075jSztRVSwpbObiYgSMY8WnDQ091e+TwusR/Kejt09tT/GH\nnpifXKN+FYUOqUrfywAEs13CevseDVR3OfqtzXI5cOjq+3CaVmCHlfLl1ENM\nHYuF4Qt3mEKmO0mBGvxt+tJJotshsf9YS3p1YWN2BImy3/W/VM1P5Ut7bO8b\nuR/RCC/EQUg9yle6iCSyvnNNu7fXUkx8u/JcTGzFR2c3OkjzuhbZVx9xDZ6p\nAAfZGTadS3nI8jTytaUCZZyzARAwDey4EkiqQzUIr9mgNCbx95f2Ffk03G2X\nw8LP\r\n=3twk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"3cbc82b06cd21f14d7ed2ff5f9aa2d37e5ff5324","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.17.1","ts-jest":"^26.1.0","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5_1592678615514_0.7374993495262077","host":"s3://npm-registry-packages"}},"1.0.5-canary-32e20ac-1592861509158":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-32e20ac-1592861509158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-32e20ac-1592861509158","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"40cd29fc59723fea3748cd2688bc5b4dfef2b762","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-32e20ac-1592861509158.tgz","fileCount":30,"integrity":"sha512-/glVnbP6/cGdI4gXwJtTyJzitgZisHs4DGlbpFGc7NOlLEd/Jz1b7qxD1lkzufd/MOg7V9ZECz1LmLIbUdWZuA==","signatures":[{"sig":"MEQCIASEpLf2xEOVJPzXXwyeNE43qlwGkU74vO+GSuvEyCVkAiB/atN1zP3h+t0xaJN5UyB8SPsrnIIRNp2mXu3haTpi6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15799,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8SN/CRA9TVsSAnZWagAAcZ0P/RxbAiU+nZ6bHa0Jf3JF\n1Xw97MtJvWdGkVJvF5TKIkDYwT5ED4lTZEDEmsQxSZZTVfkQeKvbfNom4C/G\nEUHY6QJ7OJAIKn0w76zpnj9pM2OFisRfwr4IUcdlTfS+v6tiVKT0YlBPJzzg\n5ij2coPssgjaWfnSGHAgt1A0LIoM6UqSqe23m+MrVxypdJZmlha1P5mzVp6i\n34qa26jMPDLWe3sikHlaBHpkTbqbjW4VOhV3v5m987WWxpkw7mK62WHxBE3M\nl+/vWDJL/xxPhY5SDwNUiC/J9z3X2cgw+yGrrzpKt1cySydxmgn9S7KGgJKK\nkt1Q807A4K2hG9dYSzsmF3TAcrahw+3G3unWOyYjDZbOJWGjIjSQnB0jxAjL\njDQOM18qhI5RAMxxvLfM7ex48ntkQOFrPA+g5AmdOyKNla7odSEREBPLKXRI\nEFi3DBurRqAwh30pj97Zrtq2D54cNAOrSUql2BGzD/PbVlT2ySB/IFWRMDDA\nanHPBdxKbN893/wAs6Kf16Jy//Z/hWD4NPDgS2VS2bOowSBV/sIZDdnri94p\nCTDEiBsQf4RHkL+998nittDMW3kittR5bfmGbmYXbl7NMXrxrRqjV/UBs5+I\nEXo7tjSwFXNU6DmmLgwo6SND8+ZB9cUHWKH7pEYhKwJt2l/mpieHHspKyBft\nx97e\r\n=lKs4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"22b6621176af1e973f0887933aded6cb09e2c7aa","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.0","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-32e20ac-1592861509158_1592861566773_0.7944745518328449","host":"s3://npm-registry-packages"}},"1.0.5-canary-4636fcb-1592863621775":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-4636fcb-1592863621775","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-4636fcb-1592863621775","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"627c91ffed907c34532f3042facfc150904e423f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-4636fcb-1592863621775.tgz","fileCount":30,"integrity":"sha512-wgl8jfROzZofTO0chB9s4GEnzXo2HxWJn9ifqvV2tTwiOqV/UKmmpK642hsIPw12X0YUBaP828+xpMCsVW0qow==","signatures":[{"sig":"MEQCIAaxlbeQCGSXDCsnd3X9q+Tpa9G3zlMxFw6bKWRRFbctAiArisGNrYSWAZwSSfvZK5NwJBocO3aytbtQcSwXhbqGLw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15799,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8SvBCRA9TVsSAnZWagAASlEQAImSluYlc1l+1onVa2IG\nsam3oyaZrT7Qzej14jAmWuHx5KHR2ZCCY4CsrRSDKRVVmQyUJGSe71LX2DCW\n0cjYfJRD7Os0+Hbysmk2IVEPKVOP8qBU1S7FKdh6tTgx50om42/QjksOfIHp\n4XK9R0ra4NCx8g5FqOJkXxDqlp3iakXJimsh9IQNZXehUuDhOD+5PQ9ghc0C\nDi1GKjRq+WJz7oKLmgnpfN4SdK8yaYvairVb1++5LR9hM3C/mvPDXKNeQDnQ\nLYkfFx+OznfCG8ji4y7ipieI5OQ3+WwNbxtkE3JS91d8UPjTN/VcTFD/xHMn\nMfUcdiwF+4pBtMxobzyKz/1dfIVtq/MwheTmuHZ7cUzOouH9eSwQoQOo21eO\nmpM6dEot9fR4jGo7F+L/s72hFzHAHavIiEZjC8soj980twX5ugewBWmD6R0+\nQdfcYLJuzJ5ClFdes+5e1PqIIOQhTuER9K/Q0huN32eL5PDEdzuWqLIVNoKx\npnXIAXPub/YyirktaRZxG0l6hx3EyDrU1S43iRCj5tYblBAv9ICXtv/KxDQ5\nALFSv7+uZjcJSj4T/f5Aq0JBOhv48CU1u5NbXZB8drXMY/3EwJK5liI1D5J1\nsQdv3MnKOnlwqewpwqJsTQxA/Rz63k5dJe+DdY+u4aP1NnBLIOQbVtDmck+V\nmfFC\r\n=kJjF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f1c30e97a3559e98c002c23033e127442d627ca0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-4636fcb-1592863621775_1592863680983_0.14056764151966528","host":"s3://npm-registry-packages"}},"1.0.5-canary-b78ac30-1592883534968":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-b78ac30-1592883534968","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-b78ac30-1592883534968","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"361b5e322feb59a26ccae65d1860203e7d4963a1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-b78ac30-1592883534968.tgz","fileCount":30,"integrity":"sha512-iPuABO3AveoZaE4cZHsbK1VULnLp3nmfaXPsfetC65OjC2A4aU6M3hJepccAH+Xc01PXDvFr1113v8wkq5J5lw==","signatures":[{"sig":"MEUCIQC6twF/8pjVbq0+DXQGpejTJ65GSL/B3QQTj6Jgnv8EHQIgYbiVt65fORyRkMR4ZE3XF5eR0170z08YH+8ua3Wvofc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15799,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8XmSCRA9TVsSAnZWagAAzdEP/RNiNVq9H/vfMVFgz0Hu\nk4PRUoLHmSMWSRJJUYM6RXnN+d/2ys5/A2uuAF6l+bWdFAfR6oTt3GA6UnSn\nYhwFex+a0GyWKZXdlld+AefZC1glhTK2pIP3r4kPaXeChjRQmy46TwHCnN/X\nqQHEBPI0rMk/INExNEPoWBLs1Pornck5LlhCg9TCE18rgRvKYkmcWrw20ZUK\nt9OEJJtDCRjNPFdo7BEFfX+Q5Sq9npFYGE72KEgQ7/nXYI4OTiYw/nW/GdCl\nBeWBo4/fV4IJGLi+1dq5wah7QzimCGGY/3Y71nQKbSCsNasSvwKidrQxCh3g\nqcCW5tCVod4Kdv4YV1JqDpW56NY01MWMZmUBGbj0t9xI5M3J/QTqJDBuyOFU\nupedo+40sOh6UFyWnq9Z3qRIvrMJg8gtkyCDjfyNq1BqCH0yPByxvMpYsJjl\nGpfCsw1ah4xrdK+t3wLdGsp0xXkxI23PZGWhrc95F88Bdb8sH5GR5Ef8HEIq\nQ6z05qFhdRSLycTo5hU3HKIrMHfa3G6gCR2zkzqKAcrWpt3jOUjrgHFCKBNS\niDysK4ot9mRm5k+Sjxo2uB8O0qvl1+gaM94wbRp6rgxPfW1w+19Bzzz5qKVQ\nDEFJ+oCceQA1QNaTSsKg6a+EAS8U94XVFvDHRTzHxMlLLoeQY/ofnhJRU7sl\nbvMi\r\n=Q45c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3b4f83d189010f1b3a6921d0778cce95cd4f4641","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.0.1","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-b78ac30-1592883534968_1592883602084_0.8567051755561721","host":"s3://npm-registry-packages"}},"1.0.5-canary-de0b6e5-1592963549632":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-de0b6e5-1592963549632","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-de0b6e5-1592963549632","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8ccdbb7d6dd0be64bf56083dd8b4785086b52f96","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-de0b6e5-1592963549632.tgz","fileCount":30,"integrity":"sha512-ChDyhOEZXfpBOyZJn+eVwAk/Q9zoBUIxd6ojQ3i+QPg8qjAzlnFiIeBQZ0J8YGe2cothGhct4SlcT2GjA4hHdw==","signatures":[{"sig":"MEQCIAs4Tha8Di40JpPiET4rbWdm/Crp86m8T+QnqdvliCyYAiBAMMEYXy0XOl+thEiNf2uy48l110b0yWUCKLHEjtZODg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15799,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8rIOCRA9TVsSAnZWagAAqNcP/iBrUPo50jgX+yKwhIWo\nvgMAeozEaBvp/Yt6PijkJxGfRLVMGbQ5tmAFg9z84n2cp1Y7M8V/ANpgUl9a\nSY2B4S5UhADdSEzaHap9qvv+CH9sWXBnBP4QoJZVfj7cO+SW+5OVzIx1/LnG\nZQuN3H5YZN104y5aWRrdpCK6p8TlL7SGBBfCPxjbNJGLIHg2BMnm3UsJgUbn\n5O6ztosHSFqc6nw/xFe39BlMgWgFK136C29LZVvcYtLZRXeS+f4Gnbdg/Wom\nSIqIaUc2eSJo4C3kj27lurUs2aFF7irStJ/cPeaIEMXvXuwDa7CtyPJKX8TD\n+V1dkMnEF9Bfm/3WjkcnCV45HWnsuOzbAEt0xxe4YPhu4SyLy5fWYYH+SwKu\nCjl5xceTKznyC3bJlFH6DHUigyArRPyGYV0skICP3MyniyyR/gDBteJ18XLH\nc2S0X1ryLVrNdAa4RSEvDYte11AbAgRdeyVrDteRVHlejNTPQ/HK9DbQ4OdV\nvQrHsHCMwm3CxS/e8TFRiDiYvmyZUzKWBN0px0Ag95UQK2qAx8IfbLrIMzq6\nB3cq8+9awMffsHq96UX4xhDg1T1d3f+fzRbj0v152JbPABBED8a2TIbz5Pfz\n1B4Fy8R5nQozyOfVq5o+3311tU1LxLCO+EQGE6XATkJ3YR0AioBcpryXCASc\n2H3/\r\n=TKQY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a6db0396302d1af15a9c3bdbc6175827207b132d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-de0b6e5-1592963549632_1592963598404_0.23490447881201582","host":"s3://npm-registry-packages"}},"1.0.5-canary-25e7cc9-1593010379951":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-25e7cc9-1593010379951","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-25e7cc9-1593010379951","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e1ef5b0b19c39da0612afb99b466511a5ac7e22b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-25e7cc9-1593010379951.tgz","fileCount":30,"integrity":"sha512-bDON+YBvw0VHBH8luChvWirpi02nX3NUT5XitnetUI3bbqQFf3RuAEHfRMx99w0EML2qhYDBGO7pKMwAjGaf1A==","signatures":[{"sig":"MEQCIHUrUXdMGZrQnMnmXCnWeBaAyUt7nXJSDFOUP8h0IUFUAiAsVVi+IfLEXohWOySd63TCQj85JGRLZvLgNntqqGaJuA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16387,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe82kMCRA9TVsSAnZWagAAKNkP/15EuzQKXPouHJ6i6DgY\nFu6wM9MaqlEMvixXzCTtV4tqpoYCOjOIZH/YMs9btE+HIQsTVbp4fcew24l4\nKTTzAia8I7jp6VteJQaJp2xHzSZySOUt2lDGrU6q7ORm7rjL0cgCWzU4kOeQ\nb6+goPIVKBzSBMCU+v/YyFkEl5oYtJC+06hehgoOmT25enqjubJoVrNUS3hK\n95cJ6lGNYts/O+nbRcYvNGC2Ml6IqW67gwgO7M1qXbvX3Y80uLeh++lkDkEF\nMfU9bD+ubv3Q2WVB5OOnCoa4kwevOKw7uFETj2kzw2dUKswLZKHFiRsdDP1Y\ngg9Ngvfy1M5h9cSIX4lHyFWg9ngxd8qXh70EE8PZ1qdzM/FGDmtv4vc3bx1e\nrc2sWK/7kbpbpF800mP3q1PocWF+IkCWZYMfUQcoiEF/YgHOCWHpQcUueKzT\nE1Su3tF3A8PgoVw6z04FoKh+7Orf6kiGKQJVE4F0OQk1gLfxRirby8xvLWGt\nSntlP2VrW20Bk6NDSM9IJWKA6jbxQTa06CLDA5eZtDOpFOZcERY41+SWEkjp\nW9UjqFHV16P5d/ffSjGMl6i1GkohJQEI30ReIG38r247BIFBdspXWnElS9G9\nvPt2bEki51qDoJCrhGVLAInKZwhUaoVWpiUFdAvVnnHXUvj+HqnF+I33IQTP\nkxCe\r\n=XCPt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"78cbd11ff0064ddf706811ac6dc14de8422ec7cb","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","bump-changelog":"VERSION=$(cat package.json | jq '.version') && remark CHANGELOG.md -o --use @jarrodldavis/changelog-version-bump=version:$VERSION && git add CHANGELOG.md"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.17.0","ts-jest":"^25.5.1","typedoc":"^0.17.7","babel-jest":"^26.0.1","remark-cli":"^8.0.0","typescript":"^3.9.5","@babel/core":"^7.10.2","@types/jest":"^26.0.0","@babel/preset-env":"^7.10.2","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.0.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-25e7cc9-1593010379951_1593010443463_0.11555962277016518","host":"s3://npm-registry-packages"}},"1.0.5-canary-350c961-1593010402121":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-350c961-1593010402121","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-350c961-1593010402121","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4616d5c8f2d66b031bb3e9959ec9a6ea11087a7f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-350c961-1593010402121.tgz","fileCount":30,"integrity":"sha512-gvtXgVEN+FaSrLQdRWKDDC4OJv+PpQ1JssjZi5qSYAFYRJeDDfNouOYf131is4oPIw2Jzi8TuEwB9Mz8aa0AzA==","signatures":[{"sig":"MEYCIQDFiOLSl3qEa2wlt/7aiAhjUkBhSiqQ0Za3nDpq2orhyQIhAITeDTEq9ygv6JeocZ35TX+3iNjtNq6/pW9o6Swyjvlq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16152,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe82khCRA9TVsSAnZWagAA2hIP/jspd8UshiCgUYCTnKMM\nqBrFSYTeIgOnsT5inMA3E2trpla0MgrOfgfT5/vBntPNX8uSJu1cCPuLgXIB\nu1Zfb4ZKVcvHtpVF38n1kEHgCkEDlj2aH/B6+ON1aptNTxARZAelI96NULQX\n4Gs8m+08yldz7tuLFYenSe/M9ryMYtbFgumG4/tg9JIua5Z1/iXyn7FWYbw3\nafWCbrnk53vKHaJWscFR7Itx/K+uAbmBQBXUDyifYWpzNSXWMudmXozvw6ZZ\nnIQVZRYGikaz3dqylk8Vn6tCTTjYXNe07907R7CEquCDJ91AejMmGhNox30z\neAuUieJ1CFtSXWfQ+yMJsxyXqQdzGNnFBDMYXF30iHRYDP8/sEnP+8PAEzSp\nH562cjhOi9CnI45dFSarzKDyO/Z2PSy0wKJd1I7TcS1w2ut/nw5cFlXvouTy\nmTgWjQrp2tWeVR3MLA7AqdHQIQfY9sxQJaC9uS3a31xcVFeAHyNnLbYFlSIp\nVgAXgJ/Lnqb2xfqy54O9GTbUGOiRInUFJ2/Vqfb7yySs1YVqK6Qytonof62E\nBD6lNiswzdSerZmhcK0qfC/io3f0nRIs5SAilzqwfm6rayrm9xHVHt5deorM\nzAhu6AgDdGp0xV4KYrbJxjo2uGw3U3jyCN6Q8VNPwSReiU2v4InGz7xikI/W\nCqxP\r\n=aPNl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"119fcf09f5ddf5c4e6b63c67ed939114288e311d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-350c961-1593010402121_1593010464409_0.09889377669031152","host":"s3://npm-registry-packages"}},"1.0.5-canary-c09e3a0-1593010533835":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-c09e3a0-1593010533835","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-c09e3a0-1593010533835","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"affd15fb321ded199ff2134ac027f7ae541dcad2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-c09e3a0-1593010533835.tgz","fileCount":30,"integrity":"sha512-FKGMSHZ5dINUf6/9ffNqyQpfXhr0rpppbDdbRAbZZ4Xh56/dJGTUMNEIr8bRPgbN5O0hmBp9KXphaffT11XNmA==","signatures":[{"sig":"MEYCIQC/hl3HbPRl2YNhDmkzJBqpSTmMot555lX3uz4wU1AXiwIhAMkCWEXnVMSMKydAgGh4ADM9E/ujo2noDsn9+irD7LNv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16192,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe82mjCRA9TVsSAnZWagAABjwP/3qKkPk3KyEInfvykJ18\noL9KBhcbrtxu0OF3cJeNjZqP308rxX/RN5UkLUcu9gEwuQpx+f3pcjgNkBjx\ntSpYwmdrS3031QPCDaaMo4l8ggaMKBBAv+DLvcEddslMHgWu0QOO0TMUEr8m\nXw/5kHRyXTaMdrm9SLkg+IKA6ameadc9RHdNoO2IgzsRUDxKCBrA3rws9f0/\nIJCkcS/wrvH1Pf9cVM5qbf+ijFmMlVypWLn9tv5y82jqSJtAELh7fbriR3sb\nuQ1jP7sbEUGNU/A+hWDgSLWJZWkdCPRSCNcx048dV2eHMh4Qp8TXKwHiIHKL\nGuShJFA1WM50+gYk2v56RFSgu8J2od1L3EYF8EewgcHAkjWXQREN7PV13DcK\nqaYsYZX9AH05SjLUNu9xIXStzFUw7mQ5hHeXEH1wJB6hVmAfZzN7WZwoOwtD\n4UUuVpceGkyecJXQBrt+3qS1ADEwR4JO1Ouo65EOUvXL8E8hMx9hn+0mX01E\ngFL2QyeXTu54IYAW1/MTTcroXh0BqNMuI6F3vuQWToDhNUdoHSjEMKqZxCdC\n4clXvZoj9GbIzqPZmxxPyGoeUDdi993UfwVDZBNYKt1m/akHymGSq8H4ck+l\njXCUAt8ZRH2bKjkuxccO4FaoidnRA7AYqd5NsiZ2dKKVAJIg0Ar4JjOiQxKM\ndDkl\r\n=vE64\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f97b70be454d15a04064edf72b9e78e23c23e7d5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-c09e3a0-1593010533835_1593010594680_0.1928822250990574","host":"s3://npm-registry-packages"}},"1.0.5-canary-d660af3-1593010765828":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-d660af3-1593010765828","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-d660af3-1593010765828","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5db4a42014761ec7b230ee5cdff92d0b65de48e0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-d660af3-1593010765828.tgz","fileCount":30,"integrity":"sha512-+5a8mGOc7seZBsDEZDr0Fb1P2IsgIIFNalcZ1d03/aDeGaKao7FUzVj5xk2oPP87hh7q5B5zeEVzeg7UPxVI5A==","signatures":[{"sig":"MEQCIEgZQiZia2Wiaf/EK9gNcO/Q6svC1SXfkT1EmDkmohzEAiBMB0QOcJr+qTf82qdS/Kieg+FNkORYoUv0TrEB7R0mFQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16219,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe82qWCRA9TVsSAnZWagAAY2wP/R8YGPL9YAznm9e9hfV7\nKeUxBe5Uum26K96SH9DkIjt0Tw8VYy5WTnUj/urOemYgYJGMCKQi26cQq8Ts\nkmrULlPy4mIT5XLdmG66v6IM/2d98lqnxxdnodo4AWAoNs0YzVNjCkZp90V0\ncJjTtr1nDRFrivwu4mnZhLIE1sGyzcSFo2lwN0Z/4PWrU5reusFSHh5fEOUr\nu92vmPjkw1CZVAhAvpnlHgAq5sXpRE1XT0hI5JPikrtsbgJ+Wmg+Q1yq8pmp\nWUnM3L+jAX4X7hcU2hWeiKEkb4wex1xk8/dS1KNnfAribvGjM+9egCM7J3Qi\ni2Ifo94yt2LcRef/fT2slrVrSE90y0LXlybVLjqyOEA3NFSRXTbwhaDrZ1Oy\nDa0pMf1jEZFDpromMw8TB6FKVOgFeS+QMv2YyntChSsFyi8cQXEG+Bna8qXT\nFGBnm+8Jd34jMDX1dZXVpHpou5PC5SBC//pcEjyqZ8dSfkPQfiyUhDFnkHtl\n2zWhRzSV9L9LzoqsRtvv06FjDBpDjLKb+d1V4zHmmEe20yPBf5WUtW9AGJ/K\nP37cfUvNPcyfLmjNJCwsxj1HWZ/ssz8mYSJlwEbDY9nvT75XY/WpaDIKwzcU\njnZuqFfbeCzaPE5iDSAAc+5j95wGwhaIx6TzGqSlE67rSj/vOIkpVNTwCZNn\ncT9x\r\n=Kr2S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"53e214b491cf7cd1e148791bcbc01b7653f8fca2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-d660af3-1593010765828_1593010837936_0.8577780407839566","host":"s3://npm-registry-packages"}},"1.0.5-canary-909a7e0-1593011381761":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-909a7e0-1593011381761","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-909a7e0-1593011381761","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cb075d4bfbe3b7b52518a8611ffc8fd14261f7e8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-909a7e0-1593011381761.tgz","fileCount":30,"integrity":"sha512-mb26OkRZKBSm0+HwrVYimc3IIjmi1M0dZ3zOrhsupM3ILoQN6t3KLNTRcYd1kHGN3HDymwkvnr6kj6/glRoAIg==","signatures":[{"sig":"MEUCIC0bMgokmi/WueA7One6Y2Tg8D89Wz6rsPVAYodB/qllAiEAhfr4SAVlzMHcphJmQjhHt5kT4nZPysV5X7hntpy+osY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16219,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe82z8CRA9TVsSAnZWagAAksUP/AvBN0k6QHjteub5ajhw\nltmtl8fLeUmgbwlW1phMeTUc/ELcgfA/9ElWwaLmnzCzGL1m1mQG/Y0FjHfK\nsEEX0KGhvuzo6YbRKr/i4qPuehNhI99Bi+nUZKrsxQkCP5JsDzNsMgB35OSc\nQ549utOhgtOYEIxUAVcwkfd4jySawGKIvUfXNFDfx60wB+yOW+kom/f8B+S8\nAoqKsD5wHzuPKRUf1NgLFIlvAwtYijejJ6k7Mso3BlotrsIsFmYXzz3dIcsx\nqlPPnVDaf3MluZQNoqHzGfXS37wbxFtzpttTkh2Pb+7o9EhDD2VSynHLlI7c\n5in1BrrldRau/1tw6Wgzyb7BUG71VbVAPAUfqAIw1TB4qKH+1DDmaVslGXo8\noH0rCfrFAUmKrFLs9x+4BEio6e6D0kcnbsBDKaX2MrmjfymrIbauq5Xg8fbH\nynSbL3UsyQa9jJQHP6imlXbmqYAWBjVdcYJboMKNXFIgjLDdwhjvVqMuHHUL\nrKzrNrYKYWU7ucPucElVXHj54Dmxvw7dr8XNFgpY4wo6ZTPgRa8GPQII+gNQ\nkrMl2A4nAmnGKd2CfpmmhxGjMtA1Ep9kyMxSWWjd6qzd606aApw8s4gg/iov\nFrKEOTIkYgPJs9FZPjeXWJxw/zsh2L4M6Knw9mQhm/r59+jZMEwJ6+EUaysO\nU+4Y\r\n=aORU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"32be68b69ebb888496bb18b401e3bee0bc6da3a5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-909a7e0-1593011381761_1593011452367_0.090241960120794","host":"s3://npm-registry-packages"}},"1.0.5-canary-ea65594-1593012850440":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-ea65594-1593012850440","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-ea65594-1593012850440","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5b6687ccb8baa5c29d25c59e770081f3542a27f6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-ea65594-1593012850440.tgz","fileCount":30,"integrity":"sha512-5Ip89/0f9guvTIiw2fbM6g+Yxv4w5yvHmhuJ1vJJN1MDDrHoPUvLuziVccW/7LiAXlRbRcCt/Zimhf1guO8EGA==","signatures":[{"sig":"MEUCIEekfCH1QzQWoqWxxeQwYtf8ScNAOG+2EyiMUrfsjeE6AiEArZ2/tnxJHSosWwpEXUccAEEqi1fpgJ4girMOoOM7egE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16219,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe83KwCRA9TVsSAnZWagAAmIYP/jmzs9TplGfa1+1h7SIy\nGQr7cug6fvcnxSZzLBm+ZWqJXr+camgc3ibDT3EJdEHVurqo711+SiMm+jxF\nVGbsgk3T2bbuLtnJdvmG25t/bLCOOTWmjHIamdXwTAmA7XXxBY4bmbNcgcSB\nvDL+FiY78hN3cant89PpxkgiCQ/Al0l+1HduAJPyf35IFHMd3ZI88I0MS9z/\n+09mpCmI4XXPcHwzgNDF+R0YF5E5y9VXI2xGzRtcwjcLsm9XhACptIa6GRNX\noVrUlTqJPIRJ9e7yEy1b5C8urs4hqnH6FKhuvDUSjM+7oOkaXvEs8NKQE42i\n+x84ugQW0IOjXJn2GLVqDKZQCRq40YW89PX+tW8sF3idRDNlEeon1rUtDEhi\nsrNqRt673lNWonMlrUSIgwELRuI4ISknfz0R9rmCvnNgdOS4Fl6AJR1c0ony\nWAqzMAGakg4qbnz7brjeWwUkncE7YWXKExaH2gexrwd5HfCP6nDzo1bNGJT/\nXMuSxbY1khK3NqdnAnD5kbSBPc57WCzO7T6mdKMemH+FqWYG7+EdREYxpNcU\nLIlqPsW40wrwHsD3f+Lw0YaKh5qvpK2Rha4yFqOFkVGeH48X+ulTCC1rNgOT\nxEWBaJ9fmiJccHVkiTtsQns/urL/UMOA4jKymraOn7ZDWOkPelNuzOJQpx1c\niz+o\r\n=amps\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"133bf76159213561a46c765e6cd6f7eec2ceac04","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-ea65594-1593012850440_1593012911712_0.6153641381429436","host":"s3://npm-registry-packages"}},"1.0.5-canary-6a55326-1593018323507":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-6a55326-1593018323507","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-6a55326-1593018323507","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e43793f2eca506cc0faa15634978d35dd423047d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-6a55326-1593018323507.tgz","fileCount":30,"integrity":"sha512-YpkklokEwyNcbJpTPduJRNAUXByvIQw2P7Qf42+kzm6JFCE+moInfzribRDbBDHVE3VjVuFnP9c7q+TxR6tYgw==","signatures":[{"sig":"MEUCIHbJd5QNkO8zFFNNNYpRskapWepJptiBx+yaFfgGt7//AiEAoR5pl00QtP2bCXKsC4507Vz9YCXCqsu+hW9FPgQ9zSI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18025,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe84gPCRA9TVsSAnZWagAAgiUP/Rypz4LZuiwduF2jWxev\nQq7bCihUhnA4kS/oIKgsbm8Hemxz3rSD3sqDJv8xdBswB3chKM0AkCYnucgm\n9XcSr4qc/s3+gGD4KgY6dryYZ55xtsKIj5zoCkAafsmrfeOkFOSqOwT1UDf3\nVlh0Nd8LVqnwEZcgpQAI1I2fIpCWEORazVnZIgOwCgV3nKUAPnjwR003Iz+q\npUM0TdRkXxVJ3IDG08C6gt0kevTXv1snYOQ4J7QQwGmWeH8KMSIhu9w3hap5\n3//zsWiyBgYZ4eCo2c4nSc4QZu64KPlPcZl0WeGs+zltqBBGKvuk5UTcX25x\n4MdcZptUo6IRH0BcQEGGJtQ4KE8EeKg4b4rncMkXQb6ulxWOeXJ+TKST7Bb1\n8PhbGmbSyeKTcAeLFJmEfV2BlqzK70mS8enwL65HQ+q/IjKkgjjfYmScOXNz\nG3r0Zz9KI6zQLJ9Xz+X/qUitusJa+jDDRXs3ngG4zqnGoDEEcDDfRuPpyoyO\n/PR+dXiyuy2bNGESErvYC9HlLWUk+9Rgp2n1S5aP5CbM/ufmO2XGgUsxoWgJ\nG1p5stLQsgE85nxNOc0gqZua/TAoYkTZvsZ8rgzmCSntCLp8TT2Vgc2VRb1S\nECPQAFfHuBnI9tx3ZP7kkObK8G6BR8Ybukw1qsKe7GEkVeq+9osrGyCAz4jm\nY74V\r\n=5cG7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3012fbdcd02e9b4d65a4269c9c8a0eb2901da35b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-6a55326-1593018323507_1593018382543_0.1081594543726101","host":"s3://npm-registry-packages"}},"1.0.5-canary-c38878b-1593019709613":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-c38878b-1593019709613","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-c38878b-1593019709613","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"20e2e606379ca86633469f153ee02bfb8bb3fe83","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-c38878b-1593019709613.tgz","fileCount":30,"integrity":"sha512-RLGPACDwXBUz0r3JcKoHQzw5r/DN+eobjFc5AI1Yb0bDeE+FjCtvB5bjo9x+ROf7CIiDQnlZK5LrzPbF38q3iw==","signatures":[{"sig":"MEUCIC4m5XFI4ax5tEYUQ7nIJTeXn7pFT/XTlUsuJr6NlcAmAiEA1VFMKN/ZCRVMy1pt73vyt8sbdqjLrhIG0DErCDJuaWI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18025,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe842ICRA9TVsSAnZWagAATy8P/1cz2Sa/fTaDXmck/CbH\nAAKCMMmU2dJ2Yj39nVlQlc5eMUOobHBftA943832/v4RPw7OhzPzI7LDz/8O\nqXZXI6js8X7Nq0XQZIQPRmHnVk1I7L53nboAzpBMaiL7i86psm0uJSMrlYJU\nSWdiVvdUV0lChzOxY9P1iinsZsRmSpIYNhKVkh+xyEUWRHiTNYOJwpRd78Xz\nMgHrHckF2HmYM9MxlBVDrlcV5l9ZdSsCJe9yQSnZiV43ANmmzTDcfNQ/i9ma\n8b4yAPjWzPKxfxwnwSoaEHESvrrk58KRaPvtZPiYj5AqBt5Q3o5ucKbkG6FY\nTkIF1ppx4VHGqr4CWm3gdVPOWA3eCSBAaP9eAGVoJb2j7G6NWo7jD8nY+/BT\ngj/ZC9s2ucCmLf7fYhFWeAnxpKsm2/8ooLXjP6L4jRcNyyd91GeDnb7cA/Bi\njSGrF0l5PEM/ZctRSo5G3bq0HuRyXOjkqksJIra3FD4khITpL36J7HBh4Hry\ndskA6pxqNn8MtvYcUppCwqhB+SJUfTZWYB9s5Fiyj/9TsOEw9q85kvZYmgDY\nr90HkWBxg5njtCXP5umlMyS8cALkM0q/h2e04kVT84fNlDlQ9BQRtcRmZJnh\nuG9x5G4xpJb1bdzF4GT3YpPMrkm6eZ5uJcGhfMkV/x3hl2AsWc4xoQXC0f2O\nGo4S\r\n=4Qbp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1619173848e4ff3dfdb2395cf28bc64bd320a9c6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-c38878b-1593019709613_1593019783951_0.39249789168323623","host":"s3://npm-registry-packages"}},"1.0.5-canary-4d8e14c-1593025324104":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-4d8e14c-1593025324104","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-4d8e14c-1593025324104","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"07a46921d95b68797e7cf7c166a991c76dc6c5fd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-4d8e14c-1593025324104.tgz","fileCount":30,"integrity":"sha512-D2jZhfZ8ik+m3s3QQm83Drzx2f8XZbkW9fjT1ZjetpQfT+PK7r80H71qstS0tNFESFI/eGkDZok9XuUdWNoAjQ==","signatures":[{"sig":"MEQCIARqd7W8VtKiVIUuMqJ3hq6JL/TsJA9VZH35GKEDTGdlAiAW53WEWv+IuIzGjOjOKScVWV87BXvREiENKGm96slERw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15799,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe86NsCRA9TVsSAnZWagAAydYQAI2eLFvcUfhp8nYPZbAj\nk9T+kZgqNUubgJw0oV+A6NqrPEPz2NGlrxkTpWz3Ld7vZkhMEsazq5o8qO3D\nqJ2K6BmFRY6N9mQOEVlluiv5x97BzVqKNMF+b23C9/IXPqVN+46ysai10m2j\ntRq4oFDeISmxIpsnWPZlzsgUB9bVnhkh3U+uoC3WRyEHWUfKBf6i5vbtlwRr\nsqHUVXfJU58G4/EpyQlDEAJOErgYSNItM0Y4wFYpGto5W36IOBndzGoGeCFm\nL11KLj+Psr/8Dbl6/B7bUkE5X11frBN7S/9Vrg/J3DfU4+gigq9tuM5RSpqj\nPdPIQ/hJVl/4xUmExjwWAZyEdTTYKsAOmn6hSiMmyHSFZLMuZzbtrOKC01cA\n08RKgL5LQwB4k/7UD0FF7A+wyXE7cLhLiQqe9fh7XiB/3XgaBJFq4jfE5AzJ\n3PuYUNLIn5uXWXA9xUmvr8Jh4whHiiAFfmBVDk7+A+RUJWN92k9a93Yvkudp\nC/cFfHResK1FG7HFA6Gjk1TlmVXyP0TBXjbXEj6ysr3XyaegwvpOwdoNgjKv\nCmU4JRId/s7wgLT9NV9E8GiCHv0ESvnvNkkRUXzINxNbz65cvjWFc2agKj/O\n30f4Xl08YL3WcyWJVv+CVi07JPbwYWZgdw7H6JVVlhHnfVSgz/1whR2RS2U7\nMF5h\r\n=s+oy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `combineGuards`\n\nWhen using fold you will probably encounter cases where a type is a combination (union) of different guards\nto reduce the boilerplate having to write each combination by hand you can use the `combineGuards` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\nconst isTypeAAndB = combineGuards(isTypeA, isTypeB); // :(t: any): t is A & B => boolean\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes the others** but it can sometimes be painfull if one type depends on another, therefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string};\ntype TypeB = { a: 'test'};\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"238eb022259e4d2fcdedc65a7f4711caa85b6202","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-4d8e14c-1593025324104_1593025388450_0.988583233860328","host":"s3://npm-registry-packages"}},"1.0.5-canary-59f9161-1593065385094":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-59f9161-1593065385094","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-59f9161-1593065385094","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ae09db235ca679144f9967f5cb96bb3a513c2799","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-59f9161-1593065385094.tgz","fileCount":26,"integrity":"sha512-1Q9+9ifOtk23HHYlZ/dp48ifarrkafRTeyLfTTUsmLZ0PaD1xF8wO1P9JT6hIahG1Ylss755Gs8v2z+HTGSmtg==","signatures":[{"sig":"MEQCIGU24QX+pAbxs4/iaG493fp589sW5n4qjisyvUpCJj6yAiBlAFp/UYzPSOOB4vU10lP+IuS8p3/+F/wC2PyAQxczKA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16890,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9D/5CRA9TVsSAnZWagAAwFkP/0PA3tfMaDOCY0c7qhj8\nBqFTOO7PQLSnh84h3ue21qaytqvmxcXQHFJXjo3I/ZZxx+v1MCiHc0cui4DA\nW2XIn7fwsdj+AP9OJ26tlgJgKEVMK9WVF38ckk9OlQIwKU4Wq2gJ2CIY3LsH\nNLw1AakKDoeBMfIqMXOoyodltISyHay/uamRBOB+shiTebNXrV8lZZ80fOBH\nFDAxqEG3lGZZOnMYgo3l9fEOzZmhuvPb/T1BGDbWB9/azSinSxzn2d6sSOBC\nFzkFeczKiHz94iBMSWUwdCx9Q39z4wjUbJCm2RcslAz6REiWc0Q7/MmIk/bJ\nHsRvrtuTbnQmzXR9bIvt+dEHdSZ43cW6bY9GUxy7N6w2qa7qHJowoz0DjOvx\nysRk7scEB6ZXCfoz6oN05RUVJ0425/5A656lUa1cCNusiKKECtImQ9KeofPE\ni/H/UJTC2nU9VpNPEbnDeCTP4nturIByPmKIIOBVf4zUu9oVodPuHRf9/bOz\npS19OSJOm9XIYrUmrh3BgEW73TlaITMN7372PaRYaW3OZvVvt6bs9uXpzb+3\nHYAIygfz5Jt3zt/Vi2PdAA8x+5AvcpI4FH+zHoDyFXDrsI4gL8vHIh7zbSuw\ntdHtwpFFAjCnmVfT22wHQb1b38pHkTHYmqeZx1XGeGk1niAKnijzNrPFBpAQ\nS9TF\r\n=AMM1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"30b4a9f20be4b738ae5f477a03028a3c9bebda1f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@types/jest":"^26.0.0","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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-59f9161-1593065385094_1593065464930_0.3665706978208163","host":"s3://npm-registry-packages"}},"1.0.5-canary-63e3f39-1593065501640":{"name":"@iadvize-oss/foldable-helpers","version":"1.0.5-canary-63e3f39-1593065501640","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@1.0.5-canary-63e3f39-1593065501640","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"683856c67b4d359216b6517b6092cd2ae44e5cf9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-1.0.5-canary-63e3f39-1593065501640.tgz","fileCount":26,"integrity":"sha512-3PjaThBNAuKla+Soh3kiAm8nwssypxBL2lNeRE/firlNGycL/WyEkZ88gy+Wtuyf9Yz0/lyk3hVC/PLXU8xJ5g==","signatures":[{"sig":"MEUCIQC+S56k8yL0P3dWLJuqUIpwC4DfA+33SUHShcvNj230CAIgSRlO+6F7x55nGphZ4JfoCFGI4jJluVP7GKBQLZfI3qc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16890,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9EDICRA9TVsSAnZWagAAUSsP/RzaRQ4zSdNn2Par4kYL\nHrqbyAObI81LWRYKfPtVQRj69xWjF8By/unncedyiqc2WnkfkuvRc9WKieFz\n2YIqASVuSMoUtq389ntd2bNP1n1RtAR0VLTI8jabzvcQsPJmOk9cNvb8OQ2/\nXb5E9G+rqX+mbL1KCEFOqF/yFZ0LUpXRra534b3RCB+JxJs/H4xgWh4oPBCV\ntelsernYDIn1Va5xtE87xKRkpopV5DNhAGaEp8lYl1CM3edQCVMfp64aedSO\nuIe6QsjTRwP2I3DsWcu5YIegM8a22bY6fEQvVwy694KAW9pAskMs4tMjKTXF\n5tDN1c072BnYbcDc5EuZtOu4B87s1rx1SXyJcolhJmg7LFz2Q6TxQ/u0N8m3\nRUVvqjUBKH3b0fdTHZ0h2rH2cHQJ6g2B9XJ5u8v6Nfmu17H04zAVTMl74pu2\n4y7BCxikbP+tdZgLszYi4G1BvZoZpcg6l6I+uCWBjysKUNmtIWpI/91c7RW0\n39aHhrCi8PWI0k96DnTVdkNo/ZvoQvYx60OtXrwEnug+gxGzlAhY9pOvCCpP\n4taXQJM3D5vtZ+yeXC5qOS3HhUdVGIW7kgeRIzqi/EJhYLnv60SA8gW0YOz5\n9zb+vEtb+hQBjZcml5EG7Ety0FvbfUpt6nOWXQLGaF5JkKCbP5fJU6A5sJv4\neT0y\r\n=JY2v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e384191522d6e12d0f3a443b4af58fd8d9b02b0b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_1.0.5-canary-63e3f39-1593065501640_1593065671746_0.9863890029727986","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"535714ceb47fd20ccf6fab1fbca7f42d08aa0d0a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0.tgz","fileCount":26,"integrity":"sha512-r1AdD7B0EpYKLigRZKnEhY4LKG0onToGRjNrjfYnEijGKhpPJMTCuk6zW5tPERto7gEHD0Krhy+8Z5Ji/Z1iYg==","signatures":[{"sig":"MEQCIBfHI8X5bLRgtmNV9aK7wssOJjy42bFwQUxOrLM8zeGSAiBQXSmLgN6lK7LsqcUR46nbs1rMdVxHtUSxeFpwFE8O0Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16958,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9GABCRA9TVsSAnZWagAAHhoP/ixW90BKVOemWDywZyAm\nXsO1yFVQFAmKTBoDtDPTfkv2WxtPPhg8uZE6WP9OfWPDFfiiu5yEAAy/sBBO\nyF6x70k0QZluOlP+KmzGgB97pzK1YS+eAM8CNi/l6k6+T8XH3UkYlGwiC+CJ\nnYxErEMsZpJddJY2RvZHX6wXMo/SGmM0s0RyH1Nd3e1xaWxk2tJbHiBT0et2\nTkndXWY+55OvrAUItyDdV0xh62fVFQVkBl1dtzCM3u0prVxxEcVtm9DYWAHY\noAVUWfN9slKXKYdUJ5FT5vdO6mV2P/jCKSxQXFJm+0I7YDKqpBfonGRPKgBp\nM8WTBstXjjmi/p5aOqOF1LiAZIw1eS4HOHD/vvaSaYYEoCIGmIZghmV0OWeN\nn0JRN13rDXYcJWO0LkJJhAWnuU1DOrrrIIJEqYPbfLRzCkVyZlpu95VOSczg\nz04scLsRqC45Onl3RT4VPPpR/hNrI4HnD7vrHRkAWWJGv1r4J7B+hGpEptMz\njlU+xSFkqwuD6WMmCJR5I+zX9hjz68GUacsqyM6qvZir/FDn9sxtQIjM9FcM\nDNCws2ZxYLQyu/dlUaW0jNT108ef4jCvxGacCBLRrHOryv8Ma9CANZ/TUetP\n1XsvZZOjVzoQqQ/4qKVq4offDA6OeI4WOaN/xd8+pD1FrYMj404/F3UAZWAi\nv3wX\r\n=rOcX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"6c694cc2c35b2e9e24762bfd569575869bd02d86","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0_1593073664898_0.16086077193249193","host":"s3://npm-registry-packages"}},"2.0.0-canary-79940dd-1593192408613":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-79940dd-1593192408613","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-79940dd-1593192408613","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7301ec73b134d485df146d47f25583c931ba27e7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-79940dd-1593192408613.tgz","fileCount":26,"integrity":"sha512-6F5udSFg3F6dbA7w8ES7cMW4JpKV0Q+NPr1aqr7WI8bgeguUVGn9XhmDnX7QDwc8NtlZAkn2Mgo0I8dQvDcnMA==","signatures":[{"sig":"MEUCIADaskuwcOPVdhOiaU1DNPv6iRf3gdHxlTZSE7O5SMe/AiEA69cER8tVLHNW4Pfg9f2MkQk4dY3udPsf4ikFw/LJ0mY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9jAbCRA9TVsSAnZWagAAu78P+gJqcAzz65U4HoBomNgw\nSUucq5t8DXz2Ek/r+kBI1QIM3rO8su3Qhr2X+Vbs0uTF4cbtJAlM1e34HEiW\nfQrZFS04lOgA8gMYPS0B9iyeuL1z4+B9tT8+m8a2p/aa3nKRzCO/Sllbd/pu\nUL/WmF45LKKGnZm99UKpxgDavMAr1rFBBXDYmSBvPhrTQ2X/QbAIBuTgRhbU\nM0SOfkcwCOQ5Us6QD6x3cyiIgl+2FKYueGCIxt/35/HAHqEStVlt9DCeJdMt\nLOMrHzoWbG/e03MeHRU3BaOaakvC4fbVyOkHh18CU+8vFyZLox64WIFzH2vP\n6gQc7TI3KnRRD89d7BHHBU57X0XHY5gW9nhQpJ+vby/GHfIOBH1qCgZg2kbW\nKi/PKVvmJQGu+Zk+SUVYU4CY5waQBEW5O6lHPNDA/YYyHZYKg845Usj4q4ek\njIAwVh9P05YmhSdGio/9c1MjNznUW8KjFCyr6iFL+5Vv9U0erDVNgAI9YDYU\nyJunmageyHUJYXVpM1+j8PhK8I8jPQu2sd17bxf0MJJWrklxuDUPF4mA1TjD\nYQOH3x2VVcImhV3NMExnL4pLmnU+4wGXaVs7M8Sjerz1vm6572bL/nQASUwI\n1R/zZF3I/MGQ/SwnxvCsciYakPUTI6kRaOFBtKgPEUILBVor4TIrCpwaSur1\nL51m\r\n=CW7r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"142fcfd4faf8529ded7df9d51a31eba449a0d599","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.0","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.2.0","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-79940dd-1593192408613_1593192475092_0.9460465188446698","host":"s3://npm-registry-packages"}},"2.0.0-canary-dfb1e38-1593200912080":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-dfb1e38-1593200912080","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-dfb1e38-1593200912080","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"92a7c24579a3ce70fe8c18b5880a23a470d79880","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-dfb1e38-1593200912080.tgz","fileCount":26,"integrity":"sha512-z/l4r3Thi+0ZOAfpExteA2Uy2pAxSvh+dQUhLEPlnwe1++8Hs7JEDp8PsF015+Fnacs85NTpGHIAW2wvp63eVw==","signatures":[{"sig":"MEUCIHsCY09XlJNQhQIOpK9aVjx1h2iqYyUogNC3YUOrbMjHAiEA5475dt4Na74x0/8+4n3kHP6+BlHGXlc29gKjaKbxzOE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9lFTCRA9TVsSAnZWagAAvqoP/2jJU1LmUignIpNSmnFt\nVIMBxr0ApuN2D2aaZLe2dIZWQT4jaWMayf6Q/cC15D5Y1e9SZZVXHsA8bnNe\nj1v8PYOJo1H6S1hCFoDNyxSVfjvGlAOdfw2mbvab4rBSDuUraInqaS0hDN+C\nYJ9VGucRw/aBzm5GYF/97PT0/yLBQ6m2KLdsLPlHdZMNf31x+KpQnhEz+1x6\nkv3UwksThBpdDDKfYMHdHCxNSnfU70fpR3qJDjwPrGhlc6YHExOOwcfQkbxo\nJFWYS+C4Z2+Ow1/nxrKaMrMIC4ocdYiDGRA5IJV/8vl6lKIy2rIvOEgQwe/u\n+C0N5pcx3sI2CiQ21epns+YKyUPZpufsZMUGqgnSCXShZAXgtheDsygouy2U\nPm11jiutIxycDu6kXm7lQuET3qurt373tM0yXJ5eAn1Bi/nrvB6ugB5u2dA1\nOb8cCQRtzPN67iryizlYeptgxD06lQnKLALwg0uFtZsqEg1SBZlkWzJRVoql\nPF848TSXtwVqOKZjL+vbBnM+i5raICunxLPBBWg16p6ls8WHs55OSRNDxz/5\nR9NrXSJ7XU5KviVd9mZeRFFP66/+/hpVK/US1DdqQM9V1tFG/11bdN+uif3R\nDk9LutRK5Jk3ihO3FTGPq84usr4LEBYxGFs8Ig82mXuw55eFCaRHv9mnKDQd\nAseD\r\n=cK1R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8a23e5bdf3d77fa359bec93b8b5d25d4a7334897","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.1.3","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-dfb1e38-1593200912080_1593200978687_0.718082245341972","host":"s3://npm-registry-packages"}},"2.0.0-canary-ff6a964-1593348284068":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-ff6a964-1593348284068","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-ff6a964-1593348284068","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3c3c4053557f8e503dd71d46d021b5657df0d6aa","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-ff6a964-1593348284068.tgz","fileCount":26,"integrity":"sha512-B5z5Q3TNpEE0hKFRDBEBtXou1GaTrLzKMylAJy+L6MsWIczVLl6lPKBQvFp+ox4oOqQoxZKeAitUuLp0+KCddw==","signatures":[{"sig":"MEUCIQDpPi8raPlwOAQ7SoCTRbLgoOnR/BYDSWE40lqzr/51HAIgC6FWXtRUmclW0fCA4We1bi0KOkHbBk3BO9ge0H/mFI8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+JD5CRA9TVsSAnZWagAA8NMP/RH4Q9K+Br4H80tfdSZ5\nAoYQPVZ2pMktoHHVCnF3KVsQNIlAOUmVt0EFDHhxqLnN29hKgu4/BrslVhtt\nCBOROwXBFnCmy+1qlGSIaQZwvifOQe8G2ccaggsCOJarRXsopxAttBObel1C\nsz7VoWDh+WDYOEA/aKsqf1TSFK4iSB5FN4l+KoSANoWE1Ty9QWAyYq8lXh/E\nPQW3AVt+kiOVPLQsmUXVG1uwYX1GPwHYga7ltAKbxeVTgiSXJsEI0kvXyvhT\n6rIJ/lCNr9xPMFY7VIyJhqlQv08XCmZ0cIvcH0NpyMOSdlY/FvQpCzew+E+n\nY7Ttzuit++XqFD5g1YbFlt+3puvRewsJ7bKoYPc/cK4K2TmcSQTnn2ydT5SP\nZTeOO1HIrgY0dzDVZlEVGMOoY8kXNn6hS3SBnpPQyhG+qUs2C4EUD7QBsKm/\nCepHZUGRnrYiitY2Fc160pySwJuSr7ZAeFpOyPLzn8XlbgtV7tpzN4G6Csef\nKcI45XMBBiHvbFbCfQEzDTmHa7Va/0l/qS2yxX393N+7yZ/QyFvXy33+p97T\naH/25zbQAPTZt7QaXy0mgolRg4DXJATImsZfvozEHJESl5zO6IKYZifD7o8w\nFM9GGlcCQlvXtmEk376tFypVcTJypnl9XY8NPCSbO3/0v0xNRh7oXDSNVDE/\nXsfm\r\n=h6jV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3be8dd223257344814fd30c2925255169d86314b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-ff6a964-1593348284068_1593348345411_0.634596956242542","host":"s3://npm-registry-packages"}},"2.0.0-canary-ea9a968-1593348545287":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-ea9a968-1593348545287","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-ea9a968-1593348545287","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f024da0e672e1c6da512d8c72487bb6637455861","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-ea9a968-1593348545287.tgz","fileCount":26,"integrity":"sha512-085ZuQHY5jGxm/z7nNLiIRFCV6oA2x3YIXOxMEJWHtO5ZfgGmWZXUgq2bHaMvVqI2JccY9CriPP5oWB9L5AjYQ==","signatures":[{"sig":"MEYCIQDtPBdL/DmggKl5X7A/rBWnq6QS48bWxVUCLexyaZR2WwIhAMccAmF09sAl6XXFgXaiTTubtPoxeX5q5tZBPADsAZMn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+JIDCRA9TVsSAnZWagAAXoUP/0r+WAdz9FKzEjTIJcyP\n0WRTDJhc/D7c5MRGQ4LP7Mg0Xf/CVmBIa1KsAj8HHgyhauxRJks5A9oeAB4y\nNlXQfzJehE8QJd9mWteBoUccqR8CU1jXFG3c3O+2UdlDvG3cK4SjelM12M0Z\niZUvJSLwz/5WQ011o8dmPBG0Qb5qA8hNk8+rKeVVhx8aN/sh0LsEGQsaW1ZL\naku66YqAzgkWCcsGLQQTyTRSiLD5YZ5cM8XHfRoYijrQBdL8Rt7kduhG1LGV\nQpbMqZrRO3Qx/DQEYo0KSd7pPhdeL4bzy48iQ1tFiS6arvqEs+XbhKWuBs60\n9A5bj2DMaSRFd5+JRuq//HXptx3+NLU2jEX1VTpAN5CIS7Z7p5+6CqGzoYro\nTsIDKk2A1AqHt0gjBu19yvMv5J1et9W7sJ7TNfhllr5VNYbK4O7nxm9mRNik\niRkVfpncgztDGW3+rEdqOdu/ghVlTneS0PdfhC4NjAUG0nj2DWj5GgwMXMB+\nO4yLcpmakLACkAOhTBduuslA9mDheZLZ1ZmhsMME9T0p2NryiCE4TQtCn9EU\nhxWapvC/Abd7x6HxJBAMn+BFdiuZZWXpNgGGf8sUm8ICBAn3cLJpV4a5oZxU\ngVK+an1CHHbG1tnbO+4C8wJUisZpUiyTGKDFziPbX6xbpvnzFyUf+VtxQAHM\noRj8\r\n=JFgg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aeaf488d0b4bfe230dee3639a8c8188c8d064245","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-ea9a968-1593348545287_1593348610716_0.19192583867005486","host":"s3://npm-registry-packages"}},"2.0.0-canary-0aa2a29-1593348661611":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-0aa2a29-1593348661611","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-0aa2a29-1593348661611","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fbf52fe2a729d1f16c32a6fb6736770d4fd92d53","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-0aa2a29-1593348661611.tgz","fileCount":26,"integrity":"sha512-XbgU/UArKBdalIwF6hno2RR6NW39Wk3lddHNzRk4TTyN5orLhjB1nhfKCfaK41+8ogEmSgkvNa9wGNX6mB2emg==","signatures":[{"sig":"MEUCIE8j40C++Mts1vHhZn//ze+/886vbUum/vKzwT//3afCAiEAp7drIDR2Rh7XymGVw+N0a4PQsQF0lcuTcsu7Xr+AjN0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+JKKCRA9TVsSAnZWagAA3GsP/1VW41YnQ5aicLpKCu4U\n7NvuYqgAzTILTpBUiJBgeg9BSUGTfmV330vQNRdqWa9cKYgs80xlM2N6tcHo\nIoAVmxlwh3b/omkgEgaE/Aj62102Dic259Uyr/XN6qaWg1IqUTncxYMQQGsF\nPDxYRpCiZDB6Qgt+BQ1tsMoqxRFEqiB61gQnfxFoWmwddvc6VRT5/Uo0rP7p\nDwJjoawH4B45TFVr3D5hMpA4/Ptmedl72mAz8MDJaCuMtdEXXbq6VGqFNPks\nVFZoTiuPY5qUK1qzsLkLH07GxMpDsJou6AbJLm+CVoVdgLIAA+7KOt6EB2IM\noNZ8DyJjvorsyKHbaDRlJla8/wnd2PI7neFNvIHT6pov5a9tqJnsgQJa7ukm\nJ5EdIfTw+6GsqH7LTgVwHasot+VFi/VSCCyMYjU/vD5YhPBfyWP9si/sTgiL\nvUUB3arrsoZL8XvVhv0MIIofUqwQlmRhJWFNn/eNHR6uUG5L+nkSQaJitJ0e\nXlc3ugvfXUPyfD17ihjCWloXXJil76zmbAoA7CALGaYrtb5+fv2OD3BePGK3\nVSLXuL8dnuAzK3vaKsRHAP2znALc5zivV3GWhCyi8ccv92VRoyvYyr4kLnJb\nkjDSuIPa/HzByt6sKLaMkuJOxU7k/bkrWCZ/5y1Xd5rVHoSdP1zv7UX0Gr23\nmKBx\r\n=HiRB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8b10844ce725796735dbb5475aee964c5eb3ab85","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.7","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-0aa2a29-1593348661611_1593348746069_0.3822285976440367","host":"s3://npm-registry-packages"}},"2.0.0-canary-4d5125c-1593394293929":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-4d5125c-1593394293929","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-4d5125c-1593394293929","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8a2daa916815642e9f4bc91f807f3fe02d353e3f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-4d5125c-1593394293929.tgz","fileCount":26,"integrity":"sha512-p4nyKL26+NGfnHuvLBdUIxh0QMeJJDwNcpKbE26F3N9hZpGmmPPXhvJyVmI1YzsRsiw928kXWaGkUVZNAU0rXg==","signatures":[{"sig":"MEYCIQDNx8v5gNBMsJiVVw9YlJRIjdFH1auvk2yx4UtYh8vsFAIhAKKDgli64vscbXZk74rbZOLffh0XF+17xt2rcdWH4TeV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+UUrCRA9TVsSAnZWagAA8/kP/R9+MF59fVA5u83hZ5KO\nYh5n6z1kyABNofjk9yHPGdQGuxJ+m3Qp2rYNy6hE7/M0eTn8JM4Z4aP3YelY\nydVkr4HpFg7UWFxELs0df/A4MvvbnJgh8017bWQNhs45lRaTRhG80KoML5D7\n5e6LJ7GLclOUDA/LnwCbHBE993PuqPSrV/vp+2/H0PE/aprTA00jdXh3Ed4x\ncW7UUeODiKIRSnNSKCt2eI7KFbo2TaLI/iPppuQZqStkkU8fJcuBUl+ZhjDU\nRIIefFrHWBRZlMdNMpw2+/lLqryWYx/Rn08nJvwuUEGOuzpgtFB6xaDU/0SN\ni9Qy2VO5vkOF3UiYzPJOei0J/yweQGglfrl9NGx0DqXLwZtmYu/FhuB+SGaD\ng6V72OOZLf4Iej/ki5Gq52njjQ0p2BvLvpU0EnCub6pTUAS+LIWF79SfHNrz\npXqywfmpmykLDOits5t+YaGJzZMqej7eXhK7uQGBNrzmeo8RQCV+ckedgRAl\nGvQa6UrhKgYkPTMgBRxbwaWcaiQcA4y0FCWs0BMuI7Wfza7LNGjyK5sFFqWm\nfikO2RHILDG5VGQAXIRkebIVDkkag4b1dh/0fF+Ig/aFL91wk5Jo+IoC4aZ2\n0mnnGWT6d1D7VGbfvIXVzsD8g4YwK8dIzc0zeAmNytLBod7aIOskf+oNTXCW\n6uNh\r\n=4s3a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6e264916d503ac551192709954f87056e09095a7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-4d5125c-1593394293929_1593394474479_0.19725368190595094","host":"s3://npm-registry-packages"}},"2.0.0-canary-93406bc-1593425572458":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-93406bc-1593425572458","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-93406bc-1593425572458","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"146f89f1367f676a8d45504eca0a8a4f2d5d6549","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-93406bc-1593425572458.tgz","fileCount":26,"integrity":"sha512-kx44RgBYYuZoz/ovDALcRce0avm2PVK9nRz5Vdhbk47ySPIO4t1XDQcY0k6iI7DcPEUOv2zTl1hJm+Lu40Dbkg==","signatures":[{"sig":"MEUCIFAqAeCHRDI7v1wqVatKGD1icVLbsUieH59NiCF954o/AiEAw/ipce6w9AX+AauCB5WQB7oGLbnXVPh6CQN8OCX1gNM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+b7mCRA9TVsSAnZWagAAPJoP/A4peBvg8cxgJyT1EObO\nJYP3VPnFJK2XEA7iElEno8WzL2BOx1msvWgLF8Dx26budiDxhgdHebukZvi3\n5423Q+u9/tUMyUvWXocZ5Oegis6jLx18t9QWtCmQZwA1+5rtTUp5BWaaoRZp\n5tw0tqJmMgg123uaTMcgWD7f2Vp8djN2w/GwydzBKZWTgarf9bqDwZo2naQk\nMPEezkpliz0hqTW7cuK331udZq6bq3e9t4CELnLdAE4L83EZggCbSvLdi88t\nMvi0WT7vYRL/hGGKp2THfIzrLAiDxXEH5IgwTK2CT6PVFLwv9WlBkkrBCU+O\nQQPBuB2P2YJAcfYqQ1GZV1zBTPnMrX0NLXBmiaAh5K5fRVWNBcdDK1VdftSS\nP5NvXpn9hZmd+5DH5JPo7uVGM8S85dsj6YuxuhgF3riZEFULL5aPHAYVLG2b\ncYmV53Fz82Yf19w3itKc/BEs9TRXJ+AkRPN0+RBSR+ApdmdOxC3kovhsK2OL\nT0CQbPTpXAetn3FndIcD7PXe7RbU9n2iz1y2EYvdhwYLX52Sxljx08/UWmHh\ng782k7MY/LYZ56x1Jrh51u2udWNOeyxXPQejn1IICTKgoeN5NI+pGpL3JDP3\nhHlvuFhspQAdFU0wHnLEMmE7m8E4+dqizirxcH5CTYm6P7bsF5MrsJ2hefyF\nz/3p\r\n=ODet\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ea64a3e5318eb095ca0d6d0c1b6501c13c249f7b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.7"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-93406bc-1593425572458_1593425638106_0.6786265568078296","host":"s3://npm-registry-packages"}},"2.0.0-canary-ac29b7d-1593434181624":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-ac29b7d-1593434181624","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-ac29b7d-1593434181624","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eaf233a390855dc24fa83c687c82237f1911e1f7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-ac29b7d-1593434181624.tgz","fileCount":26,"integrity":"sha512-8HV2aypcZTDumF1zgD5zeKQJHu5naDyhdbefP3uvuD8oRS3WuzujGfW8Iid8879bEaDqUpQ3VcntbqDfojeH5Q==","signatures":[{"sig":"MEQCIGhTPqszCoAnqRIvcF4QA27A0HarUfrl4wCCuCPy8G1wAiADztQnV7KRIOGQ6NyicX0HXpVLbYX8/4cTuPaeww0dWw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+eB8CRA9TVsSAnZWagAAF6wP/Rb5rN9AzvzjN/WRXMde\n7wDi9hDt0ifHWI0FaIsdQuyxA+XgHoOMp9ELC961rZHrvhovEZxMCNm/Zsl0\nyG5x/bfmFbl9Wg79m9NmRCtv+XwMSdnGbV5Ir89Oy+88w1ibv4bq9fWpzad7\nTFa59LsVKdY/Hz+x0Nu2cC1sHxFpixtWa0UBrQXIJBArLi4l7C3gOjn74S/8\nBR15Inot1kUx3JbVaKdc1AhfP1Dy3NDKCs5m+Nxp6eyZry29eojIL1T/9CXh\nftLlOSy1HtkPgyKK3ZK3hFeybYnxHAS0IN5fxBnJ4MRvxk47/+0467U7+YEO\nqLmDg36ZUnQjJUTgjLLgWWkYeVMqDd7Grf3nsrG1e7ndC6WMbKoyBny1vKar\nDRB/yb1DSo2PNBrGAGMOKrqpSCK2bXjS/34pk4i48QFQQ+BJBFgoYyPFJS7m\n8Wv4GtCFSPjPPj4ZKc3Vn5JyqUZ68AkeR2hBCPY0e42VPJHY2gD+F/PilU1i\n73tj/kdDo0i6dRz7US6Zzz9CkFLaFDEK7QsMPppY71VLcUm2s3zMb7bqQ/ul\n5NMLX8TxLqn5h64pHAq2w0qv2UHr+JyD2eH27aDc/KoY9UOCVqxvZkcWFhgk\nNRj/s7WrubUdZoMgR7LtW4KyBfkQR2QIkAN0zgICfoZntKJN4Fq0K9RcJe7t\nxn5H\r\n=PmgZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ae42ba754eff7da0b6622928d5ab13f13ab88653","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-ac29b7d-1593434181624_1593434235551_0.8673708813078909","host":"s3://npm-registry-packages"}},"2.0.0-canary-e1d50e7-1593434776199":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-e1d50e7-1593434776199","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-e1d50e7-1593434776199","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6f8b5f26edb8f8ba5e95f1f4c50906c67f244d9c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-e1d50e7-1593434776199.tgz","fileCount":26,"integrity":"sha512-jjwbdAmJbHd6cka6GHtbQ/MBibQTk04qRNg5I2+pYRyhoNxPdj1j+6g0VxGTKngr2SgD0nB/89q9GPiy0M8JCw==","signatures":[{"sig":"MEQCIEPMepRZvhQKK6243OblwNUuYX86OHzKhWs9YkTXhaNHAiBD8VlWepI/jFUA85+862hLjcKDX8A7qK+V723tiOC6gQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+eLhCRA9TVsSAnZWagAA0v0P/jXfnB6TchE/IlNMXRGR\nbywYlACgmTe/qkJP9fm+SIzEOkRDp4MTokMWOnjyHwLPUnkoOUwAdetOyFMI\n+AsT9VWCtEM79hghR1COvxqpF6as1OY/EM2g86sMos+ds/CeDpA7QPzm+7ni\n2r+n0x15eMc0tYmUyfJPwR5Fe1E2+u/kDjuvW8NblYTRwwt8fcmgQIX/RyGX\nNhyfPEPKaHn32G5d1Nj9qHyp8577nEtVOLBpMa+rhKJlxQkkPMeb5gYSdesU\nGX8OqvJm9AsgWI9T2yKbHGodohmvPonL+jGwR4GDrQT0Iuwg6cxCNMG8dFJw\nlEszjVi/SzU2T0/HhmEGG/m17gYoJI+j9l/pSoYlaUr4bqTY3GxYjWVj/hY9\nt3P/WQTVtx6vFuRv3DaCQp3vCU6CEKj4dVe1OW6/hD7ZD7aYry7zh8NPtHZK\nW7GU0zdSB/w0OS0nJo6DzWHeAYStI91Astmv8vARclkLrAXlexI/YagJviF1\nKssOW7qjeuVdzVtlvzk2bCpkfjkyNqbFk3+xBqY3PfRwQ+QFyBmyqNrYaxB8\nNMkxnJtBgyg5bqkk8MdSCtWXeTJvRBWZJEraLE/uePslHsuuudmXwj6pa8mg\nHC/9Qqpgr5Xsy9vsVOdiVC6GQ5M1nxOLpt+8uiUE0YO1m2RzBOCZgMQlLGJT\nSkTm\r\n=bpDM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f1b2b666a986cc2a0e9ae7ea00fe9d880272d318","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-e1d50e7-1593434776199_1593434849310_0.5201391411311826","host":"s3://npm-registry-packages"}},"2.0.0-canary-af5fb3e-1593555230575":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-af5fb3e-1593555230575","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-af5fb3e-1593555230575","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"08b72ea9491082b95955c9f253da1dc818936378","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-af5fb3e-1593555230575.tgz","fileCount":26,"integrity":"sha512-I5FsaKwqArLxBJd9sHORgg3aJTNKeWjEqNTP4PzP5l2XEXcF/vteq1Zj9fqF43ja54bTgmTwzBQDPSAlY2aMoQ==","signatures":[{"sig":"MEUCIFqv8jd0cXyPqzIyPuw4ElZ7RYfKEPUTJtrPbhWJiKJUAiEAlLRFxyNPg2e6pW6EVKHLSRA0haIM3pk2MXegtoHXnfI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+7lcCRA9TVsSAnZWagAAA6cP/22ezJ4fuBq6xlVL+nYR\nrNIZXi8+4i9NbA9SomIUrRuHSWQJPZyox4W0Xq3fBvEsNDUqZNlparhdcBSw\nI+bIMZQNLloLPQ1Klr4rKepXOecc4FiyBzBYonls3K0x1fHpld3jx977pCvF\nEkzL62X6nKyhN2NTRBd3aaeNc3JlRAWFqiZO2CVcInuD/aGZK8AZ4ZXhBgbg\nWRvyfAlwfNC3/2JEcTA8KOP21bg5XJRr7rany9T3jtLPzyfLB4H2J1E8J8Ya\nwpvZKTafNh0//6ppNiruOgnwwOkJQpK3Ysgi0kpKaHlsgLJIj6rmiAAvS/5W\nX32M7vCpcN/Wf1mpGthPJVF+xOnM1HZgd4gzowa2VwatDrymxh2A1oBkaA0t\nXweLmTruBF+TRh/oq2CgEg3kDC8mdDNGzXNcmWRaOAci8AufRoZ7YePZ89b3\nvMiurUmuUSdeDtBja6UUWfqS9x+bf3NI/P0MT5lSzKEhrxIa1vs6if2X4xXn\nHi0c/j8QmfGa3vP4Ni9QmDcp3r1o0feL7Ek3vIxM8zJPG6De6Fp38DDpfOCL\n0cIVijb3L/qdlIdLyZw0WmObYMr+OuxTMGdE3xK2ZCF0069oDRicK5K7wSlL\nlN6G6Fut6FZvdIQi0yyZcPJyAOYzTIxu2dYcTDCDJzCUbZS5eUYDefC4cPYc\n1Kj/\r\n=YeX4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"86d4546338e299c983d89e80f544e9e082409cd5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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":"^1.2.1","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-af5fb3e-1593555230575_1593555292313_0.4197748841922102","host":"s3://npm-registry-packages"}},"2.0.0-canary-eb437fa-1593586852128":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-eb437fa-1593586852128","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-eb437fa-1593586852128","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6a6c71d8e98d99930607144d2bc6467674ccc63f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-eb437fa-1593586852128.tgz","fileCount":26,"integrity":"sha512-xSy2UqD3o3GcbJrtA0DeNF21GPUmXan5s7wfr5H6ZCzi46i13P8e6eCUcxCNdjNwTVCr2cYp3Z/nSPI8nXrpIw==","signatures":[{"sig":"MEYCIQCOjr7l0m7eIgf03OuRgWdIv3ujhuQqyVvFTw5idkootQIhANw35H/2dJHt/7RhqlMWaoNmZAwrbM2o9kv3hpkMsbJi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/DTlCRA9TVsSAnZWagAAd6EP/iZZ9tgaM7X/0K287xuK\nmgvxB6sQQgLAeFf0GpXUtpj3Hfip7GuA3C4ARifJdg+OYDOtvblzCgSkpaGS\nf1yZOhtK6StbquRgihnWHNjFzSuFoBqxQ9eKrIpo0e43gnaPGRUrNdfq6d4y\n7A09tz45/VeSLw3nRA0+/IM617LRSY7eB5EEOCkHqYYI4Wl1jRi0QgGY5wu4\ncJq4aoy2K1dMI+3CE8Elkpt4XKvjtTrwMEU9chq4tP4B/37LlmVxEYBmWeqn\nxI9ToZSOcMOk7DFz5L5kFjpuBfvl0DAhiZkY26sMjDaR452LSrAD3ZOlPhYA\nC6Ksr97opp5R6CdnaO//TcYCBp/PSAlJjVwf6lT1IobVPrGcPL45sRtfasg+\nhkfrk/CZZUtu2NOFYnls4D7gl0DGhsfjlyauF2mjatzDq2Dq6XOD5F01MQ+w\nr2FqkmFUIK0DaX5e4A8M4jGt6A7BOgZ5higRfisTjLUZNs1aI1q/ZFDlXL5g\nbZ0tZS1AWnq5e7IwKfKiwDgJ4Q/y1AJ5tagNRBm0dTa6OBQcbD2ZHDoeo91l\nNKNZIF9VzZqYzyuFoUmo6HAvmygcZewMIfY8qGQ8USLWAUk72lzsKy61j0HC\n6TRyDgsr36hrQOqOfN18Y4izTjVWqYaCpNeicZKCObrCmrLrtkqO3wzweHPQ\n1LZK\r\n=y5uS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"64e1d6f121968bcfd289805748842571fe3b0c9f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.1","ts-jest":"^26.1.1","typedoc":"^0.17.8","typescript":"^3.9.5","@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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-eb437fa-1593586852128_1593586916410_0.014083831378306932","host":"s3://npm-registry-packages"}},"2.0.0-canary-620da2b-1593636940777":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-620da2b-1593636940777","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-620da2b-1593636940777","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8a6ce3630f8027d4fab2de90c1b4a2ce917a2d21","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-620da2b-1593636940777.tgz","fileCount":26,"integrity":"sha512-ZPe5s1Mf/bUxY1brW2IxvqQq4aG2tHg3PCpvWtGXbUYs0ys7GpQvOp9odqekRYNbRg1aUIQTvKdrONaXlwRZEA==","signatures":[{"sig":"MEQCIC35iz/Tif88Ngpf7tERQcmude+mfAzzM7LW8h2fLe5HAiB9Hosbqpfxa8bfyGIz0+8y+PH4tPjuL0UmLxh2Y8sRDw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/PiHCRA9TVsSAnZWagAA3nAQAINNJOmljsp0vAuB8Skf\nei87kmEgYuwQ+/wYykNB7GmHKL6Ex1ROsEKlDZGpn9OUXMSvvSTl8L/cVgFk\nZlKdXRZk3dNQxZZ7eAJZf/x/hH4Cv97l3+pMVxo4P6HqSGMxHjllilywssMM\nEiX+Cilq04AdfZCfeuu07oDY4wxSpwNfJA2L7EcfVIt2QRQ/++y+9OXYeVha\ndRIwXCCzkpqr+XW8oLBtFA+vZQUZE1Dc7d9esRNbpu+JHYMenVcu9sGb6Gay\nQ/JiBHnswSpgoqNcd1Q+F/wOos61rar/DRma9o2LexbplKLFJc8X4xvlUH+x\nqYvJVMuGuYX57ai8ZYQmV9iMXgM+7BSPQzvP7GMLsF2UOPQzPdJCFNgPoK9S\npS7/ED1fwLTj1Uop9WvFu6jA2UnKFagz/gJMujbfRx3L5duHPXuJEaNjBWVl\neZI2eSYgIllXA0tF1PYpM5511klLu+a3Nq70pVybV720JHec+PJ+PcrD5pQo\nKyQQ1oWLk9JA0jwnqnD8M0gHL7CaxmA8pvvMxC5BKdNr4ObGKbr51HeKhcVy\n3z3IVM0mi+UiF2w64i7kiDt4o2iqtae1yEMUORe6NgeplIJTwK+OnSM9zyu9\nINgnzNgPjW320QSFHnPwEmtF+LE5BuAe0Iwk2sDaV3ESW39MqKdPM50c1ww4\nFjmK\r\n=f8BR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d3d0b7dca83d3e633d97099074934a30d8c335eb","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.1.0","tslib":"^2.0.0","eslint":"^7.3.1","rollup":"^2.18.1","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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-620da2b-1593636940777_1593636999320_0.007446322318736431","host":"s3://npm-registry-packages"}},"2.0.0-canary-36f73c9-1593664103503":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-36f73c9-1593664103503","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-36f73c9-1593664103503","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"583824cc6b26386322febb0fb8c34eb2a8cdeeee","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-36f73c9-1593664103503.tgz","fileCount":26,"integrity":"sha512-DlDUAxB5xquU8124nQ5716eFrA5DojiYimbSkeu04fO+gtIPlqhPxlerxYGju80p0r0mIt3/k58vHK6UdllZUg==","signatures":[{"sig":"MEUCIQCDvc29IRYQW0rsojnQJdZ6WiWBQwj1gwVa2Wmx9EGh7wIgCZDiPvF16KJELsLjMyJtwKzdQGQz0g9j4TEqtkOIjww=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/WK9CRA9TVsSAnZWagAAPigP/3rxUssUI4NagTn/YhL0\nzvwovn/HswgndVhep6tQrWExJMGjwXIyBfpq42XVzXI4iUhd0Ku9VE6JrNeQ\nymqTduHl1zHM6OLHWXYmDUiLKk720LbFMEwa3ywWqj1Kn4REgdabfAh252WB\nOVbBmdbPhqwodRvSkoRf1NHNOGpuXctI6ablfOb77/8OGfXWfgOEy7jhf19L\nT+LFW30liXaGLB3cT0EYt6rujv0KyQH8bb6VM8g/+WIRZswWbm+cWZL45aDE\nmJ5uCv63kArY9HOVPitkBfvuigEUt/pjNjdncl166GwpeNWtjM/MRhvnuM2X\nLsROI8fj1VsCOOONcwoksSW+c3nfJOc/Y3c8tDukP8+NoGejPV6hI9CUcyti\nc9uWLzMzyb+ySVrBFfqrV2fDi65tK8/9HWFk7DpNVj0iZZjgYsn+opx2dUzY\nBXfkqpqbhY+OlGuGRJocSumjyHWUKPDp/Kb8ZFVkE8riuhcjPWTM+AkxGluJ\nXeKKemPVB1BD+1i0E11505FtAoGR4trP1jZTzMyknKueFWSkb9C/PuMzhwN4\n8FdNH616kOlzyobQyWt0or91RPrkI9ovdAUVQ10o/ZYUtWrRweW6e/DM79Rv\n2zYr9bOjFqacwTzUvGM2Y1KUobuIt60ziDM+NcnnPKJsMeHdrUyq+F7Js6Hu\n6VOB\r\n=3/Ze\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"04c565823c75370a1302653fd04ae02f1ee805e7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-36f73c9-1593664103503_1593664189343_0.4740674576868422","host":"s3://npm-registry-packages"}},"2.0.0-canary-6b549fc-1593808118630":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-6b549fc-1593808118630","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-6b549fc-1593808118630","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"21252ff336faf35ebd575f08e6ffca2f0c7b4fac","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-6b549fc-1593808118630.tgz","fileCount":26,"integrity":"sha512-2tbbIZwgbRsIhcqEWw7Y7dub9Z3kE/F4khcAlmilIb2IuNr9Rj+U5mmBKpMoyXsE4BZ4UwVm6cbcZVcoH3hsAA==","signatures":[{"sig":"MEUCIFBsknYpIUrrwgDire8Dr6eeRcYqEV/bgtvplnRIPTDbAiEA+asYcLajZcf4cDSIU8ACTYyfkweKDID8DEAjiydmr0c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/5VCCRA9TVsSAnZWagAAB6EP/A7bCnwJyY1jDRmdjUYZ\n0sDndXyMRQLvI9kL8b/K65iTulM3IFm2GtFE9Ei3zSfGq/iwCXzLDAFwazGu\nkN0eywrW5uy7A8M+PGeSRlu184i3oJUx2+lzss3LWKeeWkA16hP6glAc9JNb\nHyHQgrA+GE1e0+7G7Y/6SS/Dfzc4N2FJATHYgkUTdouqloNEWund7YluHqQ3\nGjmaWNYhx29ugn9WzmD7nNMbft7fFxPi6WugaePEb4llC8BADYB29nB40VgL\nc91VXUEGcn/WCd9fHtCM22bLnZiOcETP4ren5DgxYDZ0wP1jbRK7EJungWwx\nW0jaby9kT5eBPDZez2RPFy9/lIzA3BKc+KDeyLsX9r3F23L6SrdCgqR0Nd5T\n7N4cDlX1Yc01Bh1wXZBFRA5N6TXXUlU4RRObGZCsxDozuX9IuLYbZKzxXZb7\noItyo6lf0NRXLl6+NRz2ro0weCEHn98J9AMQ3ZFQH3xfIMELfEz4OTHxQujA\n8H9sNBNjeoBQSfnW6Z/QGC/EciAaItYhNy4WyiWiN1ETttqDNQLIXXWWkxHk\nTfgs31yziWwTt2+jN9GWw+GO2nzQPvZAblHla1SiuvbXfRzyvywUTk1K4c0g\nGwhtk6gxoyx0rboHIkh5R6CiW3QKRq2xWuMT6K3skL7IC38LOv0yFqjjNkLP\nBbrf\r\n=ZHVN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"49a5b14d87780fbfe4cf649ab635d20ff84b62aa","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-6b549fc-1593808118630_1593808194384_0.9227328016179739","host":"s3://npm-registry-packages"}},"2.0.0-canary-b44228d-1593927745558":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-b44228d-1593927745558","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-b44228d-1593927745558","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1ce0e2c7754d12b198ef642be6499f3f0ac34421","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-b44228d-1593927745558.tgz","fileCount":26,"integrity":"sha512-YYWE8nBcpsq6kSgUaNEvmuPoqo3Za3jmasmF5OmKgU5B2iHyBNLTq69+aWG9Dj+hTudzxZJ1KEZPmEPh6y0pmw==","signatures":[{"sig":"MEQCIAHDKjyG/ACSWt+vY5Mq5F0AtY3UKeHzgUfILSDkyB5fAiBY6o0lTmVqp4VeVIW4fva6E6cUZ6VPKyR4gW+QoPtPAQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAWiACRA9TVsSAnZWagAAcr8P/i1ZL3CiuTeX4+hXU51w\nstrE+gxHx+13UCQbrmJGwR6rxp+o5O/6LYLzz/Q6YA37v1H/mK4a8JLySiN7\nquhAcGvr72R1hok3zmp6Wff+wufS/7sSyS8dPfThGP2ZfcQJ7p42AX9i9yAW\nEA4b09nweK+ieGs6dY9SJVlz1Di8Kj/mWm+EDRqPpVOMuqZnajixQz74jW2P\nAiaE+Q1KkhDOS9s1wNso1rOIalR8KX8aRx0SGFYEmHcGugk3aXaYATPOPY4P\nsTNXwsfHQicNnj99cG6Hk/WTV3npSccEZ0EGQCGwalo28X6Y1RTlEP42bZFs\nZ3QJtrgyYzK79LjURufQI6DnAUZF1RTe7NWGea5WjFrbZvn6hNznB+Amr6hQ\n9LXcOoixicnCbx+etpKOegO0XT0OyzrM0xv/mMf232picevOyy5DYiag4u7b\ndtU6ckf0NKgyag+/8WikG5neZgZpOfFvzJFL6UBBhMXiIV6Sfw++mq0pATW2\nfKMDldGMpS/a9lfn9qrPwrv1AS/E0u9WDLlsYmCEAYSh4Lo/IYrNfJSoNdwd\nqEwsQXqZhIji3hlnInEZafNTCmtObSUfi1XUgrA1mP+e4A05rbBKW984roLy\np68UXN0o+wUOqDjJ5UL1FDMrp11e1WdfVebJyxXjIuicSVV9YwXznMNjqBw9\nTwd+\r\n=MLqt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"60c62bdc587557c96d418ada2a4c44b21395c9a9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-b44228d-1593927745558_1593927807665_0.4425089335651675","host":"s3://npm-registry-packages"}},"2.0.0-canary-b793f98-1594019130179":{"name":"@iadvize-oss/foldable-helpers","version":"2.0.0-canary-b793f98-1594019130179","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.0.0-canary-b793f98-1594019130179","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3790b16ed6b3e922ad13bbf83a3de3568e15c8ac","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.0.0-canary-b793f98-1594019130179.tgz","fileCount":26,"integrity":"sha512-mXHaD/QwoMlUgGsDaCQIj7ushhM1lgEHGxJmLnGn0Vtsp8siCq6VXtJSUmT185p06qjIRG1JosegY92suIEmbw==","signatures":[{"sig":"MEQCIEaR1R0OPEvJf5js0E/ti2DT7Qg41d3tXiTkOPrr9RklAiAzItzu05QbIqqvNl7XkJOLj0EFMjSsAc/J1pLcwZ1HNg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17082,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAs13CRA9TVsSAnZWagAAy/UP/AqZ9DKK7HxrwWV++RC6\nIdHNP1KCBwmrfMZQyAKiwWsDFlTsRq/YYXK5ThjZ5pVdQbXNPOyFKUq6XhDs\nwCnAbObibvkHgyzo+yMgy2HCJL3I+IlpjiqIaKQc17dsjfP9t1vklfbugxJe\npg4QPLGQOi/+UiPiyEReHIouiBWWBTzG4QSDdf9jD5TsQ0EKR3jLO7KgOusX\nBfLHeWWm+u4Ye6k2qX3szJ+6wRM6QocJOkT4W/3L5fDCxSm2KIrYKAuGTTKa\njRl3iXt2DBMvnL1Jbuw08yv9u5ZoqxF/9Pm8Fs+2A/meVV7GKwCImbhS1x6C\njG+OtT5znlKG4CNkq6KofItXmg6udXiiZn3adBDU+8HsW8x4fFqhITW0ZzB2\nVbUeLmEJc/DtwS9NPwYjG82PF8ecggMpApps1hfrZqn0j41gVZc38A2AxjvQ\nWWjKbY63mOe9rX8XoY0npnNJBzyGGxx8gU9c58XNLhpCkCCGnS+sKOJl6n79\nsZmPO1kuxDgtevDKJm2TYbT9McPjopA/VyEW2Sn0MhH9r4Bn9x2ca/lGSfv9\nzA1upBWk3JCz7F8UXr5nNgoSLdLjR1iuk0XENSpjcQDwWt4KmAm/YuWDKvBH\nCZSB2NRjBxSOH9nZKua9U6imi9r6ttrj+HTPk4VFtwuGDbK3+v9AJ4NnLfhR\nXIQc\r\n=YfDx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"54f407d7510248d8e8cd8a97f3bb3143bbf26e8f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.0.0-canary-b793f98-1594019130179_1594019191125_0.3851424066199516","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c455c7594b1b7a49a945a6e4416d876107e4dc3d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0.tgz","fileCount":26,"integrity":"sha512-tRWkkyKyb/le40iegJnrIDa9qhOcqGVN9sdawJVaZfnYqrCZqGz/SwMKzAvKD47nwV3VnSK5WIE7AP232DMeBg==","signatures":[{"sig":"MEUCIQClObnadtIuILHOnMUahyef1hfD4GqdM9wX1mHdGnKN0QIgF47fpdb2p7QAepzf5piv7oVFPjtkSgn8uJjqA1AhHg0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17151,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAyAYCRA9TVsSAnZWagAA29AP/2OmTsaXdEr5RVEFa+EU\n952/ArXC9rOPxLcLP4tpwlmtdVQQ2f1bNbq0Gs6svz8Q+t9hGwbAFtMctzkB\nmnirI5r+55Its/tWtl5Ox4n9V4gcDJyS/YFGPeiD2dP9wMHg6VKZaobo+OQd\nJItdqaBRHwSrPKL02LmZAbs3xomLxJ8OTMk6ZnZt72Z1rl8hoaBfKAqHOj8P\nVLuAZ+j3DMf0zG2MKQMNitcQy/WAnNcN8U6s1whVZER6+g0gSBQWsqrN7h9s\n95f3XostmYZxuKcu1XSlQKbJtT9YXAll3A+3Iyx6AUEOW41ccPiFMLKWK2XW\nU4mpKp++js3XZEimofQAb9CN9FvT4fUsxWAQi++p+pOLr453OUMzdFPtAsQL\nRSWxrdSDg6qwbt30O5ENVXl+bSjU7D0UW3B8WI6H+yKLcoZ7kYimaTdawFQX\niSd6DjHNOtdFcnGWcpS/4xu3oNmP3Ua1JIDwEBsLUhr1GxYnJnnUKG/3XpBU\nurk4F3/xhOVMKabywRMv/lujUJVxcTPW2aY+B7JDjyO2TGlUAmMfS8dxZasR\nlncQ7qOPMS0tfMyA89+fzuhuysb2th3PCX2oDweT1BHaCUVJak6d1cm/nKi/\n9bEbQnZZgwfNEu6Ufa9eN+msOoobvw6OMBOon4WK3uZo5sKi4F9s7nB8Wx6C\n5LWU\r\n=3t2X\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"d53cf01de2df7d63211a6bfe79f7f571ec66310b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_hasShrinkwrap":false,"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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0_1594040343775_0.31472183851014024","host":"s3://npm-registry-packages"}},"2.1.0-canary-c882586-1594080079649":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-c882586-1594080079649","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-c882586-1594080079649","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"af8b2e6ac034c247ab625995210dd6fb390319b0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-c882586-1594080079649.tgz","fileCount":26,"integrity":"sha512-KSorzGgHIBw8kbr6cb9qYOyllyPKGSnlDbCulDqRl5p+gnfgyacYB23mPmG0+bviSomXdkdnkm7K/XDAy9yuYQ==","signatures":[{"sig":"MEUCIH05Z+qFj6XjVi7irVlyI/9Kl0k2dkRu57FzZPcv4oHUAiEAm8aLhtvhrmeokoZ4mk7MmGoYFwQRzJvw1iamSbCV988=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17180,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA7uRCRA9TVsSAnZWagAAVAQP/iOgIay1s8hvlD+8MPYl\nX5CER+GxcEa240nf4USeicxcbX4ms19byVbO62laeEun80E6WR4Ct03b9vfx\nPmIfCnEtOKooGCWL63xFIf4/591zVvOzeVETIGM6sjfeco4d3KeSzlD823PL\nFFDuYzrId941sNpGx0Q2vklkY+TFaOjeORpx4rhOGPCVfaz+zOUYly+/Lhxw\nrDW6Ms+EI8NDcu13F0s7wfhPxtI7yeTOG3ybOS7miGNyXCqpGpgFKAsZL+Hm\nWTrbxrqdIcbeON+SvxVqXbjSds3jby72CKxlqSjlBO0TUKNm9e4z2eUpKBcV\noAuG2ueK3xZcpNZZ5zlpan6S7IOcCiOV2lcHvitVTtIOMDz4VpSX0gtJXSya\nRFoUwDKJLVKWheRDrWf+LszsjS10Pcd+h/gav3I1dRPhPpc9Cz8yRM5K+Tsi\n8kZe2FZFBLBaJY4ElLDZsDcPgNUflpitLSARyc3m9uYTaMuxZDR1LruGxK+B\nkY6aqlJPhpbE21KKHzyUozLNM17ibNR1B5X1UB3qWGzhQugCACMNmS50PUNV\nJGyim37jcMsMyL4u3HW7IZt3swE8ka5miXjXZMacS13RuOjGq+bRXnpIna2C\nPfWhhSdPNtr0bC9BU5Qg5qKz3Es85uAXIF1opMhE3xTyUQJkJPgkjyJjprNd\nlIQ6\r\n=2GAv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4fd942fe9b1b09756e2eb7125090422cfdf33a11","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-c882586-1594080079649_1594080145312_0.9221222461623726","host":"s3://npm-registry-packages"}},"2.1.0-canary-b9ec059-1594084903067":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-b9ec059-1594084903067","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-b9ec059-1594084903067","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"45b7cd0ec8ec600c05a7e3b13d64041f0070f744","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-b9ec059-1594084903067.tgz","fileCount":26,"integrity":"sha512-4ZYC0au81rHt+HvpN79vyLeoNqMp3AYCnBMQFRitGaveShp1NgWiqRAdZBUTpa8chP7+kRAs8msfFqQ6tSfECQ==","signatures":[{"sig":"MEYCIQCleNb9oJaMeuwhvQc3/0fTfQnGjMHEIyJCmjhpB4T2xQIhAJjLxidS9/Uckwp+2e+sz0iweg+uoBXb/XzMAWgQQ79V","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17180,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA85qCRA9TVsSAnZWagAA1AkP/2suyPbq8wEy4AyMTGLw\nm7wiQPGs9lcwL03lkVA4J+Ukgn1EVLyERLCCDboqZBdct8AmWvpEvMuQKsbR\ncXm2ffGovXekeiDFoEK9SFwVOx9hq8i1nDuM6AnQsXOeWs8rRztuhRtrh+AA\nJT1EWhnP5tTicYsLIJZs2dswYc1u9GFkA3lQkzFctmVcK9BBnGY2RJlr9ekw\n0T+7VBzFDQB43ps+W4j0rUDBaEqynN9+HuoE1MLYsE2SfR++dC9txzWRfJ4K\nrIS5SbBge0X+/SjnYaacM62+JKdbixg1gyq9HgREcqP5g85+I19IdOmLQRNA\n/mCIMxj8vUTYXxkX8KIyiONEd57HJif5HZbFAI3gubO1CkrYbK22ii2gflfO\niyT+w4FxscYD0TIuJQxeR0pkWiwMJHq+z/XUWoe75tK+gCq0UL/S+y7h1jRG\ntHC2wJWW5OrS9bIiGd+cWdrkKPcom7NN+Q9OXqaUhqzsBByzt/hr8kFORjLc\nywDysN+ylFDHeN+4bUy0u1ujTXt0Adh00pjCNl6cfWr3XbTn68pU/QK41N2w\nQYkNO6+jihmtepGcpolnmmBZNzxvDLzSj6jAL4xXEkmsXbCrCdN56zJOpCAR\nj12T0R+8LwBqVwRX/2Hy2D14+LbZByUEcQlnboL6FUdaSJtm2XgDu+SyS4F/\ngEwD\r\n=EKct\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7cd516a1f4cb5cc8cc2f0a320784b301a55d25cd","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-b9ec059-1594084903067_1594084969613_0.18183433141708583","host":"s3://npm-registry-packages"}},"2.1.0-canary-27f1211-1594159848912":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-27f1211-1594159848912","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-27f1211-1594159848912","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6f83145f050680f8ce29352042fc48a0f091c7d1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-27f1211-1594159848912.tgz","fileCount":26,"integrity":"sha512-veqiVNycmY6L8FXp1XkDvHERbM12NSGwXylmH6SvGX/XL4ryoYc9sdNyxpdd1Xyqkwj36jy0ZcI1a5DIUbukfg==","signatures":[{"sig":"MEUCIQDO+Kcg0ETHskVl0ybFpsSwHOnPMZNgk2PZWCahhKGoqAIgCeddF8Fa8FwTbdS1gnG8FDQPTjvw4a+DVJ6rD0d3Xlw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBPMpCRA9TVsSAnZWagAAMhEP/A5BKl1ALmlQJACmspDi\nw6G0pwgVLBfOQwc/DeGBPe5skyjIa6eOGZmVksd9mKcNB4DKHIONcvNt2EEb\n6MsxRX58k/9UqqC0m2u/05OiTIPxi0mq+kEFIdnfCmnnFzVoORox/tSbNiXF\n7A4L7fuxtxZYScmHdnEzFVHXO5/t9XbA5aDahTuiaguWipS6/xxQGvow1WRw\n44LnlyZybNeiMYnX4Qygg04sgVsv04+rZgwek9QID7/cd8wge0EAy8YVUQil\nG1EnAVrAZma6hf1Mg4br63LbemwVjJYBorJS0Rrfwf2LPtNWK+guOwAdBIPH\n0cZml4ZEreJ1oxXhuig6sgQBH20z+H5CssaW0u6kdJ6HHBuLoRi/Vy7iJ1gX\nugSY46uh87mK9CaRAP1WUcmde1td50KffQwJ+Drj0lcl30DeMYvZKcrqZ9wK\nM6FZEv3/qNpLAewB4JxmuPGVhfokOxI0AayuC/fszsA3LZz8nRgei0qOuN9a\n9aVShj/7rJ8fip3yXrBoiRjwNtRCTj867x0evFCVbEiPt60gX05u73hevGuG\nRYOJrIRP2uuqQdISvi5Qr+BxXwqvl4SqDwH+Ex+HQqNBQDUXsainzZ53JEAV\nVAQfEoYHhPo3OxsUK6yilguCFOatSCK6yaFQwbseNemntVqHgmcug0YHUbAu\nFJtd\r\n=a/Zh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f08922867a738a434317c20f5181824b39694c64","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-27f1211-1594159848912_1594159912647_0.7894726057033985","host":"s3://npm-registry-packages"}},"2.1.0-canary-560d47f-1594165432995":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-560d47f-1594165432995","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-560d47f-1594165432995","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a1640d0c0c89f06ef7696d10fd459f39f5a207d7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-560d47f-1594165432995.tgz","fileCount":26,"integrity":"sha512-1kSBmyBtJDdIjJ5CDnTH4H3yus7OrN9GlbtNEdibU6PajGg8o9ruotf+cZnpGAs8OD8ZXjLk3jyZNsRwF/9ccA==","signatures":[{"sig":"MEUCIC0FzsGaprMvVzTY9c5HImf2Xsiens9CV7w55rCnScX9AiEAvZvq3HehuWqclT9YKC1qmfVgBY2TwZHChkMBzHLQerE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17180,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBQjrCRA9TVsSAnZWagAAzmgP/1gAJXg8swWiOA3ZTZrp\nS6D8ljdUG60yaZBPFpIW4FuvXAVOSRWTf/M26gc7BTcCUXIMYmlD1O8b5xMD\n1+b+NAd/HUxgux97FvO33gkVWMSHoCAoVrxXIFM0rrh8pJNWfpsxRbaXRRQK\nEuZ11gnxvFx0hKil5GDT5Qvcrkj50xmqhe0OQ7bp3xzdICRK9DcIGirqWYD2\nfl3erBUxGvSxbyjl0mLneqEuxLLXNxZ/6IfHmhCTXeY5cs84d+mh/7uAxFx5\n/vBSNbpbJn/l4MDvOcVO3ia75v4G4A+4sKhU47GAVoaslusey/GqEVZJ+0bm\nhI9zZnGMWYWAuY6RXLXCZDTAX7JUIQYOcTUn4A2984lv2yIkg97942IQ5zp8\nhCBT5ae1CEUutu67KuR8aNisKnId6UeIVmtj39IQ3PVPVj/Eax+4pWWyEwEh\nvfTSeqS9gc2o70iBmvfe810uVOdPIVqR7c2EJ1yN1jR+AbKKU8xGyFqNjmm5\nR5Mg9pGo32IyYFtvvVdecYcSjQeDk4D0cSlXEUc7mRHczhkeoQRGmoBHK45k\nchKBDlWy8FZug4Ry8RajMAxa/6U4HyLmoFHw8+ofFR3NlG7DOyGRrQNCuokl\nkgLvtKes0gHECGAAPN5V5uZ5JNmNaoOAMhe7oCm9tVPhM3CYaJh7pJzMDanb\nxPsu\r\n=uMOz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"345af353fe23e84f67367897ec519315a2667e98","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.6.7"},"_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.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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-560d47f-1594165432995_1594165483302_0.1558318257320095","host":"s3://npm-registry-packages"}},"2.1.0-canary-56f9ce0-1594188141427":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-56f9ce0-1594188141427","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-56f9ce0-1594188141427","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dbc6e78bdce7183ade3e11e3e589b0381df35252","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-56f9ce0-1594188141427.tgz","fileCount":26,"integrity":"sha512-+X7oidWCtLtOk5GX2XUWrDCC29ad6CUxdpIpreko4pIWybphLWuL9y8fvLfxnfOPaOQuXaaMNwwSrfd7pAVRuw==","signatures":[{"sig":"MEUCIQCbjiTUje6I6oelZ8Pu8GcjJCJCjQ2c+pQEUVcikJiLaQIge025FbsmHQrNEurlN8IuYhUGv50d7AOkBjcpR1vXj0c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBWGoCRA9TVsSAnZWagAAhXwP/iDGcaq+3MkBH//l6M45\n6ygVc40ukm/+xKLDRYt/oKLTEZJf+87jjwy3FwRO1z4/ajs/dYMoMm1rXCau\nJH30zRtk4wKOPUCXJEDb9u/1+XpZ8S/6sVF2ZwTT9I4mpsfYmtNGtyTJ8+D+\n3WsRYlomHgovv8K/SY7EgPXKpIPrF1MqYhxEMMfpswINVa/7fFR6eWPsHxgu\nS/dBwHQX9dkz7C5QVOFpppeEzebZsgXc1Jb6kFbk6OQyqQHPCt0VgHEwScdH\nHmNQFFiImcvOiztTBL0+9dcATgPRrenOS7IU/ZrKJpgbBRWZdom6LYLMcXKg\nZTXwAhBkPZPMaDY0esA2P1S5QC+hQjs+KFeFs7CYFIGgIzDF7TlyPpNiPw7j\nIrZ9LGy71PgzMeMP0Hm++ZwfaJeMSbU4GelO0XKTkkJPtbolCJEwG+daY714\nm4xyIx0Z8ijRw2m2y8Ai0o43xy16TIzJyQEyCkJpIbSs2d87O1HWLOQm0lRA\n7JobHk2F/P0gdGpiuAVrGPYZY4mJqX8XRHruU0arhRq1F3oBLXwloPq3IpxO\ntFfPcYdfN6JMZEESYVQyD36KeukDCNINTIcagC4bqe42vNDpHuuuTMn3lQlG\nE8jDarEzNUObjqQgECanF+JmVKtAfH53Lj9fT2h9a6ePaQQQJjUD+IbXMFjf\nmw6D\r\n=Ha40\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0f4802257bdcdcbbcb11962e945e3405e6ed226b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-56f9ce0-1594188141427_1594188199912_0.936919700506532","host":"s3://npm-registry-packages"}},"2.1.0-canary-9fd73eb-1594587716004":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-9fd73eb-1594587716004","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-9fd73eb-1594587716004","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ad1c84e2749f70c07fd811ab0f01a386314ad5d4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-9fd73eb-1594587716004.tgz","fileCount":26,"integrity":"sha512-ijSDIISoOmQl8Eew5ndXTrQKU1W1z5BTG2aCFHC6tkNVsc4nvQUe7IqPWYFZ/AmJPq+uM4TjMGzMrV2urnCVYA==","signatures":[{"sig":"MEUCIARAB3n0ounNOVWufhZeSWS+oG9c5H5WSXVq9QUDps8rAiEA0/SfL1eMtOXVSrv0MAgQ3hG+qV6dXgoTY6MtZYWzzbI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC3qKCRA9TVsSAnZWagAAqKAP/jp4H1F9jf2dmhKTJD67\nmLATmJ41cgVOgaTXdunO8Hf9B0o9BipWyseVYrWlT5KOA2Jvlyzbj37DE/3Y\nC7+lVRr3MTddTb5of4wKhMqV+Z2/NJbTF73Lw6eX7gTMd9te/GWjG9Q4rKdU\nuGlQvzGulKglkF02f4+v0SXbdynenNjqHJZ7l6hgRQSsW+GaomA6kn1Pnmfl\n6/QejYzsyXQx3NCUvzAw25HQFj+YYPHE4qkugQ1C1HeaDJSewdxCP76k3Wmx\nEHLnxf0564BkngH/f9USA6VwThLoMl2RFnKykC5RNrdfB0mcKXFV9OCGta0F\nl71T1FVdLi4RD9Mlsog4yNfE7GxzUWaxp1yXD1mAA7WsqctfYU4yBkyl3rXs\nBwyNl/y3F9kTZ80/MWzPe4RRxuq+ERM1p5aTfxfONF9daDU3JQNqTJp8cXCp\nOz2x+YDDXUX/ARVPaNnTx1mXDnS50EFiTZVbwUumfhgI3PPU3gKRYIIwyZKR\nCu70uRj8wnDBg5K4tSM4ackNIdFwr8rPabdOe+SlBdvGOvoI8Q8DkeH4/JPJ\nE+qrVQRazT1HTEBVMdT0eWYoeftkO/38JNTMtbVhMroao4tUHmTrbuE5wsk0\nqv7b/udxGGa1DuEeGb4WGvbvf8YHeGwD21hK/6/Rd8khgKhE0v7Q7S1Yg7xp\nnJvU\r\n=uuHR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3234463b26a910b91a701b4bfacd394c48972ff7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-9fd73eb-1594587716004_1594587785466_0.6542111222416991","host":"s3://npm-registry-packages"}},"2.1.0-canary-e1a94e6-1594587866926":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-e1a94e6-1594587866926","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-e1a94e6-1594587866926","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7a9770be238056487ef29ba056f85f5f77f0c63a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-e1a94e6-1594587866926.tgz","fileCount":26,"integrity":"sha512-C7Ffm4Yvbpx0GDuA6tu7PzkSOPf6rlpsuwNql0hgFUXNB877YeXBPMx3DyxfVcy40zstQj5jcV4OqmYvh8+6fQ==","signatures":[{"sig":"MEYCIQCSym/oj8REkg6N1rDdOZm2DJrohntJn2E7wDdbt6xEuAIhAJ3bbHS0drgr7fR5jO9MkJ9K1/BjzKiqTk1gg3SKzRC3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC3scCRA9TVsSAnZWagAAYWUP/Rq+o+53jl4qlX2slEbh\nglbG0u+V+8BVCbn+APU5dIddVaZFIZ0cYGQxnrOEdbUAZiQLlxPWng/MIUwC\nYtRgTXiFW1KANhF5iw6qrBjkBkmQv8UHWikmWNtW6L3OQh0lbLszmpS9CPB0\nNq1NBNCRcwDqTN9LDkbyAXtYJoiZ0ZTsCMz2jtIxwn6uo4mua7QTYPnz4A/f\nVyqA0NmzmqbgvVKQzI2aZtK3vR3SbkXSSg2QEc5lwR+13mZCPlwJMWD3z7tN\n5F7l19Q/rX2S9sR6yoOmTKFIDnxAsfxBPrzJm+zOiZeECYWcrERHmSIGYiNs\nits1FnI/p5Z9RcAlq24xzFzxJ7AqwrQ0mL6Dyg6a7WX+0GzwqPYtxPUCyEBZ\nqgrn+448hkq5emQ6BtsxetIieluNXzjaMcsY1vpNIz8oi7ISqAFgtgwT4PFt\n8k+eezdCEvEVGTDuzqyJaEUmoculvvrE7pDH8D5ETTFtuaIrRGTJnH6ZSv5b\nUJnA3eGOrLgjOGOFXDRT4rVvkbnTb03pjX/gaByB9yRdW7arM50dUjhR3Pmj\nRbGYWItSzon790SUHHADJHp9nWZvKjQERob3uZeUsyO15uve4XALcjGfIDCM\nfM1AwyR4i91i/Bbmd1gWd+FCar+NXLK23EoTJZT6aPLMhLh3XFddafKEv5ld\ny8HH\r\n=XzQk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"381f00812e708f7fd8d1357aa2dd1f551e1444ce","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.1.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-e1a94e6-1594587866926_1594587932473_0.9311671631197393","host":"s3://npm-registry-packages"}},"2.1.0-canary-35d3d2a-1594594042023":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-35d3d2a-1594594042023","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-35d3d2a-1594594042023","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6c377df602f513205ed5dd2dc8897bfead04aacb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-35d3d2a-1594594042023.tgz","fileCount":26,"integrity":"sha512-UyqvctE14Bilb48geHz8tN1Jleh8mVetjwhmPgsXb96yO8eQcIoov96YYwVD2QewOb9BMwYtcDHJpYtQQVKjoA==","signatures":[{"sig":"MEYCIQD0bfZhEBy4tf+8RGzpshzQi+tcRN+5Y4D5lUH4MxQiRAIhANNOlElVZFo04fZPHQWPpH8FqHDEZot4ZvbXEOcZQi/8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfC5NPCRA9TVsSAnZWagAA22MP/3QIBfpQ6MuNNC5tqlup\nLnVDaVgqihhMXznexzfp+3h7ib/Vr9vkaxe1fDE6A/pJvQH4bzj4pqgYvd5X\nqrMnoii+ZK5fhpbfvV1oM5ItbE4nmxscUZC/BmatFIPo4F00XFRPV3Ced4VK\nTkyibyJE/kAUblwpwZYpKZoUb//UGOBbiYW4rqRJOSS/jmdVsbPCamtQlBlX\ndkg4eDWr7VLsN90T4OnDQwc3R1EMeKV52AmGj5IKX2Rsdfq9r2xBu1ACyV55\n39SKb7UAVBrSX+R3WOQc9QMnlpYQSoTFx8scDHxTN0OSyAEJEt9y58OhbLAr\nYr+LYhS2aLjB9urnf6uQ7svyf5QxA2T14v3yZqHDIhuo4On87Ljz+ok5XeX9\nJ4mrRaBySl/5xfbXXwt+lJrIMG3dsNeVxIAKoejuD62rGS6LxuOepPei+IqZ\n5X3mOxhCAJEZ7Y4/G3Plw/1ehX8shsiqg1dDwE/Gvr8Wgi6bdL2SHwAlcSTk\nh+FOsDpfwyRtRgJB8DnRVycGYWlw7v/E5ERgaa43XRg4qAp2JpadfwQyxEIP\n3JRjKOfZ75/aRW1LhW6U6ZBN76p6R11ddu5pKuSLp/g4eHT0hvMdni6DollA\nDjA0a8Dlqn4OuWCJg5R6R17ju9uHksnUlrUjAtyB+KGLYAws4Hls8CQto2Vm\nAyQz\r\n=KiRi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"772ec7b485cf1a7db3db3a37203caca30f89fd0c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-35d3d2a-1594594042023_1594594126473_0.855535114632751","host":"s3://npm-registry-packages"}},"2.1.0-canary-240087c-1594664264571":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-240087c-1594664264571","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-240087c-1594664264571","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a7424d1ef47534fb5e376bd0cb138e3da56e7506","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-240087c-1594664264571.tgz","fileCount":26,"integrity":"sha512-eawLRnmYTeqXqgMMI3Lnob5uqxkuW5lQpQui/kzeJYtHWIQyIPww25/a4Ct6q1gEUYgud7dE16qC+xgO1G19xw==","signatures":[{"sig":"MEUCIDBq4uU7xAqIvaCwZVttVTCrJbBHAGcin4fjRaszZ3RhAiEA0O12uloZGCo4t1gGZyv1W229ptokvPfAzlP22yMHENA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDKWPCRA9TVsSAnZWagAAAYAP/2NuTpWayQL+YBEm7rh6\ntrg7bwqOoNF7id9rlJB7RmwGw2SPSg+xxcAM8X5Dps37Jx8EZVMe2ohGbmNN\nPg7V1S5uyfIkZamVxKgdW+8AJ6uUj7CNK3cq4i4OLfQjUHQnowGfdhSDPFis\nufty30vtKd/inwQir6nuHscdU4N0lXupnRI6UsxzSq6OBo4utACmX6IlwnDg\nYqrLSGJWEYrg7xhuAdj2pkasMcfawyTzNAGQ0ULXCbmkVUyuDmkSizNik2sr\n4apB7nWg/Bc+oQmxViA6oKpSR91vZoKbzJbcHFkkqReeXeqx+Q6hKBaT3Mba\ncnDo00YSod6CAjMGQlrlobZKLtQ8G9OEzhEZv4F0YXdjbkEc2tUJw6ntuvBC\naYi5PB3moFiDqpOvqc0FJf91QYSgD7EtOYeAff6j/FRvkxR+nC/+d2rf1eNj\n16zFx0eAyduqx5zZF28vpbXTP8PMrcFcvOcracSJxZ/PD0tjUdEU2X1KdkgV\niIxYMXP3n9OH8B6EJbp/l1NhQB/14NoC3Lvrc2c00CMszqJKb7PNzJQxxz6N\nskr+9aCNUyZCx8ELUsCJQUu/VKOMYqlnM+LD4GTnUobZPiOLEuItQ3kd4673\nFhGzP8Nsuk6T+NfCvXIWGkHfryrj9AOfizEY+QlgJvgvOYVF5oN2vXbvJt5O\nHWqI\r\n=c37g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0b1024e03ac9b78d190c10e1ef5a63e8baf21ed5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-240087c-1594664264571_1594664334555_0.6530204763881458","host":"s3://npm-registry-packages"}},"2.1.0-canary-8670835-1594695343831":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-8670835-1594695343831","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-8670835-1594695343831","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5233cf135a73bd972a55ce336f7ff68aff63d397","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-8670835-1594695343831.tgz","fileCount":26,"integrity":"sha512-7D83PKpTMInNmjKMjUmxnsHKsmipyJXu2GMGBPv4DhgOYu9d7faRQZhBID9XOV867zfwp885ShqKNFeovvpwDA==","signatures":[{"sig":"MEUCIAjkSB2G6mOj1dnDSuohcgkKpDBDv8QIM4MmO5/EK4nQAiEArcp+JyyXg+hbtUzDkLgJhqF7WhubH8BR35EmF1vUqZ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDR71CRA9TVsSAnZWagAALFgP/RdLdLysF+mFKuMx2Hqg\na1Ww15d0Y9b15Ndh9TsK5g9n4GGxaQTtWgIhUMnVGGm/Zxeusknlf9OV5psu\nA+UBNhYBkKTzQsMSqo+yfy5S5VfCUq2LrqEbMleIiEvEh9VFMh2YBTho3BPr\nejNGzMuVVI85ODTtphEE+HSYqPaFgxpDK0GvVY4uGodXNjIUF0gNRav9VS+M\nRs4I9idIJc8hdlSZdV1dcXTOExhvFj21xH71DDgkRg7sbwIoBKEK2jqqffxG\n3ZbsKI4M5lGyVdoZ6W73Kgz6754YCREQhR6TEFZddnw0dXkdDtjaEtlYaAYZ\nKKsjxHmf9OAzWhtmc0TISYARgdb/VTh5fMxK/vg1R2PibnkjD0qvesr21qzn\nHZDfdA9WaIlhwMk604989S5WPrhGdq25bDo8Pim8rx8ctS77/qRNJg5Cv8yo\nuXec4YZNuIiM+c6e716h40I4FeaPZzKrMRST7SayQXeL/MLvrm1Rvx5D+Ze0\nhM+gMAUwZlzebIV1IHanJMa2HGJNP0GDTpJTC8ogxkPnkSQEyDNWansCUxHM\ngNueIiCkY/4xdoIapqqCACAhW4gT1W0oMM7NghgBZkkrbZmqpbZZf1RGGVnv\n0zF4pdFmFpt3Y860kc+Tcda5a9kDN+o7bBKGVbrNTyTSYvXOOaW9kohtlshz\nnVd3\r\n=EjVs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"618ed8f46260c0aec3ae77e99bf2446f0c76ea51","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-8670835-1594695343831_1594695413291_0.601827716078901","host":"s3://npm-registry-packages"}},"2.1.0-canary-2019038-1594857573727":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-2019038-1594857573727","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-2019038-1594857573727","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"83b42cf7fcc40f5c76b8c74452b20a8ab99fba16","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-2019038-1594857573727.tgz","fileCount":26,"integrity":"sha512-GukrVMLqICb5pSxGKzb7y3qNSSi2x1yisJvz9MS9PIyFsIn2ev8viaC4s1vTmbWN/QFpv/ArTksaFKYgZtnyIg==","signatures":[{"sig":"MEUCIQClreHOzdj1IarBPb2w49dM2wxnT8sd4a4LHYGz4sltiAIgLeJa7JdxeI21n+XR7jh3a58UoIZc2r+SOG4zpp6T7WI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfD5ioCRA9TVsSAnZWagAARC4QAJS7zWb320aHi8LKAuBI\nzy69kNqjXe6om9fc26zPzU96irHztIepYxUGkuULI0GjnqrAQKA68OBDAm1o\njEuCF0dKWGUXkrd3wScC+SVLdbmddR4eHa0wyNmgSMSUxWGC+MdLYaEQYCSF\ntVOPYfm1y6wrCrzQLglURVvXbcn/PYZPCMLZXruR/5wDaI76yoGmJuJ6D/hX\nc7xLANCkuQ7uxQmeFUaTCX2YvMavdhhKK+Yn1MnQFs5WZdx5gV4AmmIxSbtZ\n+n12lyreVDOkiMWAy0TrYcDn41fjjNclhO0SQ72W8X/eKpXKgs/fpjgameKj\nKGY8pJSZ835GS1Mo1nDXOo9tVStk08UM2QJ1/rrghWD8m5E57QeWCgxETADQ\n7sz84OJTOs62Ms2h9Edo7jNZZOUZIsxbLpHopImUGAEDA3XGErQEXByZyNuP\n9XlkkofQDE1EKvmKE6ZUm42ZKlUN4UEztszwA/PmNi+bxVEce5vrBFjyym5v\nE5WfuyO+YXWkhnh/UtqGRqXZ1Kw1VIyYBaWnR8wkGe/1UqxNTt5IWdG0u1lj\nTBk2qvV8p0gD/grjsuEFqEpNfVCwMgSNREn8UGT00lWJyfy5AmoJMwkgRigu\nDCBhu0UtCmi1ViT4daSmADKSrafwbc1ESMBWy0Z/bnr4+kOwQNs8OM6yWjak\nztCJ\r\n=+4LO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0854f28563b01db4d34cd22075dd0da89a67cfb9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-2019038-1594857573727_1594857639669_0.6979428193926551","host":"s3://npm-registry-packages"}},"2.1.0-canary-6487eeb-1594930649226":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-6487eeb-1594930649226","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-6487eeb-1594930649226","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4a292cb04e6b1f63064767d88ada3c99e1876713","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-6487eeb-1594930649226.tgz","fileCount":26,"integrity":"sha512-dMbOgqnvYdQgrdEDB12CPiLA9QAhaqT+iTZn/3YCVKH6dn/7QF9j7oAz+aCPYQiWDNwrt7HxF4ba5Bic1caZrQ==","signatures":[{"sig":"MEUCIQCBvrp4Gwi5hH/dgQLrcbakFPKUa+Gz0e90nZAmCbGzFwIgJu1ZYudma06pxofIeD/EUPB2x33zwHskFd03wyTrWic=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfELYOCRA9TVsSAnZWagAADLIP/0Y5eKBDQOeEEB9QZBqq\ntpsBwVzLSE//q8DG9FUAwcxL7SZmOs9DAEdjyx5X7LuVQh0COTIhFT8qznNv\nznqa10pW8IL+crmY0BTWFKliUB9I31w7xDUPuxj2fwPaAbNfuu3LZRRvaH4h\n5MLXA99QNJbAhW+Bl9MwT3N2Piabp7Qtht9vPjG+htICkKD8/avVn6PT73HN\nDiqkTBRn0R5nCc4ZyhZs2Hqk1buCadC4Lf0Z7lo+3IQic/UnInsjRHXPNr2V\n46bYzHAMSbJ7EjAX/9LpNjxDH/H33q4jooiCx0GRYiWjoL03V2VGxvWDiX2f\nHRykPO0u/wcx4NehfXTrn/z9+Kcg0RfcrAZdukz/c0vjE306iUFo37YGjF7P\njC+uCTpjtl0SKipCnJ7Wy8JrryFWOFsex1miL2Pd6vvuw8CIrn14iicBRGiU\n6dUhaN5cb8XlnUYG92c3HJVuhdQYLyVdzZJHR7RYic5Wy2GsWch6qk7BWP+E\nXPa0iBrX5k3EUptjQHTn8iObb1Rak1Witf2TC4d9ITtAYvtHepAry6S0+PEL\nBJhvQcCx/hx/KTTFsEK9cs1eQ4XkHcEGzSS9dotXFReChWYMAIKSy8LD6sGA\nEtH/78+sof5a7IoDNQLK0V8gcuQzpNB0O0Try0kWEQ9qxx3yV4Tx6ffmWduv\nqnFQ\r\n=4JWs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0e31563ca1e99f985cbb75edfae1dea32e755b6d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-6487eeb-1594930649226_1594930702293_0.18409708703112093","host":"s3://npm-registry-packages"}},"2.1.0-canary-0b743b1-1594967040060":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-0b743b1-1594967040060","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-0b743b1-1594967040060","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cc93e8d10afb48f526d795d15f5ac4ada46551df","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-0b743b1-1594967040060.tgz","fileCount":26,"integrity":"sha512-KygvuQVBeHxIPZTAptgVJDLmOji/jVbJVZcaFavZ6dF/VT8FPlDeVsD2Sg6HOvL7MMxeoF30t+R6mJOdntI/GA==","signatures":[{"sig":"MEYCIQCkl9wNriqEwaisQN4qjbm5AhIGNiTTZaiwJM2Bu9bcmwIhAOqQODluotsV0+BqQVkxFG2M7zAGVXuC9rHcTuu7SmrY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEUQ4CRA9TVsSAnZWagAAvgYQAJWVv3ZEECT0R3IUhvZK\nLI3ncpYT4o8oPlNmK6UWbfngZJI+Q6s4tCseXusUBy9mC5nibFFMTMVxwdzG\nDS66bHzuSLMcn/e94AajiDbZ1uxemlk1qj4xe9A6AWWKHP5ocX9PG60MxKzz\n+gATa3QmoEwpn+7WKuOCspEWPhEODQhDjBRnMo5eFIOoU/ar1mDUt7AysL6A\ndomiWlNUZs5w6eIZiRy1k+vBHB2m3KnpkLG6+JfNOia3oR0GBIQcCzXaDi12\nqo+3PR905vWwxmhjUdEdrGhsZMlHbRKddrkFmITQkK2YnZBzrMe0uOnzBHTn\nabUucfB3fpoiJvMhht4Lq8AHyMrrJtW3l2K+oIp3f/LLhGzCC/A80LAiTsXp\nPxWk3oZHUrM0kpneGn7e3hF677QbARvi27XAp7m9Up1fDzNZCC62/MdvTSBh\nQa9Nn35Xg0nt0w6Nn6UH8aD+JEBR+y8TlIxzQwpYuyZOQVH2/ft14NaY4wek\nBgAbVkcOpEfZcmHTsEFoBUXEiJTmbKEGjcLZ2hUO52SxaQesuYm7MqEExw31\nIsiFl5VHQTJ2pL9Py1EatQ5AyPQ2BJWgg6xX5XVX/D+EgqnPI07SZNi9L3KS\nKFse2lh/Qd88NrTcegaxEb/ySOywgK9lP5Q1Csb366SoFiaoz3RJ/4/zr9hn\n2ViX\r\n=3I+S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0f063415e61b647c3249a94fff51c59a45d4ca3a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-0b743b1-1594967040060_1594967095840_0.9601445329749656","host":"s3://npm-registry-packages"}},"2.1.0-canary-d66f277-1595047581397":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-d66f277-1595047581397","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-d66f277-1595047581397","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"14ad876751bcd622d15fa4565c88626efdf3a097","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-d66f277-1595047581397.tgz","fileCount":26,"integrity":"sha512-5lcVFeX40pe7dF20gc8LFhotaVREwHaaSMO7GAqQc49nkDAB0kboSu5TO3XyYlfIk3zHkOQP/Xp+DhRJFNcttg==","signatures":[{"sig":"MEUCIDb6OTja2iv2C/MahsoMoPGJsuiA8zExg/2u4+ylZ3HKAiEAuoe8/idvB53oYi4mS+gruzt7PCVHeGkxY31Iusot/6I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEn7fCRA9TVsSAnZWagAAbwUP/3kiBsOai765vNVzGeHq\nFNxfEv5OOvFrYq+JRECQSoN6jIO86kHnu+M2pXd1EYBef/C0NGrO7dlHqrtA\nRepNLSsg7A0xso2WaDv3lFoPxBfxTGDXdatGfHQsoYQ2ulblf+84tsWt3vnx\nDEMKCsweOyrjD+iMzhE8DWKeAcvWrlMFNi0aK9XnOpKvfQFWbpQOGk+h8i8L\n+cKOCBFqp24CKpm6LpavVjVP6Fzmp07SrFVnXJ2gBSoXnfoxWk9/QQ8Hl6tX\n8z7LE94LWC9mdZjqGVtSVD99TrmJAx1QBfqbGPCxeJy2kwEdQsZO06TKoCMC\nmmOQXuGdUp84l7cyiD5aH9a21or7qad3a8hDOe+zlBK34dyK/MBD75WwRz/X\ndignIFD94ri5nCd9/lrtX9LboLocTEiITfoxCEejOIFWWmypqjCuuBdLVUe7\nkasGlgAG3vdQDrLInhVtkxFFpHAIk9KpsWij64ed/S8qNiM5BwcwUoaNXMDv\neCY9ax+uXUJrko7m92kOtbaGEcVqyzM7m6SrdpL9lnLJHrPAxf4IvP+rjNzO\ndhD9Qqyzqz7ZOmp9Mo1mObr4BhJB9EXAWa6pTnJI+ciPdUaLXfceK6JDL+5c\nkkagje5hOz9MpKo2gckGtrUe3As3/UXg6PYSvfCs3VV+1iw6l7LAUe+Gzhrp\nlz+0\r\n=eU2z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4a91f027ee214b70a9bdd9a189fb460116072ee1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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.4","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-d66f277-1595047581397_1595047646721_0.30361332287743203","host":"s3://npm-registry-packages"}},"2.1.0-canary-22939fe-1595088570923":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-22939fe-1595088570923","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-22939fe-1595088570923","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2bc2253edf8cb317305caf8ceeb1a002b9b52a08","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-22939fe-1595088570923.tgz","fileCount":26,"integrity":"sha512-R0TC0fN9Jylm3xXLWgRh5t32EhBlPh4xkDenS3eGeCywarNDDg4c4GraQgOHUHlCM/qnOW/t5y4qC8PVx5X0sg==","signatures":[{"sig":"MEUCIQD5S70EZLfXSlu231L3wq5bSxxab1/rG8VrlBzpA2TqrgIgbqlgZssKvtCyzKGVuMMAF6SeI+SdOz4ZTYrBvorFlvU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEx85CRA9TVsSAnZWagAA0lsP/23g143d5xcrDnSFcVUb\nFlZi7PSlzWEUt4VaNjkPerVMtWrsaoYzhle6tGBM8ra5kkDNUbq827QoP1Xr\n4ATXKzy9Fy4RX4AHSnN3LabmMXA/jnTK+yofaJpGRzEj6cxgdtImcqBTJ1qu\ndscyeBEVtNJTSUUHoAP9PeJMStHla7ldLVLBbgk2+AwXQq8EX99vb4HyhnE4\nHhXm7ID4jSNyjBi2K5zLEQPoWyIMYM+f1Sccol1zBxHp/i9VCwe1wRp+p+Ms\nraVoiN+aPHk0kFXqqG6AfVVEdtMVMg449rOnBGBpM6//KR+YpmFXpaY2ZYZe\nTAII1Ktsz03WxslDtimXDIKZfD+j4fFxGWLGabpjLlHG5xF7uB9YpYYF2ekQ\nOHQrbmJCl5051LJPk/A5e6o43O7acu+cjhyBSjYvdymf+/rHBqBgud52mtKE\nfvFBLHDZTEqHA9n3VjHmKIoeb5/JEzeSBIwBKB269JlLa/U9D+9iiW5rySmK\nNoqad0aP5jEcwp3UWJdffrKjohB6R3PAksORtwh4yvSO/V4bNYnTrn6k9nvI\n2HBtzUd/arW8jdd4eblFNho2CRvsWd3kXJkpTxMx25v8zPz1iqQUqsoALt+p\nb0N+AU+odbUzIozVf3zPyBPmVAsw59ALgHYVlWsrfXBRueAS/9DmaFvak/bU\nk4yk\r\n=G6S9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"efb6fa7cb16ce93375f2a1895558010f3a477a8c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-22939fe-1595088570923_1595088697479_0.1826597680955424","host":"s3://npm-registry-packages"}},"2.1.0-canary-6d7eb7f-1595100999351":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-6d7eb7f-1595100999351","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-6d7eb7f-1595100999351","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b64d14304c8f35fdcf4e22a9b7a65993f07a53e6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-6d7eb7f-1595100999351.tgz","fileCount":26,"integrity":"sha512-3h+A/3/ChU1dSNE5wOAsfJI3G3E8o51jYq547EMKtPn+3PVsx8uwbSjfNamiOuKsWPFJ5i3EgHRriKhH49uKXw==","signatures":[{"sig":"MEUCIAGd0CicOX5sARzUcAPdL+4J5BZvfxLOWxLpbuFD85PfAiEAiIzo4L8KQPTCHg3EG1nsrECR/RF5J9hhKDru8vVYNlU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE099CRA9TVsSAnZWagAAS1cP/0Sh75sPKH0xJ2Kjl5MW\nB2Gv8lwLox0u71rgZ0qDK8E54YKGK6PHrEj+x1k1IdQ46rNmR1xW2CXrlUB3\nuBBJlM7tCwQh9vjQEE3LLGDAbt2NG2us6x3XbxmIYhQWBGCFkYABM2YASpSY\n0HaIp+RiYvvFzpYbdLp0PxmswxLQ0noqKwncpvaIsbL01BOKG9UZJq62QzJ4\noIbX3g+ivVGf/H6BJjZgApzPcU4WwJg4LS+J2ELUQeL2a9kH4/Svw0OiDJHs\n9NaESm9lvUh8X6vAzvgucbApDBHCB62s91ZpqiFgGooqwxZ9GvhUTtAhAVNU\nQVoBRbTncLK5qf1en5py7BRWQE+8TV9xLqpnh/3EPL3cv5lmWXb2HrR/w/8q\nd+HubqJtflWO2ETbT97rSAQAHMK2Zclc3MoQ1KLvg5iA2QDZs0GCZhaCHIYm\nloPXiP41J6FIYcmw8eVksSl0ehwEa7mz0nyHAna2VhCOYGUyZyIOCN3AvJ9h\nObJgKfd3df5/CKXYb5DYKZ+yajv85q8h+wJFrlulgSdCeo0FLM5Z4NoOkyu7\n7LA/jdqyfMxdul10DEzL9AmywzL9DxG7zeoGG8Et1PUmjcLxwxiHXV5d4rDN\n0vTyqi2m1zkTGw7jMH4nLgCSmDp5YbwVu7/yfc1nCm8gljGOaYZDIUnlRia0\n0wP1\r\n=Btsd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1ec3fca94bc3c8da66d534e1c1cfddcd6761c828","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-6d7eb7f-1595100999351_1595101052830_0.7230547152951936","host":"s3://npm-registry-packages"}},"2.1.0-canary-77727d3-1595101738971":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-77727d3-1595101738971","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-77727d3-1595101738971","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0c01f1e720067b47d00052e124b195ddd68b42b9","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-77727d3-1595101738971.tgz","fileCount":26,"integrity":"sha512-j0fQ/KwYgZWyedtjjGchMQUuXPJqvR5SuBE/083wv17Pq0souBucfHmk84a+/mcjcFc3kl3YMSIMUzH08RvhAQ==","signatures":[{"sig":"MEUCIQC321tesgP7lRwS9JP0WzyA4SxEQTi7jEz9015S0n4/EQIgEQCwDijJ68rdUUtV9fsj/LMR4RCYejiS+P8xj8/EGzA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE1JjCRA9TVsSAnZWagAAUHUP/i/lwzReKhS44//usx26\nNdDZpF/SAuw5GDRc8HvYxm845Jja5T4ermK3LvksQl/20Vc269ylitW0q2+e\nMirHNf3XqBoHiWZks3QjYRc2NGEcofv5b2SKCvkSXwWCoDzTFFOA6pe7auLA\nwVxFQ2no/Z4/1UO0RraV9byVMLQbLKU3EcBywo8vL95MHjgAfmpXPY1lVI4T\nYc8hRYx05MfKE+SWCg7N/WxTju1JlXKolzt6B19fjKVatIcXloZwTqxwDLHB\nIbQ3/JPwZ+u1XX4+Wn472SHmcVIUTJNvGDp6qh97Z5BL+roKDG9k3gievJH0\n+bQbI9l0u3wWtbZpj04eLCisio3dEyZgxLzeqccTbs4BOggXvfgTb/WLLIgy\n0x+ayLRbRDh0a4Uk6Kr/UTQJr6tCjVuSQ58V3Lbxo9M3MpNZ2njiULAfFdS5\nyIVCxiZ5YYPsKOCv+YA2bYtQxBVsvRMQ08lUeGZ1OPLTgRwMjzKxFen6Lkte\nd1ZK0ucy5mw867aLb94/gNiLcvqHargzO7/MFKB08ARzFOZDv42l8SM0AseQ\n/dCnDmSVfgXY5/78gJZ5IfBlT/vzcNxMDY8ZYliqyRU1+pUJi0HRoG7tvtrO\ncm7JYDQ1iGbYO5Fq73bXUChdT9sL+jiwwT7eTHP9IGihyonBW84kFvS9ZTcn\nPmiJ\r\n=fmJv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b8eae0d55777f4d2f42ec254a55ce2cbf58cb6b4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-77727d3-1595101738971_1595101794737_0.5120872020570457","host":"s3://npm-registry-packages"}},"2.1.0-canary-d99c2a9-1595398999147":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-d99c2a9-1595398999147","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-d99c2a9-1595398999147","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f7808b746dabed696df2852f9d1bbadd801a1a96","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-d99c2a9-1595398999147.tgz","fileCount":26,"integrity":"sha512-zGVntIAJiG8EdEYbDN/AupxKLuzsa0DDVwTif1osGpiD4r9RfqZbegCybjRFgrbxspW8kCaQ28cdRhY2kCjBFQ==","signatures":[{"sig":"MEQCIBPjQ23QqN7ZhjXIsgqpmYFtwyWNZJDO30xiY/Cxm/x2AiBQKuE6/wd30ewKrMH48AVEz0QIyi7FlR+LsHcIef56dw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfF9uaCRA9TVsSAnZWagAA860P/0IeEQ7oojINF+GH2lIt\np/FaAXqZLSvv97RiAXSMbGNRQBFfx1dJ+P8jySlOTCTPbwyznkvFDw9Txekd\nEvtnKFxjDRLyuwgPC6GsAt7bO21HyrYozXuLemd64qulMxTF80rjTbduU99z\nmQ7eYuTlDAwarDKkDh2NjR68qSIy9grulSkBRqDcxxz56fpwHZwdTxiklCxT\n0S+xkajiyrfqIA3NPkp1U1XYnyly8KxOSW969l1CoweZs0Zza6DKRjX0w5M6\nWI9UtWMXQ6eYbXzN+izkjHjMwYRcuUEyt9jEPE66+Y7mhEdXR0Fr9A6CGKgj\nkujOQIP6FOQsSyXbuciCwt+DzQyDK7Qwb9aABDYhZmSEwhqZNqhn2nRUQSKb\nPk+JgFc6tekMM+4hIZfyyxY5FoTiI53snJWEhOmzQ90Y52uowM3MUHvwRs0W\nirHcttZ/TH6wQhwVwMYV5n2EyFeT+TEdzm5nxafXsfmxIn7xp3NkWONpo5Fj\nm9cpBZ/F1hYg/rVaEVMALgvOblWna3jVzwK6cmwY3OUZajDh0tvPofYu4Ibm\n/+lgoQVVXr/PJlAhiUrO1oNnT9bS0f9W+gRGWMfsvrW7nCd2+ZvShidOiGmU\n9cBqnDyor/YQQOHyhNrHEcmcp0nZQ6mWrE3yJjwMF3QevcETTaaRECnKHiub\nYY6V\r\n=bimw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b2a54ea43e6efb57e16c03dc2106d4e5fbc6a497","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-d99c2a9-1595398999147_1595399066226_0.02894805773087583","host":"s3://npm-registry-packages"}},"2.1.0-canary-d1c76ed-1595444289177":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-d1c76ed-1595444289177","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-d1c76ed-1595444289177","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5392b7aee46a0daf70218c18e0bbea9e89b66696","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-d1c76ed-1595444289177.tgz","fileCount":26,"integrity":"sha512-GYBuYqIMcehJBAAFGRHK4XVCp2rsxRnykqpRMJcp6dNeG7KEn9yeIQeS6N6d06Y3tA0Bvl7H/wRccDRmsH170Q==","signatures":[{"sig":"MEYCIQDf6yUgcS8waO0yKURdEbhJIk1Iq5iZmqwb4JDsYPdJugIhALLDB3tKmrddZ/THZgqacRBoLpXZaEitChNxkwOLvD0W","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGIyPCRA9TVsSAnZWagAAYLUP/0zxJc2dlexVpIx5P4XA\nGC4ABmXvI41iv6aQ+KjnlAZCweB5p4XUyz8/U2oTPBe/mUwHSSLDbrcjxteP\nVJbBsSuNLsqJS4NHtUZ0m8QhpIkAL4C/UHxRLYcx8F+yK0Mb7l6BV8MtdN7R\n/aZDoyMijHYmKrJYF6uEvMlpcr4A678Hy161pGPhDc1BUPWwxG582Oea7vCG\n9GxSFTvH8v+uaEi5VrkWZibjU2FtJuADwZqPEvqo7newxBIvYkGJjDtecDwg\nziXshc3qwOVaVUWMJO8NKl+V+t8TlzTHt2ELzpJVS5Gy6yW/Bd43uX9LFVTk\nfjNeiQQu7H/dV8Y+QI2DB7V04AiFGjopxX2BnUznFaZSqbywuH8aZfi34N3d\nH8+yezPhsBU+mBLhdwG8Cf84p0AndwFBqnte6qFHimlehJmOvoFwRJeD/8rZ\nKqbwqhCjK+Nh+zT+ZidUXBQVr1urqyvJeXDoA0d4xs+vHKdtwDgPeNBJpHHw\nwBi6SnZsiLGSIj7TvcGGHH8rxdI+oiYgCzbDjhaWSX2SaNbXXjIMuOuPmI0d\nfwFj4TNC/Lc2DQRVES5tbluIaU0KnErgBkXVYuLH4YLbsBQecJ0tut8Hu2WV\nmNXDeWkahivFpSaEc01XygZetcNkQXpx9uJu98P7gP0ldPcByPLAvN7Qemio\nX5hF\r\n=B8Zs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"00717c07549abb018aedd440d322b44898c51e11","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-d1c76ed-1595444289177_1595444366986_0.9397189476999235","host":"s3://npm-registry-packages"}},"2.1.0-canary-f5e348e-1595527457942":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-f5e348e-1595527457942","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-f5e348e-1595527457942","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d4330f74164c0d176106cbc3859a333c30dc3d40","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-f5e348e-1595527457942.tgz","fileCount":26,"integrity":"sha512-Ig3CwNJ2ui2KaqUmlNhii7FXiIhfmsQ/QwGbUkYSLrZ44AKNnmGzf4o4mZZdEU5AH6stYQNUsOF31OaaI8PfKg==","signatures":[{"sig":"MEUCIQCNdKMRpMYDxv9COO9guOiw2KQXat1YtWmRj5zMddUW8wIgDG7PQurxECxXCxRVrQ5jwQRZcdRCLwnW0zhVdZqa7XU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGdFoCRA9TVsSAnZWagAAraEP/2T2J+JJhdPWdy+T45bU\n+dFkISdPcf9MUBoztAgjjEa/hb5L/GSdstxFAXdIFasqM1hhxXvs1n3/+G7o\nkoNzDtvcNciUi+oy4UwmPDv++6NGQiRdSB7hgHXs7vf4jppSNdaIOJUNj1tI\nRsKPaalAcN5jQG7ZdHr9nkSwFcn5vqhjhsuMc+Y5p5vjqw2Y5mCGM/GDa11Z\nxrTckmdLc0Jx1iFiWARqxgNV7WyCqIZ83AGEY9DKIW4/hZ5xcRDjo66xvwes\nNOh0zMgND2E3kQ0FAbbXk3CSKzMnWvXzwfwXNlaEAGIrXfvkz97BqoiF/mv2\nVxU4jPHcRSTYOr5A10gGWP77oR5a4Pox8LZgio/txLtmtUwNEWdDzpcbWRAS\ntK6QJ+MwQJ295oXpNrq28/Flvafcs4R2uJaG5m5i4rZgmzDa8LUkFPPql3Cr\nPVGlS7ZCDxURJs7eQSKo4Cc7meJ50i+xChw+pqbbpHobIPTiLmyp1rM+ZBgN\n2D4tFpc3v/ZlyaDASZslmkqeYksdMl+ci1F2G9MdPcFx4Ve+ttO6UEG0IqJI\np0Jk2rDijV53KmpQhk3qiugPcAMa5VwW39f+gF6rf36osctOIAledFDIrkJ3\n24hnrbeeklr1gAHAx7SzgnVueju57rZZMA7ZW0II+31r62I3rPWSzBHwXJC0\ncIvM\r\n=qyUi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4e6cd9156e02ec219e32c891e6398d605316c61b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-f5e348e-1595527457942_1595527527832_0.14428558682952386","host":"s3://npm-registry-packages"}},"2.1.0-canary-aff1b09-1595530783006":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-aff1b09-1595530783006","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-aff1b09-1595530783006","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4986e70ccd6e569a9263bc59c7ea62d6a1e5d785","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-aff1b09-1595530783006.tgz","fileCount":26,"integrity":"sha512-DFiMT8qDGhBUXPJd4C7hIjrOrlC1seUz+I542TL1WfCxN2oVKNfo8b/4vWXohuHLdyxwcpgTwwrnLi2MConP6g==","signatures":[{"sig":"MEQCIC+q+1zxQaP7Gidzecn8tGH2/K+Vjf373s2Ld+JJulwgAiB+ZuFmmWUB92upNIRXK7rvPfNuYYhaYLOd2kVXYfePdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGd53CRA9TVsSAnZWagAABO0P/A04+V95yMxatIa6StsP\nxR3QKNKd66O/kRqzysuHUcsQ6H90w72uan3CLhepRV7UhBcj53deWp1l5tXv\nBKZ2jNQvTuE/RcxWLGBhemzVDmH/8jnRQumqGYbMIrseGXj+dXLJ1YzRPrqF\n7NtekP6shVzS8DZh1neCUASTJ6703wwx2ZE21R8CgfBRJt0oIMCYWde53idY\nPtndAIULgtReixVURz32gAI1RdpdoBIWvbB1PGCqa4zk3fm7Tw0vMOaL5Q+A\nQLBspWHFi/4+QFxM7cbRajnwltNLhywFB+qxyPOAB2b1dipHYpQqGg5KSyXv\nkAn1SkU0UEd7p3tBQg4omMdZ0VWbDXxYx1NHHgUWtoZ8OY9Frc8uatQkh4DO\nD34oaKsSrFN7V2RveLZVOgRtZuvVBZIi6GKi83e1Y+SeR+nDrGu7y1tgG3CQ\nU8NyEIc9Nn/7Y6UQLlSfkdguROdc3sa7HrOYbXVMbOAJIg+v6XdD8Ou5h0ND\nT5hwVpHkXbedQwPVdf4ZrurZvBgHxOIyuGSYIH9SwFX76jZdWW+DwGCuhhpe\nIu0OmaVH2XejMgygz6hAWJtBXeGm0UwklfoI84d/+LsIPFIczW7RymeYhiVc\ntQStsCgbz4YQfSKyURcSjAKfHldh93pt+pSs7Upar5thaXOgB5WY1W/A27GL\nWYjh\r\n=848u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f00b0138b72f56ba0d5b3c1db06b7b5967b967ca","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-aff1b09-1595530783006_1595530870544_0.9785088930513732","host":"s3://npm-registry-packages"}},"2.1.0-canary-4d48c66-1595531037257":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-4d48c66-1595531037257","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-4d48c66-1595531037257","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2e27914d302b224c78a08ae32e67df11f6c44d55","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-4d48c66-1595531037257.tgz","fileCount":26,"integrity":"sha512-BgjM4RmDeaWEzAbAw0uzGZ6GpRqriZDp1s/fem7U00Fu9CYWy3pnxXE7SEDtAvck9ORr5THDjxgSlg5jHqIe8w==","signatures":[{"sig":"MEUCIAVeg0Z2OF8adKAdx6Aw6k+uNHWq3YwSVfAQTj59nbr8AiEApNtHJ9GY6wuQta/8zaM4nH2rhcaQbuaExGfrc7YnEeo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGd9eCRA9TVsSAnZWagAAXN0P/0VNwNXTCvZzLTKGf36C\nG8a0BWh7gvPaLo/GHE03EM6fHMzDEvhX7XlRwaokiD/6txuQUOr6H4uGrUqC\n6s8b5uEyXCPGmI7KCVVDuoZgbE+b49Fz6gl49c3myhMYsOU3KdCCFx8I1Wvr\njO0+hQOnQEQkFjeyj/wFgyeuWaN6JbJwljeCuBJmBgU1riOJHiBJbvTiMiHX\n1wmdIux39KP0kVqPRZeelMx/FURYYnf7uwXh2PAWawc6WBwtbmVMhA2ogHWo\nRyh+j0oUdKW58NT8mSbiD3jdaB3XXhbfy/4P0QPRIPOWUDmq7NW/lK6o6xvJ\n4dFC7UxvnOA8v5nf5pKTdNWdytcsTvm/fgD7N0Jz2tR7tZr3tBCmn9jJAuj3\nFO44dg1l1WEoDDJr+tyq2t9Q6xvaSiWKZ/IbzCW5czM/PQL5Cz/2Ey0f0XHT\nAK2D+VWaSaJo48SWHMAJbMLnxxYwQhhuq6BraO2k0LzVggPFWBiROfUlZNmW\n8sLMC/ufd7t3+TkT/7AxSNhpv74ExRMe0BjDmIriNJ48A8M+NN/7dH+L/Dce\nAkC8OioDCA1h0UreM/4WYQswbzon6GL4z2yMRSvFxZMKkLS//GEk91fg6CFw\nZaegtETigfW1gf56Wr3WsR6IQ15TDOqirQan2xPLsQDrd+IbJBMwar2Hs3/L\nCWS/\r\n=21GU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1345597cb9854668079c4136b7844192a1bad9f8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-4d48c66-1595531037257_1595531101897_0.7007877503370488","host":"s3://npm-registry-packages"}},"2.1.0-canary-2abcaf6-1595533071623":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-2abcaf6-1595533071623","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-2abcaf6-1595533071623","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a5db5e37c1f2cf16624d7bc914e23cd5761b51ff","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-2abcaf6-1595533071623.tgz","fileCount":26,"integrity":"sha512-GNj/g0kQdYb/uXNHnPDBsgnnFyToTIQaDeu7it1hEpOzTFB7rw/mMTtkUFoTD/rqHuRW1+/sYeph2vm2rJJj1g==","signatures":[{"sig":"MEUCIEqRtOweGXGTnrBIJmAv78wFVBbmPRGquA+HPgrXPu/AAiEAvJT8afDRgfT3cWxi9uZ9GozgDL/bv2rk/hdtuyEaGZo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGedICRA9TVsSAnZWagAAu8sP/0vV840n80NLk8nuDiDu\nT6RhGtT4lLNVcdaHQ27zCQc5qBjTCT+hZNd2eLgFAecPWBFlLaz1tWY9NYhb\nmeowQ5fph8aGj43aMtIGrOXjTFKh8xc5En9UmDDUyz6gW4yv6I0PPKO0Y0Bg\nvq/NhV6TXDkeolixB0Ih5oKWq/L46k06sgET4m9igqOH1sEXIb0m+0jq5nGI\nTpcPdWvucI1w6A4LxZsk/oCofp+U0J9XCRLZHMPshkJoE1bFXHna1SsIj3Dn\nA/zPZWNUwY2Vduf6amXwiSl6JaPKh+eHy+qhnm9AEn94rEyXprPVQBWgum1h\nqhT/WABUs0hkPlSFqyJlSEabNRYD1f92HszDNVWF/Mk65GimAG67Cnw9XAv2\nF9WnoCsj2XUipyZBCV0+w3tq8vRb8lJWFkqvplUSm1ICY19UsRmUuVI/6HKI\nvEyNQd3a7zv7RJHTx5sJL1WrR2FBLkQPWguhXD52DqF/HwfijFJpGiC+vTAW\nDXrwJH7PlJkoQZhT3CAKCLA2vZy8Gvzv25WZeWZvlNZBqG2Jh+jbBQ5x1+lZ\nI4rq3P7fshN1pylOAsFUXExmS+9h2XlDJ6MYZnVRE2P1KjghH1HSCVBU19at\nVquBYIqlv/Gxfuj4r1DJ58AjaDy3BfXk264A65xTy7RgJhHYGMUt+cibyihI\ngpx2\r\n=Tdzx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"150c35098f9f0f49da4f66c027530017fb6e5813","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-2abcaf6-1595533071623_1595533127707_0.18689017690799492","host":"s3://npm-registry-packages"}},"2.1.0-canary-ba822a3-1595536631724":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-ba822a3-1595536631724","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-ba822a3-1595536631724","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d431c59c12126e6cd0295bbfc6d24313dc5feac3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-ba822a3-1595536631724.tgz","fileCount":26,"integrity":"sha512-5JPWMD0CZJGRPpKANuPZdjewMx/NdD+KoJhqnKYAep4YDQRhd3i3CCKfdlNutPqx8G1igvOrU1tN2Nq2HRTVOA==","signatures":[{"sig":"MEUCICabep25Oy+UJzdE9iDgIFyO+6uSH0nJJhxcTxrS2R3mAiEAydJhhA8gYY19S9mU4SimdaU2Hdn6jRqa7WbPa1ssMqc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGfUvCRA9TVsSAnZWagAAm4AQAJZqLHPjqN8u1eM8HlJ+\n4BfoNae2RWQdrSUY60xRe7bdHP+4BsSwIoA9iW+eb8HvcLGAcsXxobfbTYTm\n/kxC3ajVwwuHfzbIAfcfcf1WrwbooPEdd71sRJ3xYgnn7q96JeMvv11MV08l\n9TcXCJ/Y9uWD+WWiYKNsiYco10kq9L9pXlL0uKGEJefGFq/iOONgMBfAcKgX\nsDd89XAHe3MVpfa/4k5cj9mftK9ejHOIU+gDbkUOuUyPJZdX3evv++2HupES\nYZXL9/+yEGWmi2oqUHPPCFhhTL3wfHym6mJObeLdMD8UzI8iB88rOPKPSFCT\nhxAmHd6nHsEOp5WOvMBYd9z6CBCj4YQCacGYvMZdATcy4hUhfQ9dZMvA8lw9\nKwMX5trEfeIsNgVTP08f0SiRinpjkfJPw6vzPmiow+LjMXovR+9OTfABGcPT\nkE5aUVh/njnardGVIuwGPMFPxxv26l469A6ejyqhvyj6vkV/bsaPvSxAKLQZ\n76znw4sC12jXScJntgrvQsUIOmnZMdI1a4szEOMAzhBuUQ3j7PhFN6cepR5v\nyL1IUhZ34597/97bOiZRlCckAqR8xrIwBE4K3LiuZ6w0Q9idz8P3zGphQPjx\n48rFBZibMgOv3b5rt6ksBwJ/Hue+zBV1LWbH5/yr6t6yWaEi3jAcXMWGuJHz\nsiIn\r\n=vpwW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3b1421ce712cedd60d38ea2daaade296344771c9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-ba822a3-1595536631724_1595536687272_0.19541515717002356","host":"s3://npm-registry-packages"}},"2.1.0-canary-324f6ed-1595550667660":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-324f6ed-1595550667660","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-324f6ed-1595550667660","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"147e5e887c72f04e5095f8828384b87de3bcaf44","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-324f6ed-1595550667660.tgz","fileCount":26,"integrity":"sha512-J+d38hruM4I1wwEH2JAMbFeNWRNCWop+c0lScZ92CRsUJZm2nOtJ1/3aJdMRiuUw1ShdA1TLbp/OKUG2SW6/oQ==","signatures":[{"sig":"MEUCIQCKbxGmB6Z/BwO+2Qz8gUdq1gdpx6QQFp/4sjsF6+JgtgIgHK15K63IGZsXCSJtNJ0GsJ8bOTMRho75zPc/LcWDnRU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":17106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGiwECRA9TVsSAnZWagAA9O4QAJmyDduJVynfo+qnQT+7\nJaUujndzkMQiTxCphg7wR5SXVyhZaWJ06Ar/DI850SwIe1T6z17+VtD/3IsO\n+e2iEwjKHOO0cqNc5Verc3EJ37RBYSMaaK1E8yC1En9DP3eisKrXltGh013l\nANpHiFoBSniPSWYIzCufTUpiMORCn135vO1Yp8xKyQBM1cUsg4ky0XPqzpv4\nPbMScH8yS4ca4fQyUkvG9oqR+WtFBUSK4wQQdZk7MP4lExod/kqShOA+6f2l\nSLDgWjC+6r2jB/7hPBo9EXMmluocqZ07HK/BlNpiHFOjY25jDMkjn/GI7u+n\nb4S26JfaAKmR1Ttd1r0wTRnPbDTPvi0QPqw8cJ10FiW9MOnzwj9ce0RmPVgx\nKA0E/yfBph0Xc9wJbeUL5ldIWJXEhXW8ZzkR3txp1sL1dsVFIVh/Jnvj9X83\nlQZRw99kbiQn3FgVefCoj3EmnUuX8okqRseayCM0fKt77a2EmHtz04Y7iLh7\nT8egmqA0amRmsYEeNuPZDS6Q7xy0IArn+Ue5lPuV4HXeslgQuLrpeFlN4YMw\nE7gm7E5gTRZjC12f8vRyOyMrnBE4aylDXNFt2tqvmslBXqtmWMLIuwZDHc6i\nb59OlAGQPeeo5Nwh+gSgtODQ3jaEcpYj5SQUHmN4igwZRGcM95qbzyEVhB9m\nM8zG\r\n=evYo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"87455067273d5ab6ff703c69a08b02ea1ec4370a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-324f6ed-1595550667660_1595550723809_0.6862986358995333","host":"s3://npm-registry-packages"}},"2.1.0-canary-919433b-1595576076140":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-919433b-1595576076140","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-919433b-1595576076140","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1070f7340914052284c5f1cf646101fe45fdef32","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-919433b-1595576076140.tgz","fileCount":26,"integrity":"sha512-PK6YDrRAL080ob1ta7RKn1OkUu/RRsOEfbKdAyvOBowxIaPTyY6QKgRWeYre2b3TS758KjzVPGN/EiQHW7lm7Q==","signatures":[{"sig":"MEUCIQDfuAMR32M7xh5mK81q6EP6BD/nbJeDvyw3DcIOg3A2cwIgduwsJt9TW+AlWje+8tWL9FJwLDJ2Glix7E8TCuKfH3U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGo9ICRA9TVsSAnZWagAA+5YP/jw5wH/q2LgTTIQGvkVx\n3oXGHbus6QYPhdWgfp/y0WQ3h0UuEnW8KmbEy+KiFnrhxr06VZ/pZUZgiJYE\niGOkzdsFRT6FHfiRM5iazAVmH1joPBEoQxU8kMTnrFzQbwnfMi653vxeDDRB\nJBhGb6uxoLI5wxxyZsmkIMLV03V9E7WYZOSvc2FLuzZGkxNjNbrhBt9kQ3ct\n/7JDXeh4uAGAqT2KUwu3oaujWi0BPtAEQO5W7Xx3M3JhvaPt3+UpWHJkMrHB\nXTtVnybvjG2Fa+zESOcI0t5uIRM4+q2TmikVgMQg7xdZVdVEbt4HLQTWg9z1\nB+/+pEVYyt4u+NROx68rOW1/uisaLu2A3hY48WxzGX8y6nruF/3Dp6U5opv8\nezEjg7X1uxOlGq2hVM95DouPo4ttn8GFiaFvTu95zMWKO47DcxCsnjBYFoCV\n4k1WKV4nqfoldznCgJAr1C1y+llQ+36p5bBFoVIyUK74TH3mBykMWIDDJBzv\n/P+phMBfuzcZsuDZzIHeAYp1IwrFkrt1zsGhA2R6tm7i7JW7Qwy84SnYYLPC\nC7TWJApwcUjQyUQnfUnnmBKE+t4iNEeJCx+9nc8pcwbQ5VI6g5zzF+ej5T3L\nFFacgIlcVeJOXQy0M7beeivaLc+K/G3+FlbrnHuFAaljeiFnbUle2gtKR0P9\nrfEU\r\n=fu2l\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"66cc1577491b9d793c8bd72a9c5257f9a5c6e8a3","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-919433b-1595576076140_1595576136028_0.7781343555423368","host":"s3://npm-registry-packages"}},"2.1.0-canary-59d6478-1595588889523":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.0-canary-59d6478-1595588889523","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.0-canary-59d6478-1595588889523","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"53f39296fbd783cf91feb6f586371e7546feea98","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.0-canary-59d6478-1595588889523.tgz","fileCount":26,"integrity":"sha512-rsrdZHGk2LEQif9Fcpx3mDJx2iYh0tFaWAfBICUsXWwsseQql/QTWnkHp5bpxqsO1WyAAZInVknH8IzVakDKEA==","signatures":[{"sig":"MEQCIEDZVqPZhynis9SJi2eFWVeEDIvqHRi2XSnyAv+xETjrAiBIPk3One5Zn7ZH9GNowViCqbIgVq+WHgAOjl4jC4tyeA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18171,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGsFTCRA9TVsSAnZWagAAKuoP/jS29TSxa0F4y8ofbbAC\nM5y/1Zq7XGwTePaBtChGeoqoYvS8AvBmcHrQ6v74AE9UnkujVRlEn4CTyRfs\np8GJnDu7PIms5++yKrQW/8Bxf/3NcjvkWCXsFwDMnL1LiIS77vZeLQWVG5cI\n8HlX1RIDNE7rTrZ4kRqcOh5klwuJo7XrVsTDSM3JMXvVmcXVAEYCbyRy7a3p\nHi9B0DR2yosNv7eb+AgtJhFLwdKPHY9yMvbZeD45vEhz8gEvvzq8pmCNUg0v\nji/Ona8XEtUC7PSmGP7+e8D1ypImWRzM9imTBn1V4SnMfdzR+OufvmPncRtc\nDq+d2yV3AWyj8/if9f7OsHuQn3h902yYAQKcdRQLk1QzYssEiY9TKhRSlwVF\nFUlpqGpzv+5i+Jcia3Rel/DdIOIGKLRmJCs0I711gLCqjGlp6J++WrPVURKW\n6TN5sg//Y0oYo8NrKi9AhU5qFquS1S+6ZfR+8MB6i3TLqePDZtpIalK6PUVw\n58mz8ysCnsegvdkvZbnVM9jPnN0RqXjYsCeGrLqpXRUYB8qzovzNQkUDvjDq\nbchQEH5CiD6K/Uo1d/98ID/VPjQF5++vroo+WD5FIgYkLeWXNkKsJUQZCmz1\nIvS6POAjBlZyWYy2Q/q/uVbPBlK0q/YGbla1xp2aDBvkzrPRvblKaaKSE0n+\n4l2v\r\n=P2ls\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9e411b4451da957775346f9764a3206ad847b140","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.0-canary-59d6478-1595588889523_1595588947423_0.051538700749267585","host":"s3://npm-registry-packages"}},"2.1.1":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5d748e734430623e1c67b6d006434abd111f6c70","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.1.tgz","fileCount":26,"integrity":"sha512-KZVPQuld2Ut5edRosqXKWp3x4wJcv/AU9Q8ONOpZsIMrnWo0O7eGK9XjFtEsM7ruyO0nhVZjijIPHHnhRg1VBA==","signatures":[{"sig":"MEUCIQCMziW5M0x8JqtownAMJ45j9zgFeuRWUawOn8NN6vAwSAIgZkN9qCvwT/GT+pS+hkElB3lmXpStpegFLh5lL02Ah9g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18239,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGsIpCRA9TVsSAnZWagAAURkP/i9zKKf+S1JKxA5PUcbY\nQT1d/gk+13LPrnKBMRdOFTSfF252oLtqHIfS/9xvXIq5S01tFCMusYqtfD51\n91CeinTnuZyeV2xxxmu+QQLhRMyS/yTWuhfPywFZnwOnOgL4BxmRwxYv8h3L\nPaov3dPlTV2nEyHdiL9M7aARuBC8zFlnhRg0MlWufyXeUM4e0IdOfi/Y3k1j\n2sx63MMFS2HgEpSSpHeTxoGf2XuBUu2SmFTBQIsLMTg2n/GbJnrVl4wwxb+A\nILktEeCfu+NbSEetf0T4IDXwkyENLwHYYJejNElvjj7udqqPkfhb9g6YOWzb\nEURp5VpVKrvZbMQi3z1Z6MKwUHricPEZhsM+ulqNuHxyo621ypt3FcG/srPB\nQIXoUfMitDWt9S17sny2c9BYE4DKcZRUXAUKki3RD5iBFST/8/l/YydN9U1I\ngUY4bwkpHBdqcssx5YAg67OA3fCggA1GThnQEIPAR8t8S8F+Q3bVBrWNkLOB\nnxEqMAx8Fl2FTLD2Efkb4zUwOGjALKP02QJxqaul/9jAuIPUDHmA4hoUsKFw\nkTIiT516ssYzjGwxD4/9Ph8fQYoh+wK7u5Qgyonr7DpGEvHIiCX3QIXgpTgy\nid3hSqElGAqQtC3vkHvQqJNKHlEJ4m+ky3/xYIusgmM7qrhIEApnjSWdX141\nrw8a\r\n=9zI5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"0a010546584829fbe1e5222151e190d8dc9ac72d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.1_1595589160599_0.013170651158366908","host":"s3://npm-registry-packages"}},"2.1.1-canary-5143c8a-1595589218620":{"name":"@iadvize-oss/foldable-helpers","version":"2.1.1-canary-5143c8a-1595589218620","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.1.1-canary-5143c8a-1595589218620","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d8c09adbc5adf2dd2b4afb6527577d4266b87b7d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.1.1-canary-5143c8a-1595589218620.tgz","fileCount":26,"integrity":"sha512-Jpkenk9Cr8gwnd/7w00M5phj8wO+3JPYqxYUaZyHzBq5zi6qF4JNyQS6ab0NlqK/MBOekdcqfQFVzSzJOE769A==","signatures":[{"sig":"MEYCIQC5SrIXX13nnkEK6dUMbXNoo0I9wh8DiDcyHwRsmmWWHgIhANumU6wbIpTOA0QHn15QQDe/XerpbGlj/EXRk13pdbEq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19015,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGsKhCRA9TVsSAnZWagAANfgP/3QFwWOEG3vsy/rYtWur\n3bgfaftV5smjWtF+gBwufOvUz5BrXJZyvlXXuM9mpEtvjr5nsk20tNhXsD+o\nxEZVah0nmNpoHW27YeVCNiLhXtMx6LKOtwKeHONbmUbiLkEeexBV/ct5TJhY\ncGa2un5JnzSQsUOx0SVFCG75EFQMNbcfvHYyrBJD3v7eFnTscJvhjOZdcnoH\nqHw1Ktpw7egKqGzBjpCuuJlp5MWtEO39p9vMNNzttcX/T3ElZsnwiXNYQ7Vy\n572tW/fLO/O4+q1cpNhlo4HGif7cXGotMjclGSWFKlHgVIzps6U8e7apWSgK\nG8YG5xUEkSdAja63CuarcAAPUqniQybdzXYoXjqPeT2DJF2ry1ZHf8et1pBY\nuoZ20nw7j98LGtocZQIWHuNIhfQdPb7VGbNAS0CM46Bi/E/oiZNOpljHMwmK\nYFOX9cLLBNg3n875sAd7qxsSxyFSsd/HYP9ci4XdXF4esU/Tiqa7ve8o1+4u\ns0K78qgar6KEMRTyS6yITBnt6kr75Np3hcw+bcfyInkCFTB/wJfsXhZxT3Sf\ndn3GiceN/0chyY0xkGQOi8VVkkRdYEm7q5RrQSAm8m1C3cs2a/Z98WQTHSvb\nQmsS0V+UPL/AfS2tWulgu2Aw/Q2Yz/gRXh48QnrSnIyWHUCk1BWpY30ko+so\nJ9gx\r\n=XWFU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e572f9940f5576a637eda36afd2eee5e4f141f85","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.1.1-canary-5143c8a-1595589218620_1595589280909_0.7135838686820184","host":"s3://npm-registry-packages"}},"2.2.0":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"274d583b52ccfa063ab294b826a2709b21fd58ec","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0.tgz","fileCount":26,"integrity":"sha512-byzhb/Yqk4wDEnSa36xKMwx8cNhcF/aadjJrndTqopBIBQxawpTfQu8sRioQ3giYBJYKCWUYMtkdG1aquc9Ssg==","signatures":[{"sig":"MEUCIQCPGUv/OeQiX29RD7W1v5MnRkqclfTLKr/IDpNDilARMwIgBfNM5Fl+tPr3g8iliwiE9v/KrRT+/mryKoAexD2Pmxs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19084,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGsPPCRA9TVsSAnZWagAA8BsP/3T8X0kq9BF13nIsHNj1\nPoCa9ACJonvu6DMH5Wq+FRfmxZ9QzZfpUjzLeLI+4NUTqz01ww7IFxsWH9Fy\n59rEgmOtrZdUqGFcnoUUSMTPCESpCnsiExaWFfM6HFaBhO7RjMJ5AYIr5zz2\nh5ccupGHLMZRQ4FIJX79qbUXGfqaUE/Tc4cEVULvyGPTT0Lw5JUeMBexLWzK\n2dy2TfBWQb2phqc0ZV7EX89J5SoVPiIAXWcOeI0JXOZ8irIyme+X5PrflFdj\n5ZagGa9/cvtLQZuDuyksDkLuNBWAeEQeTFV7baOWQj/ncwP/Z+W0H++MPyPi\nYR9gnkzbY7MOG0ppigm2m3Vs/HHsIkHQpj4+1zfI/1hXJ4JV/k/DZeFcTunx\nsBnj+5lJR1TRsRA4cxgFUsvRJ16PtvufeyDh1yktQNlNSN/hLr6CkMTqqiSt\nb4TkpWcdkHXOY6EeKkhSFCb+/TLbRKKWY5tZFrSFesvT4f2UMUwhz3l5uVCZ\npYDo8UpIic781mkR+6heEVI/GeXzvnLvs2W3AMHWBB9npuzbSPUsqY3ZFUm8\n0ynSqS5pj7HXIm1Dbb554aq5u0o/1lBvoDhetxX0o2BzX8dIrQ5fsEEFpJkJ\nYKMaA0yn7OljG8/D1j8D+S1YEB5RhPlK9kR/81iqba6Rqn+r91zVrzxNlpSu\nBYOb\r\n=o5As\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"159607e696848a109261c8e44b58aedd257984ea","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0_1595589583215_0.9101486085073385","host":"s3://npm-registry-packages"}},"2.2.0-canary-258220b-1595945949511":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-258220b-1595945949511","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-258220b-1595945949511","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d779f5d29b9831daaa98cbe3107f480fafc44f19","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-258220b-1595945949511.tgz","fileCount":26,"integrity":"sha512-WPWRkjc2mIi8Kv+0m3ck6y7l9qp2YYFiVjqkyJ8yObguvhxc4dI6mdMtMbrg12rC8kDmy0kJd18TJBA4PPSDsA==","signatures":[{"sig":"MEQCIE8CI5yjGcPCHdPdPLFYEanaCOp8lzw1BD82XdnI/gsJAiBSvSGf8Xoae7NB659KhrKOV5OjiTeRSxmpuVaOJmy6FQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIDQ+CRA9TVsSAnZWagAA84sQAKNbmd3Z1vDipQPYa+8s\nNSK6isB4T9fVgj2oLYhkNGFj9kamZW6nwGr1Xw73A3tAb+mbc3v7jIwloLly\npfabvKZ7yfNHET6nW3JgbtoSyrgKeFoRhyNJFrVn5tdHD7UqpSu2U/1z08i6\nzxl2KSWC2S1/3+N1g5HaSy9gFDrNjOiGSuZ6690aD6PUDDn/IKqvQ0xssK+G\nNDtys07UVO8ICmmPNFT1F8a+Ge4/+LAY+Z7BhDYGMhi+vMUF4hIFNMOG4w1h\noF13xfp+qyF7A+af21rMD+/ETecYGAQ5hjQJgz0o3gp0/z+PiMH5q4M1Plp3\nVe6WC2qjyeSxnazE6Vo/zhhmUjRPReZCs62s2fhYQmd7gdG0x/M4QuohY5zL\nqpT6RiOpbAjQ/sWSU9pFUz5uxbPc2c0XxwSFJyKuEPZ/KNNPuoZYGFgrEs86\nhn74cLGm/lGsmvwumq9ToPpRYqJ/iVk53xv/Ovhm5u6uLdL3YnCwziwI/+Jd\n0fa08xoRIDnv7uNbyxLGZ8gnVQC9NMMfhECtmJfBfg2vi2sKnZzdAwtw6a4k\n7rorkL2coAbwCqvfs1J6AGPwe7u7Wro00QRAbSonyOKpmd8LG6GvQne+qMwS\na/z+uEIvzhW6nGTCrtMdoaq5z95HCVYlkdzjheI6gzTyr89Zj6cNhzGOv0kK\ndupV\r\n=vBuU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c5fcebb21b0bc5c0b3e380aff5f024154e5249b0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-258220b-1595945949511_1595946045721_0.8308664805559121","host":"s3://npm-registry-packages"}},"2.2.0-canary-dc23fe6-1596141893413":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-dc23fe6-1596141893413","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-dc23fe6-1596141893413","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"decb56a3ef8595daec8b2cd32c7038c13c27b42f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-dc23fe6-1596141893413.tgz","fileCount":26,"integrity":"sha512-VgsPkQMPWBMqYtvMtdPAei4CUrXQuYwuBJ5d4jn9WlrwZtAmn4N9buoTt1jzjrFneUOaoBTSeOx8ku+5WbMRsA==","signatures":[{"sig":"MEQCIDdPfZT6nfcxUX0hnewFzFRsTO/dzueeRJnSBizuwTInAiBAV8it5361PFMo+M4uvwTelZwpQwZTHnCnJtsjxXVxIg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIzGCCRA9TVsSAnZWagAABKMP/1BbVOWtF41f4P1LQkup\nfJec3GsY7Rme20A7vharqmgtena6lKxBjc0sOsYPdlapxhSPBKIkaYIWCoJB\nVQDu0SzlecJdBs0K/y09pH/QaGb0L1SH1aSmCPoBBgKcH6Sfm7CzWF5bQVN4\ntMVyLeG0IN0bKLJczzd+oANmHSEPndSxVqypsQ5eMQgP9Y9ceSprT2jexv4x\nUEMHNCuZ19CnrutewtZGeW2dZrBwb3QXi8qY9upA+aBdxh+6sK6fZUJ9ZAzT\nuInRyGZneJfdO9ztNb0cUzFu6f1G+rOSWkDVo7DsnQQOI4UjJspXDcVA33Bj\nj20v0sndooCRsbLXQedVdpaFnmrCfkKquppGjBpspjP5sWW1UBTR4a/0x3ui\nynVqCv85ksUyCrPFRX76znaAObl7vseOIDk7HUj6gGzsxmlsydySYfjlOHcK\nkYx5Cee8KSzDI5KHb8+C+p3gMB/MwqFBU9/ebCnISk94LEKLZYjiiZPPvQPd\nD8HDZZi0sbJK/BkZxk3w1fiCPuEcn87xth/aHevDljR+ElMDAdjxOBVI2z6i\nf+d54zNQCzvLKWzexKIRImq851Pqbp6trSKJ/R+nVEyb591vjfRs7n0Vk0NM\neZOVMYd8Hd+Npg3eXowokUalBflzGPWY4C21hO5JnCeMr+emljmp4iO/4VuH\nkqiG\r\n=T0mt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"702b3e8a1b93893c76f1722d7c299e9419a9094d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-dc23fe6-1596141893413_1596141953490_0.9883808742433284","host":"s3://npm-registry-packages"}},"2.2.0-canary-5210260-1596173872047":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5210260-1596173872047","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5210260-1596173872047","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7fe7560cc3b80e57f12c8513392447f90d5553f2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5210260-1596173872047.tgz","fileCount":26,"integrity":"sha512-Z22ybbSOKX0DoflYMcWzkekGGkjxHIiXKK1dCGbqkv11SZxlMEep83dBjEgOW4o8+XBWaTVHEt6qprfGbLMsqQ==","signatures":[{"sig":"MEYCIQDsGDsMS/QxHEWUaF7kYHh+xo+0iEzsKJUKJx45qQFdKAIhAJzlX1aL2YmsYzuprftP3QZK53ASz6a0/vFLntCWO4bR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI65qCRA9TVsSAnZWagAAzbQP/360amnnY7NWIrMeXmrZ\n4R0nAqjeBckep7XP2rPRsg+MTGS2j0PYrqzI0zsrBPVv+OCwp4pYJ2B07unh\nNZ375bgDkerb+dTJNkveN+uDYWtlx4JeXd39M+Efnu6RohSSJUcsgdk319hS\n5uSJs88V4T8vsVvB2tvdVHjxkcMHl/fcNC1ltkIrrbBi3nKO2OG4qxftacte\niZIJ7rj15lYzl/ky2O8k2EaPpuHQfuGACBkcv9ssd330wDMdpToSnDD/yrd0\ncltIRNVtXkqP0BLFA3gggoBMa1ejXE0juyvBPFBZNzQIDFnB68+qWNflRqzE\nogpxQLaAOX/Wcuj5zyO1TcTDk1M2mqlibIFayIU+Zq9rr68aO9USF3R9mM22\nKkiWwF7BzqXIg6s8Ggke7QBAOgz/R1IVw31Lr+3ptgJR++I07tJPYw2kFFCg\n3qVQc8urcAKPuh3zv5e9bWoirJ851Jqzftw2RhQyct0OzZ1DFiiZbig/xVGH\nO/hZEg3vt2gsUBZyoGm1+qPlSoMPdixcSy7ubjA7K+gH1rMCzzW3a9TGKjW9\nSbLKe0gdRX3ul7Xr6oW1Do4nKdi8gkY6tU/TdKZJE+qJnyXb3YADLtkPYWq8\nszttQG0Bu6UM7ofkl+HiXTL8jkAm7dBTacW+JdzVzYwnmWiDIss6vYZJRUIu\n0NGb\r\n=akpD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"97e2cc12d9f1787f3ca6275b31fa4a9104bb8c41","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5210260-1596173872047_1596173929873_0.2210658063312938","host":"s3://npm-registry-packages"}},"2.2.0-canary-601bffd-1596249128194":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-601bffd-1596249128194","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-601bffd-1596249128194","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c0274ef812d754e2ea229b98e9b329248adf9e8a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-601bffd-1596249128194.tgz","fileCount":26,"integrity":"sha512-rKR3AWw9NFZ8m99VRz8n6PpEpJod1xynd/yN8Lj7wnCDPXvY0D8ajnluhM5VC4rWdoWQ3PhoCFDB6/8pxQuPnw==","signatures":[{"sig":"MEUCIQCez9/o9ZBuK5t/+cp5m7on17E8tsXeyjvKT1MSsG39mgIgPGXS11ZcozPqKaaViPJtyNNSbNG69MStedhe7+p7nFk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJNR0CRA9TVsSAnZWagAAmDoQAKLe5f+dUtDSU3mcRkDX\nObKe6XzGmyawTpHNCBKTe04wn7s44QteKXBeu4aisVOn6OBV8+CVpNruq/l3\nZ3+cfeRvY9RhxRdDCxqIyJ3SPDq2JSZvlZRNn/4ujhAeEbrUSBGkP3w9XXi4\nJrPack8zI4cJemfYRCjUG3sVnsM64vo3PzjRH9h32OMmqiI34LqbOIIbjwSp\nHjMvEGnJIPJpcO6l6KsoTVuS1m6cFxxgKwOZeeqx7sbR/eCNz/xRW6E/eiSH\ncKlj5Fxu45BjvnanMmCVcwrBisBlwR5C4ebD8lVQiCela/hT/DtJ4cmKBEXz\n/awYWh6WkELGx+TGv6pPadSgtC9m5yQHytIJIzdBW/ktDoCwNR2Orey7tjW9\nm8onunX7SV3aE5Mxjtg4KZV+vSmCkwv9EI5KCcQJHcAVQf6ogCQwtr0KlkV9\nBQQ0yLVPBJgOyDFRShbqsgEyfLGDU5CEF6KVFdAZESQLe4yN21i9bOMR06H8\nk3kUbtkY6hiWmIdo0nenHd/JRT40t25FPT9AFkbRz2dF9zh/Ih3EEhSzzYrR\nqM7gKQrelG4QXPTPoL5b/wIb3YxIGPtm418vax26n2SFAW79VP0w5eEZyHtQ\nSnUu/oH29USURrXNwjsqsKm+XvJUoZvIfxzTsg4AVEK7WxD8YNwBnFkjzZDK\nSCND\r\n=rHtB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aeb47f325e03c270ce1bda4a40d31ebeb6a73d23","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-601bffd-1596249128194_1596249204281_0.13066930275339672","host":"s3://npm-registry-packages"}},"2.2.0-canary-6963d9a-1596280113158":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6963d9a-1596280113158","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6963d9a-1596280113158","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6f580d7c5d8bd5e4f675015bfa7f1852a5b2287c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6963d9a-1596280113158.tgz","fileCount":26,"integrity":"sha512-Hk+xtr6KPXLjYR1ZERMiHS5ZAB3iApCHy3jA3ZvtP8jqH8RjKc/YkQZDacmiFMwZ6v4sGcEqVc0paU35yv95AA==","signatures":[{"sig":"MEYCIQD8xwFkDhYmRLcMifTLIW2fdUVSBBnBiSk9PyKL5GcPfgIhAKPpMHG988vn2fDBSZX/N6XhSYVA+Yi/55HN8zGwpDS3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJU1rCRA9TVsSAnZWagAAcvoP/1hrykjHDUHqOEBdbrJ2\nhiQyAuvqrYG/34gxyFisHGjsZ1q7gc7WvKmkSlioF42ChNxyELadbU5tbFiz\nE15ghj3ESmHQ3o3yQqaRkm8trBfwMMSGtFbiBSd+P1NrAC06Gwczh6bDn46r\n+43XtADo+TRZesRqXiBd/csothJHrIj/NU5Xm3J+prWYI4egRJbFe+fscekj\niyitpHEzKw6gtR6wck5nSUoHECm3pnby1xBXhVdjBuE2RrcVDjjCuER47STb\nwDpJ5wfa32heYyR33gy+UPAoIUbq3+c+E2eIoWAnarKNFC4XDyH4wcPvfL2Q\nktFoQHnStQS8OwQ+paZr4JRvn1SVjzB3Yv5Ro8vain7TQS5l2o4ApQC+/3Je\n8y30ezWbiG9fhUzcfvdwXdeMUMd56MVA/aiwaom42cW5lK6sAcYbtV94TUUJ\nTQjGmqipe2OEHXLpwtChYBMCpO0438iKfItOaHtHEWZmM47XydQwyA8Ydy8y\nvFRbitEzDrOcLtiZPvQQcyqPb7/Ei8gDiWwNpmNrJOjuy7QlPiDTkZC6UwZA\nSr4LOKDSyOI+3O9yjP3og2eG4l6kZ/Cpj6yaucQeP0vEavnAskyrFt+2jARb\nV4i2pqhDQWorYTQZRy9+1UjL5HtVczNhHvrXLGiX+TP2jwiR0FSpvFMDfILV\nan4l\r\n=UQy4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0377cdb2b4ea186bb2523f91fe8e3ab0326e752d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6963d9a-1596280113158_1596280171015_0.064704852775896","host":"s3://npm-registry-packages"}},"2.2.0-canary-5b8e8bf-1596585499618":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5b8e8bf-1596585499618","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5b8e8bf-1596585499618","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"04967315a61b83c80b5ca3e36e6ccb4c000ee1c1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5b8e8bf-1596585499618.tgz","fileCount":26,"integrity":"sha512-6Xf8lwucDLT7tu++1O1/g+zHdzqwikPTZNz3PUJ+3aHi4uV7m5+4Y5BbOaLszl9BIXxMIZTRtuq3bwrs79p0qQ==","signatures":[{"sig":"MEQCIHSE3JWohU/UK1VUuBWx99M8X0TxAQPoHbWilaPE99oFAiBpiR5zYKX6sIC2pUX4ALVuWZVrEaFjOyiRuMq6ge8bDg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfKfZWCRA9TVsSAnZWagAArOoP/3bVG5Ix3w6wXo5GkBpL\n+jEXa/jz9tCWzo85UxEaiSiZteeta2pEFmpv957lJ6mAAmaLCIYQ+gn6YzIe\nUU71BIbrMy+gwy97Ydc4VI1GR7MU+K/S6++vbIQ60CrEJ1FEXWRCMCT4iAlf\nyVnWa9LMdhfyckq7nY7tvHfwNJ9/Iqn+VY6cqlJ4eEsHCKH0fruqrSezLrGd\nMHXQlOE1StKknJoVPv0rkcAt+SKCA4pqw3w+Rt0VP6qHvJ0qwGhv3pxXpD+C\n2tTfqJIypROrJPA60fuVvgZ6baEFTErx+jJkO2OPzrY1RBgpw3eGmBcmK/kY\nO/rAbNThLK7PvtciaJrRvDk1XOa1eAdZJo0Ad5SVKnmwbSKluyEX+no5YU4P\n9ur+qj+q9QLo7Sqe3UCMf85XatNIuOSqnpnGVgUemLIbyAGfhkVXDtjz2Hm6\nLPhci4Ghwb+Nq8yCvDmlRV7wZ3xs/+hQeuNbK4Q2oyh8czMXYEugqP6l0mC6\n8Rqf1R9J8YgVxwoI1L7lHVOdaCflexjjqQ8rCgm2bzNOJu9lpK0JSCFnKyWL\nGWz4KWw5p5kVMq0ysRQZjLwYVbI5IcldHEnZo2uIHkcia/H5xjVSRCpJJuGs\ntH+98S+L027ooWZzVjbiyMTbFN4aaZvndlnyG4Ro1gep94zxfXf9fuHXJuc0\ni/Ta\r\n=ioJw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"004100c662a486252fd67da42506c34531d5f900","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5b8e8bf-1596585499618_1596585557881_0.6506875680677477","host":"s3://npm-registry-packages"}},"2.2.0-canary-3ecab9d-1596674469964":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3ecab9d-1596674469964","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3ecab9d-1596674469964","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"24b33d8be34337e812060a9d7834bbe03b1d5f4f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3ecab9d-1596674469964.tgz","fileCount":26,"integrity":"sha512-jLfl0+d7mrF4ccoXFAPLwhfmlZQViUHB6Iwg76vMGU6FEr9eQnF5gg+7MJx3t9mi5uzapFF1uMkMZkNVkHeZZg==","signatures":[{"sig":"MEYCIQCdS4O6vefVfPxkgXGYg2OquziWS7zoeX9QJelhtDITZAIhAMZlDDNfCfe1Z+eBl7SJJXlAg4+fhbOB0xll1hs9j4Gg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfK1HyCRA9TVsSAnZWagAA/XQP+QE4+wYczsin6CnCCxMB\n+e2IRWoJdVFQfTnK5z37eVR5+84cQa0JKQelV3sV5apA/RYm31bbzkEWOoD5\nd+Wzcd6OOeuXMspY48atkImUp+AXJCxy17ZVqr0TEJ6QEf1WGDbzIQDxeYSE\noD7tRcF1UnRLEz56cbhK3ADBvURrVG/1A+tQZnonltR0UcwWMD/4ae6bduZy\nof4HGxMlpReGFtuK5ceyt7zyLeEu+W+5rzxiL6sVMYhpTkRiilYZ4DYZ9g/r\n1L4OFWt8q2wYe4R++EDMq0m0q6XUnhBACvXirXxYwjHB0mr5a6fhjJ1R2emJ\nKgW+ijE4Ba8viFLlNxNiXDnkAxNQ/pFqQJBphOJpMT6e4ifQrtKSfDSD+Grg\n/Lblrvec2RvG4SoEZFdQjVrFnHH/ntwudQoe7G5jABunPHjZ6beX2Vvfs5zN\nkYrDtkee65nHLmRDy0kA6RPRrUkJrt4k6zxNg6TETS4uCL5s2eyrvmIS1OzZ\nc1PGj8E7GPrjNcNI6bye+CH143wuRKqufMx7bhCiqNxgbcXVtLbko6eVHyHp\npL9jbGRoTOR0hhhNwJk+YChfE7MvHkDGR6cL0oaJKnRiZSYuR/W31e6tlAEa\n8H3boL3weBYN5XKEFBIl9ugCPwSNiihWj+8YKj4cmtTum5e9s1uOdHqyC6A1\nxaSD\r\n=iTAb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"63de4f9e908d75407f976145e7a207dbabe26c0c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3ecab9d-1596674469964_1596674545534_0.10926668784234073","host":"s3://npm-registry-packages"}},"2.2.0-canary-75215d2-1596752032564":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-75215d2-1596752032564","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-75215d2-1596752032564","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"254ea5333bfde1df2cefeccfec188ed0897ad826","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-75215d2-1596752032564.tgz","fileCount":26,"integrity":"sha512-M67zgfAkTAOLx3uTLhnqqFOrdd+hQGzNZaPpXbuUEpgn5yoBIJXbLZdjaeTWcozk7ovATZLxof2DeysaqxUT7w==","signatures":[{"sig":"MEQCIGE8K83p8Uz6WOPyQjkKzlsqopJxPKDj/52SH0oO4LW0AiAqHCtkC3UAAWj/qL1IfKStKK/YXy1yuMGfzIAJJCkeEw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLIDbCRA9TVsSAnZWagAAtA8P/0i9OHmFkyeBYvpHL4Xt\n52HtHi1ehEH59cE4YWLL/q7S5ImPAMM5pbszc5IlGHuhQ2EvMzNux+/pm3K7\nUaWa+ZN2IaqyIhA8KGB8GXBQ+IRDaoRYQRuEelnkH0+kFRLvWgwSPQO6AqNe\n8XUNlxcGc3gCfu5zHLdH5x29zbjvgi29EiBi2a//aON1ucY9QRgEMHKi3CCQ\nvRj2peAM0B/D9bJflJfe/igI9pZ2djlq9tKc9j+eIHzCor6/xFoiViy/Hdgu\n0mNhS4pWaYFPLaMYJHcat9O3mmoE0PwtYJIGHRkcezWi/rKB+DS4fcNlAUFK\njvykHoSODxEm7Djbe0cCkBTWkTH2IiVO5HP3tBaUy9h9hMl1HZNG5xM+3f+g\nHQ6hKBhDXVAB0NuOHAUT9SHLgPQTeeP3ZWs+VMeDleRQsWY7tQgxuaPbflaf\nnJVa2gvCS2ESvz5C5LR9ug9cooT4YDFggaWmPbGyd3t1O+lVepC3yvd9yL42\nJxXupuGs23bQXdqGt7xC4Ncp9gDxs9kdQp6tzXj1Ah9cdpp5PgXynsu7IYd4\nrpSPa86wGL+k8B9eqFBtfTJ/QTazt0nnZpQsqjOk2iM8OwzD8LFKsE6Gppsd\n9iuXUSUVX82nk0BsiutlfLgy3GjxRCybD0KPVegEetDN09ypkk3wZgnBygSZ\n+nfe\r\n=4AhR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"af360fdadc2abae422b4c7def23c52a75aebdff2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-75215d2-1596752032564_1596752091413_0.1051834430520735","host":"s3://npm-registry-packages"}},"2.2.0-canary-31b1130-1596754604496":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-31b1130-1596754604496","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-31b1130-1596754604496","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fd0afc2b48aca8d4eaf825c520c9d0afd426c16b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-31b1130-1596754604496.tgz","fileCount":26,"integrity":"sha512-FjQ58gqBRKuis9sd7FeFLa+u9HbV86EQSR6xf1h/UjH4siuVjXUZTQOJlM7LpQu2kDVRzRJFYmIteFRCLkaAmg==","signatures":[{"sig":"MEYCIQC1UXHosEHQK9OqcKYEaVQS2MAgb/SKlgvKdgRpJSKZ4AIhANM2c7tAJN81tE4n/L3TL7E/g0Ipi3gq6KPPX6uPo7xv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLIrkCRA9TVsSAnZWagAAHq8P/RMib0NC8SxKU3c5xqxF\n9/+7hwHUfZn/0mbZUn1yPkSmVbs9z36QiS2pjEzPUqS0AwQFtvYF4KYzZgqK\n9EEFlS0hE+u4VhmAq9iw59WeiiJ5AyIADYNVDHjv+jl6Pfpt+l2NfDGBEOEb\nBK9nyDZFMbtE6oM5YAOrU7b7QlqcS8c3t7BYExstZ5kbXbRzzBzQ8fF4cfYW\nu9Gg3JRjl98NbrWaPtrVdMeT66W/m28fTXMO1J0VFLCa888ckYpX2SWiyOA7\nMCbknLrIOiV/VIqzH3uWhYamhwRuwTl9jpI53GfiqtuwnlxP4woJi5mdegHC\nS0kJPtBFnySX9c7bPN7gvCxod7e6TEkbbFGG/3JJFyuGqSOjY8pi9Ucp5gUD\ndy/NjjlkZTBgYmQEq26DJmQIhncFSgsi8Dqb1yFCH9eNF6OjHCCWl4XNr0SY\nNNGLYnW/qC1+iB9YePekddHiI5EV9eUsU+id/W9xva6fsBKlWwKVPLCkd55o\ntAktHhO75ThO0quq95+XSG8f2oMDtrabhcoJcTi9WJPJenR4J6hSL/AzeNtQ\nWl4C/zO7hHxpeDx95cQPEBS6VrYhv14cbXFJPnzD6gzum3noBiuWQfdS8gMw\nq9Bxzo5m6vJk4qBIkhcUuNebOsFtmu/53GWOkE5TVUxGkLYUU+IvZNrQZHdw\nWsFJ\r\n=S4xe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"527bb0f4121c117ef52bd57d2569498ec9112002","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-31b1130-1596754604496_1596754659917_0.9949253131443097","host":"s3://npm-registry-packages"}},"2.2.0-canary-d97a3db-1596829192321":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d97a3db-1596829192321","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d97a3db-1596829192321","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"868bb2ae7587c4ffc325578903b876ab5f2d27a8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d97a3db-1596829192321.tgz","fileCount":26,"integrity":"sha512-sbGQJod23lAJlOOzgh2AdIxIwTABOjVWjNiwByA9D8nbSXG3gFcxbm3SbzP8peNhUJ+B/UVQoFZh6Jc4VaBpmg==","signatures":[{"sig":"MEUCIQD3Qa32OfveAdXZUYsleymkS5XWhw5Sv2uZBWab0e54OwIgX95Vgt3S835qTLpSbR/W3cTY9nSyAZTWU9tmhXqlH5o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLa5ICRA9TVsSAnZWagAASEkP/2t4tM8eUm88ZQ3v9T7r\nPUwXHYzDGtbjqM//9/ySX6As45N6R1CeCw1LroNID5dd05eX7+yt4jkKlXvd\ndgHszUe6gO7AVEC8yHdpKY7YDQGaCZc8E+uAf8rhvpz94HBZTJK0d7riS2tK\n7pUh6GflWd/IwKm5ZY3CJVO8QWygz8HSYLTlbsO+NxFEDSHkzVLr8a5i5Z5U\nWdF96XhqEjiYGziVU+ucPuHfaYsxuSmVrDGeeIDMaJpRsOKQGYpkYSWp+b7/\niNIahF76izVljv3QuhIPaYzgROZDu1FRA1mwPPNQY1B52tAOCONzIRmug3Lq\nF+Cqpo3pINt0kztiBh0F59gDKjXCvVV9EsJA2PKyK9IR1dtofNnplIJsMtq7\nR2npQ7t3BBMY2+ZV6jCR0+yLvQZ9e6Xzn7BC6IV25LeMxUpoWV0HsXbPxhFq\nqbdX/yfkzs/+GKWgLP0und1BuZnkV8z21+8joSwQH6Il+AkoWZ8puDFYX+tO\naNDYoqvgEarkXdl3kmIC3qEilAdNx7aS6Q5jcbes4fDEHSklaAG2AvujOonb\nJjGzf9ASVlCzcPK4MtLB+ut5rKZxBKqCAVJbimzulkbZdDYMFkveGTvpGEKY\nXJME+/nxpKipBKrRQYsQp13OETuqGRT7pLdd4hVTE0gvTDROc2R+Qp5ubXUB\npc4z\r\n=+1/9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a27361a88ee7e8572d1d1536c483fa609a4ac499","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d97a3db-1596829192321_1596829255622_0.05648148993120361","host":"s3://npm-registry-packages"}},"2.2.0-canary-ec56f20-1596832343677":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ec56f20-1596832343677","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ec56f20-1596832343677","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f43957a3c5dd90e717784b304ef7abd19ef5ab2c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ec56f20-1596832343677.tgz","fileCount":26,"integrity":"sha512-2ZmVtD/dneSvbfo3at8nKaaVDOiPktUge1OmOdgcbpubXbNsD1MzWQj8CCDxWsAQtLvaa75boR3M63Vnrx6PXQ==","signatures":[{"sig":"MEUCIFC4F6qF+JRMYfiiCcszV5KD2u+SK50OxFaVF6UvbD3XAiEAm8KQMoyvDGJE2IBp1KRFIFeJqAY9l0lVK4aSEPqyI50=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLbqUCRA9TVsSAnZWagAAp0kP+gL9o2Yn+j8HVm9XzkjX\nn3kYnVQ9mSQ78a2Kx0Qjq/10RKKKeLZPWYPehgaZSz71h1lB/FnMqfaI1MSu\nKDHrJLEMoNkG/WGcNlXI+lVc8I2Xswd+l09ZZiDQfeCYOkYNREIDh+ZMo0Mn\n0J5Mc1sGi+CZAU0zx851AEXxV9Ph4Vz5JT8R4GFkIaPgbaDa30va9+ihuwG0\ntPcWzP9SVwCSSHdw+tzDDJNHUH3aV7E8Y41KdxDGi0jEPIu+qin/5UXdZFP0\nTNycLjyhQYggfzjXEWQzLGRN0JZ62Pj95Sn9e9Sa0nEjYUDwNp1eXsVHgV5q\nAS84xgTyX20Vkd47hgETLiEQ0rJzolQvfXITDnM1x/MZSXOlr/AGouPrQ+ws\nnDyo2kLuv5fzoA2bYB38cCVnAW1I5o6OSdiius64H0r5kugrhM/wOl1Rl0G6\nN5jdgpTxutLCD6sXNm5b7rImR/npFdoNhEQ4Q5/y7pvrRRoenSlGL+gdyZ6v\nxcSfDPpEePizCjFXtaoaZHhdQJExfZD9oVel9/ovQRGHWi8QcoPW4B6eyAK6\nfMUT5HmmKaqe2z2GEZRylrEb4ajTuopv85eke9YiwUG2/wa25Qwb+du4tTdV\nKEyJOK+AoJ5vk56z8Uo4C62/xMkcL9EUiboK0HKpwDLOcIajlAZ8GjK9aqA6\nH/Yo\r\n=sN07\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4fc5156473cb83302aca42a95ca2e58d1e22b073","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ec56f20-1596832343677_1596832403575_0.4134822249046215","host":"s3://npm-registry-packages"}},"2.2.0-canary-9a64aa7-1596934254885":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-9a64aa7-1596934254885","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-9a64aa7-1596934254885","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d40b0ed803332c9b97e78dfa5ad170526bba0c01","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-9a64aa7-1596934254885.tgz","fileCount":26,"integrity":"sha512-f2JxjsIriF1dRNR8Q0dZhVqrpfkd2wjtSx+/FTfAnbt1TbO1BraJ1Rf8d9tNC/a0Jp/Ieanlmaz/9oPJzORpfw==","signatures":[{"sig":"MEUCICTwf2Syo5JwYmfiF6wjv5CNVQf1J2Y/OpL74ZGMSTw5AiEA5mmAJda0uOuVdKaJ6GoSblZ8uSUsBr2JO17Zh5j3O90=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL0iyCRA9TVsSAnZWagAAZ38QAI9KQ70SybDCEsfe1okX\nRhLgmm1LfI6LBTEKYnhamV+VVgEEcaOpvLU0Ei+bzLDCf8uODQxcDgjDUZG3\nP0/9t6qqyMAIpPmr5H8GT1JOplQLOAOQL9IY5GGJIyD2KcF7Y6WfQ6ioGy2d\nbWmp9tP5DlGm0wfmNyboKfvifum9WRpmvSqmkWYxVt/VCIxefkHm1u8RwfmE\nyaPdl9MZzT7bgYEoLlVvRCjXhuDgN2GDsmlpZ8+CgqpQSkMLMYcKP6E1uPrh\nxYGTjWNHz8MHhIJGliBNpJV5ppwQv/MzxjrRUe1J7r4llVXnt2Ou5GMuFa+b\ni3jlIUaij/deili6OLGBr7vMQpkPImvp66QYwRZbdOgV4IX2LCXxK+dJ0KtT\n6gkcIE8eO3arhyeHC9lpI6QGkKsoA1H8LLVsKVKkl0tXxsa89CWE2oiVJ1VB\nR04bxNfKlY1FxOEy0ObnsTPcmh899m38kmR1acA7wBtoRDAyrWT0qmH5PaS3\nfT5sEkogTzFlT1CKJpjYHeCUEkEDMoqR0zkylgVkRA0qdrwhTiJCdujY4km/\njroCvjcWuOYkPeneQ7B7+J3nfOwuUaeoyyRy9r01kZdfRQBfs5d11etPI3cW\n99IpeFIPwV5CzrXl9cK3m5O2MrUgE2WG2e5ssQ7gFJ2aKIG900hI3BqGdyaI\n3ZP1\r\n=5/HV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"89c050da5bf3f5956aea2e58eef42610be903740","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-9a64aa7-1596934254885_1596934322379_0.5317927787659056","host":"s3://npm-registry-packages"}},"2.2.0-canary-bf8625d-1596978501083":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-bf8625d-1596978501083","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-bf8625d-1596978501083","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ce34198cd2f747b0c1a819d3da79eb3cefcfbcd3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-bf8625d-1596978501083.tgz","fileCount":26,"integrity":"sha512-TT++SmhgztHgHT2ef8/i7gb7uiLlrk5usiVRCqnluFhx5Rab4mTCL1uNVSPJaxsSRvYzw9G1LM1kCfowGmcuMg==","signatures":[{"sig":"MEUCIQD4Bi0Qbw9xtz768yDY5X+DGlWAM0N39vJ2WkU9OnO/OgIgZ1JOZxEdaa/KCDMADY1g4z2cVd67rOFqROtxsugTpsE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL/WJCRA9TVsSAnZWagAAMrkP/2hgI270+ZjPraBSU0/3\nQQFNO9n9p5Y1YtI8ok4/KTKSkaUtOBpvTo26mSO/nkamL5x4Go9aVLHIdUjq\nVI5hT9p8+IrBvRAtpF9brRZXMX/6vHp8LCj8w/dAOfhaKt53CkR6xWW7FLUb\nbVS0D5CUJxCwgSDYaekujyXPnwe3T5MUx2rCp6YBZxornuFhT5gWvjXHg1eq\n4HcbtbbUy/JH2F+Wp6QEqJJz+0I34BWR1rM3qK+uDAm8cHEIqG2skHRW8v1J\nescjD/EcYQGnd7t9wXIzWVfYb35nBM/SXltfOxihexDSoNjHd94QGcbvgxbd\nDOHUxHui+6o07sYY+MDO63q0rei5tvKduqn3zHkFAEc/ljtDW+46eUtuRGq2\nlGbiAw1c4pN7C+AN6moETtdW92+UHyBiEgLWFtZzmQ7a5ZUhxOrWLMuZgMPp\nRl9i53TLjvxNuhpeE0OXlerb1m5fvTGIYyWA9XxKH7ZKm3lMLWIWhy97tlnd\niB0HMcHu2jQSPpgLomJtaJeU9OxFcIdhQnCbDlDhGO2teKZ8JBfdopHGqtRH\ndz7zfGXfox8IZb2PlCXLNKnPHQ/Jx2WWKyAg804bhOTSSf1WI7Jbl96Tl9yl\nwWLKkqg0UJEmO8k1rs8iJ5ufKPfSXNnlyh5p0JJKTAgWgrjVnCOlDmWxFD48\nIC7E\r\n=Dbru\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"635e48859211485fa4fe11b3e796f7c8e08d2cc8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-bf8625d-1596978501083_1596978568697_0.2053315050624045","host":"s3://npm-registry-packages"}},"2.2.0-canary-65e41eb-1597013508308":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-65e41eb-1597013508308","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-65e41eb-1597013508308","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"607d7dccc3e165effc46a3c790afbba074abeaaf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-65e41eb-1597013508308.tgz","fileCount":26,"integrity":"sha512-eJ3fLaptsSIyxCia4zE9ZAaE2wkX9CV5xZNwh0QjwbFMR7+ixWBKJXtqqTKKeRMiGTtuOiRiLwE5gSIey+QBWA==","signatures":[{"sig":"MEUCIQDIHMTij8JLHs1Hc6emkfgRoH9/l9Y5aSgvhBfIha88UwIgXcm+CbQD5AslInB/CvrLC7wEZgdjGnC8MjDHiGkZXaU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMH5QCRA9TVsSAnZWagAAOjQP/0kBNYT0VLMgW2r0pXk1\nJrTdS3SgoxNdEpe+LfwZ9epMItF7De9Q/klIbtFLiIvAoHr6iNeU7BWtVcqB\nxdq0PmKrVjJBISfm/mGwPcTFGdAUA9mZjTVpi4+xjXv3Umy0mNOJnKEhJ5xv\nei9CiT5pyvYmFR4PD8niK9ZkASM/1jwcVvXJ9zZNS1UXPZpjwsW8ASiEhnu3\n/x2Tu/27LwaBnr7bCm7llf3fbMCkO3yGp7velJDyKvyOUeY624N5ZCPtrtiv\n/+tZ5buT0+NuCaHT8j6p2fyFEksUhrludzgjh/EGVQLYAsiIo9dkmjvc5V5s\nxyyMfG08vIw3BoEAjy0+o5XVVCgl9EK0Tq0V2HKQC675Dz8Bn+plhbxBQKq7\n5S3mwa6vAfZFyvIKJ3thocuXTVYHCC1uBJ2tidy5/lw9w0VwjE5PrDv+5qsL\nSTWWJ11g4B3yDPrLDQEXtuykqYqJpOKfBRU15OILfrQY7qtSQKF37bEVE1ky\nmCE1WbwWKwp9g3Tp7hiLDZ2ZAQLhTyj3Kv0xew9hkzSUQL+//v4bMzNlN66R\nl7smQDKJaK+JsS/eUt6bE7ie6mviL9kmVQK4i7l+32vGIAarbrtNoyreLRb+\nNCkwmtImUH22pNhcwlW+rWGAtjnuI0C10KJFQntBoxjn42JFJdIAMNKLBIi3\nVhyp\r\n=+GTW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"79d63c613fa6b1eda265ccc9bd8fe35a6530f89a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-65e41eb-1597013508308_1597013583596_0.5259655345851308","host":"s3://npm-registry-packages"}},"2.2.0-canary-c3923f7-1597044121851":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c3923f7-1597044121851","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c3923f7-1597044121851","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2ac469b2910f2c860e075841222328969fd26a9b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c3923f7-1597044121851.tgz","fileCount":26,"integrity":"sha512-ptzy1NXUimKakhcng7K0ttAl/fwAmSVLkb2UHda2tHls829cX7LqKZuKynKHmICIoLfVrm6jeppYhp6cGqXNdQ==","signatures":[{"sig":"MEUCIDcrQisE44aFtcUi75+APohmJkQ8pcdMk9pAS3p1NhqZAiEAg0XP0QxCIJNTP4bdu1huvhKireHjCcrhEs3iIG4vDDk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPXYCRA9TVsSAnZWagAASusP/0u3ZNjhod06X3tAr1Qh\nG9KoYpij9TtJ4I89gwIUuKUNIrZ1vgg0G3DHUadpiobAQL0l8tNluNaHQgea\nmFMZK3IPi9UHOvR7EeR9/agavj+LAV7kmxxSobtkN8Gyy5nnZrFA8My6gi9R\n7VRH781N/oa7BAOyBd48x0BsIWV382ECaDtj+yj1qiEhOcUHepDHSxQthUBb\noN8bwUfOj1xh9p8xq2R3LM1o7kyHvdv9STnUfDGKmalo5hykd+QcEZZZ8a4L\nCBi4+nl8ZyYp6PHOOYiKI55zjbSvEiqYgQHzU48HV0i8W909fbrpIYX8NFrH\n8ejwdWTkRY+i9Qs5iNo70MtyyxbKglqlj/hd1oLjGObYHDaI9o35xSoOCo8I\nIlpY33GbCgerwyioFyhKvMLyREJBP1+B9/CDKuEniey1dkN/QC7YDJ3zR+QA\nR1azXSTKT+RsMhwE33K2iTe4Be+byALel1+gJApl807jZOocDp9DUqxC3Al2\nNBQKkmm/ye2Z4zyjBmHU7dVMMz+i02+UwBvqDs0PSaF325SMTbEtwPNg80oP\nvkEbVw5UTXxq30C38SzpiCArKszi8tK5tKWGfKeIwJ9nJ28OkTKANOCVDEiQ\nH0ePCxCIqEP/lBIHYQyYHo7koRyHyu4Y7iXhnWXx0fEOvZz9hu42MKwrjTwf\nxSQt\r\n=s/XS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ca8ff335a78d48f2dcf5691fdc02baae66a81fc7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c3923f7-1597044121851_1597044184160_0.1736641132612129","host":"s3://npm-registry-packages"}},"2.2.0-canary-fc7d0f4-1597044126801":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fc7d0f4-1597044126801","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fc7d0f4-1597044126801","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1b11cfbc9f4803bad52041982da0052544c78736","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fc7d0f4-1597044126801.tgz","fileCount":26,"integrity":"sha512-x6WPXueNgAsqquYe2v9cbnfhBnWCitw+Pmt0fu+5PmtC8nLQs4E2cGFpRKi6sfH+q3WkOnlOOAQ/vNoWAKC59w==","signatures":[{"sig":"MEUCIQD0bR2zt72gBywS7BEU1HyQ5OTYsDN/LJh9o/p0w4l77gIgV7NjnmQ1An/8SGG0l3HMUg61UXcarhMXaYOzS+2YrS0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPXpCRA9TVsSAnZWagAA2+wQAJYxyBrCmsVrLEdF1UDD\nufLnpnucejFQ92bz+VdV75s0Qnc7huWr1er+mLfeOhEJXMSFkb2ZAi0Y+yPe\nle7b0jeatytz/HwxcA7/gQpROBwaJzYmGnfjqI6CcQyFCNU/XdSQbengvfCD\nsf9wmIz56CYq1QeSuX356BFLZxbSSmUvvShg8yNm0Mu7+B7+Gt57bmUTZlFR\nnrII1G9gTRwUD6R6uhB2bIM96lhxHME5b+sN/my4xXWdmx3143ZXm4wLNbTE\nsAUFKtZXCHZSqdr0u3n0+2ulc3I9OQk87OamOWWlGFTkOG/eW9tPSBqJTPY3\nLc8Qw9ReBsROXM2y3utsRSAu9vlHZAyM0pqzhTezvRq+tDZ6yv9rH+oebCpc\nLKisD4aa4OB8sYAvMM0yOEtVOZt7S83YHPPI4Q2PlgJvmZ3JWGC6dyLHvqiy\nuqjc+vZwviANo1tCiQ7t+HZ2RRViAyC/LUeVqq2NRdPeBbVRaZq7UqQ4o+sz\nFfgVGuLljz0MUsBA3Hxw7tunWlI77hcsV3Lk/drZsupTX9e3Bv108Uiu3XmS\nb2noE3pWj6cBSfgBYq1wZ+bfbIRt8m8xvKElUwmtrdb17TmRq3+7h9J5x2fW\nun2ymWcChe+73Glv5X2UjJc59/fAkrpeCclsPnv85VHgH47onG1RpgBRkgBC\nUQ/8\r\n=P+mc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d2757baf1f7728fcfe9c3e5274a83a63af443019","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.7.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fc7d0f4-1597044126801_1597044200629_0.5609871431385871","host":"s3://npm-registry-packages"}},"2.2.0-canary-a209a63-1597044376107":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a209a63-1597044376107","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a209a63-1597044376107","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"926886b368ff9501526bd656127d2924847f7217","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a209a63-1597044376107.tgz","fileCount":26,"integrity":"sha512-zOwVwiXpZaeD6PVLOHrMXYvTbiAmjAgUAYxkm5TCEFOtXbIPY0/9KkenihCgQ7TFbxJEgGIqKjjwZwO4uD4NGQ==","signatures":[{"sig":"MEQCIGDzf6gfgaw/T9jFGlmKWQfqrOKB1j9acawZ/mJhUvZEAiBqgoMgn/RLwCPY8lZCIHlPggIEQFB2qN1ye/VafZxWeA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMPbSCRA9TVsSAnZWagAAcAkP/i8etUEm0+XL6K3Q6DoI\nl4jicPlwsxQJCrDrKtS61l7EoftZClea41cJboTjTq3jQZj/Ce1g/0jwb2gx\nW6hUsIf+KEn1GbtsjnCBR8jqsjCthu/Uknslt7o0olR37GftFE3wHqgKF+Kf\nUUIUatcWUynR5IosBAJGpRNHsMh+n6sttHCIxQyqN+dEjpSNQGaRybkghXwv\nGnS0fhIAZjcVPOxSyrVYiapTcUvWFy7bmUc/z5O9pDlQD6Jzb7cI+iwcHJ0z\n+Qk3pagsMeAM8vhl4C2Bs7ij/75/EoqYu4Slx3cnH5gAuQY7DlJ6TDakhPy+\n/0vwKTNoB5wTTvokeDD4INLoFTIjJNbVUg3/oFwYuCfzWsRZoknhQLZb1Fxw\nOofloZcVtDqrZ+v1wUJg9XmUyTrK0A0CGTrkI3tnh1hVBPcSqeo4910zusy5\ngZxNBZEWAZYM3yKyv9UWXrpOFO2ISSGcNyDseWIo4fKnZ7uJf7XfRQC6watx\nF9GCS24I+tbLvpqMQ8WjhmwwOAGq8ha1eit1yK7nHp5xQuqldI8QCPQbQZ/K\nLrOpQZC66+b5sgZkaf38vmV4GeWRgoub1cOOvXpmJHq5jkBK2y7N3z7PmlwV\n5MO4KboSZsb/kr+tWZru+tiu+qK7lm935XQphgsdRH2NHjU3I2/ulgi4855+\nwF4E\r\n=HTi4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"48b378f475e7e37da9e429c3d0a5a15743e47d4a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a209a63-1597044376107_1597044433867_0.36517715071674606","host":"s3://npm-registry-packages"}},"2.2.0-canary-aa934d8-1597096892040":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-aa934d8-1597096892040","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-aa934d8-1597096892040","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"efec705d431568bc3ba2d0e7944da9b7a5d2bf87","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-aa934d8-1597096892040.tgz","fileCount":26,"integrity":"sha512-IXzSDIFALexZY12yfgSQCO8q6QnWbDLf7KS8KzJuNHFY1WGo9tUCfg5jiny2dNYyHxRBtbfHPNAVlxnZlvrlpw==","signatures":[{"sig":"MEUCIQCS1m69n01Sv8ixVS/hRszRF9bOey41fGFw0jNwtFQt0QIgbxwjmPUkMhGQpLgz1p6XMXnJTcHS/yaRJRzI4sSW/5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMcP1CRA9TVsSAnZWagAAfCEP/RfHqvkeezACQJdLYrF/\nuejVFzWl6U8Syo4yo6xEfAALeHU72Qs+q0iftcLGMtx8ClNKL14FsmJ0OjF9\nER1n7xl4UtndY8Isv7l92pBAHfyCoGDDsY/6nEnu1wLSOQlHqKcNtyzw1tWa\nVUE4gnl4j+EGy5ukgPp3jX8mxlLChxlM8F2gWMexY6/7lVlpN8+0xOV4I1ej\nJTnDPlrJ0ZRSrj1T11/UZ12NASlFCtdflqE2yZrS5TVG72THdSpjUSR4xMVE\nBc47LeBMIL6CSaaYW2B1pQx2OgA12nOqvroVfTKwTEH54lViQ2NeIeTY2cox\nEQczt4ksqSbrpMY9aRxTl6NAGNfKNqNYHuZzq2Gkgo/v/NlCUHO8Y5/3Jwh8\nvAG45larkt+gtJ+vt/TFJJitsovrkkDGDKPs/DfL0DuvA8dY8w/rvd1VkRM6\nOd7ddK9GHKekKPViXwJyPB4JwpTLkGLoonM94Em5lZ1p2cPv/jsczaJm6yOM\n0jBKS853utrLUBYAY8qI0uFGUaUsTXwz6HGyCdw60K36K8YHX4heiIgRZuUD\nvO0fcXaEjyVoRwsAv81cj1xSulNZqRgrusxRg2xG4enmiuFdwdKHEJjohBvq\n2lkKrhE8TSo1PwCzMxALfZnRVYFNMqLuSIXyg4Ewi4p/jrjJ2svtaV1riSdM\ngLwy\r\n=Jzi4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"857e50b553363c6f92199ac3b19b183c8f7beeb1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-aa934d8-1597096892040_1597096949460_0.7157235827653601","host":"s3://npm-registry-packages"}},"2.2.0-canary-e3fe3c7-1597181180954":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e3fe3c7-1597181180954","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e3fe3c7-1597181180954","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ef037b6f7fbb4ae1424346594a411033fb748390","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e3fe3c7-1597181180954.tgz","fileCount":26,"integrity":"sha512-31GBNJypP1IxoH2bbg9DDr8zIj20EHHoog2Q4m7+QucC8gphdmm/RD5OtStyepraqWZumNzx8+6r99ScrCVeKQ==","signatures":[{"sig":"MEQCIE406oYcT4woTvb9umjq3+2FoZMg7T2Y2b51eZZ6hQSSAiA/AjUk76pMxn6ZqARRMCM1Z6hy3KmLXyBgQypSe+U2GA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMw0+CRA9TVsSAnZWagAAIXIP/jrFqqK34wIg0HqB+gX2\niJKp2R8gYDT/Ln7MVNqCuGlHU7P+gHqefBDpntXg42l4mTlvN/faz4JUZlfq\nYRlByFz3xwb4Ov5ACbmm+nH7I6wzQl3nwSYyfet6HGuiLxpMHj+PfGEMZpCe\nMxE+GTCF7ayA1jH+wwqWDqHmudhTpwo7A+zgKwQMmokusgCIRQppB/00LfHO\nu2yI5FTE0y+hTeGYJcPkCTsYPsPEBlx8mA4J7wy3OaNlkqmL01JFSWRE9HQR\nlFi0IbaZ8YG7BEcUhYtVBDJDIHUgwU+NBiHPaXqy0fm05MKh7TlgAW2y8bfu\n8mcHvp5G2f4rKCWkR/FckJnAm/bCkLRJsmmxQ2Xi9fotzFklzbocaX1R8sz9\nl3Q7NSCTVhLS6jWHTntZ1AgWiGkF7Qm/PneDrgHEePhKmGFKf35UI8JcrCk9\nS7S+mjlBWU+V3t9yqct3uRrHeP3Z2d8eMDsYi58Anr5lnLiC9nlF8bft+iog\nfOCA2+7+hsoi6KGo+j/gtmMWMVpKlxcr5Oh9E2GNAghXIOMiyw9axiyZ/rZt\nixeik8R734Wvh22byZRo/p327OcCY5djK8Gobd/W9jJoPYv8h7Zc51WfjOZg\nioQaNjEtUITNucHEy/PFlB3RnG143hMz19DQqacZf1Mrz8yxyUAauv6b8xMP\nS6Uu\r\n=yT+U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"711876ab6b33e25b089599eade531c1c81efa109","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e3fe3c7-1597181180954_1597181246293_0.956655521909443","host":"s3://npm-registry-packages"}},"2.2.0-canary-c88e1c8-1597288407560":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c88e1c8-1597288407560","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c88e1c8-1597288407560","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"be3e56cb92538c14ca266811b85a8d7d5099cbe5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c88e1c8-1597288407560.tgz","fileCount":26,"integrity":"sha512-3cLC8JuAxCTiiMuNevBuS02CNisdqHsQ7rEIM/osD+V8d43I29O4c3yIVFkZMj0qORyx328pcUtF0iVUpGh5bg==","signatures":[{"sig":"MEUCIQDz8BcfmVRzVRP3ZCdpsJiFBC+nglUEmOzAsIEaJtmcEgIgKNPs+0IV64AEx5CCTJvForrxleDuxPWNxVeTQGVcFBc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNLAXCRA9TVsSAnZWagAAwo8P/jbPkB3CkxZu2h57rmE7\nvQsGeG2eI2M9M0ZtmLohMTOctRCvLz2iFCtU8vXe8aSzwo+Rt0vWFSzc/wGa\n9FHUC/vAh9bvGw7MdCn/PSAFda/zvT17ED2K+VO7f91JM3BdLj1Iq62Wohv7\ngpFn+NIARZDRYzdvtkWouUL4DtRMwhHtdoQIkVmcEzjSvO0biCh6DzD4G7XN\n1t6kCl5MjXPxjPyegoY9Si2nBgt09BQ7NupRGz9hbhWRzgFRkbI26UWfKDap\n8/m0nrRcTOjA4KWFfA5J/9f9IYS9C36TagHbJUy3Pe8UtajSDDdIbV6+D5mT\nv2iK6BJ3kBO8NwwS43/zsDcT7eBPbvM9C6zZpd00dhPNEfxKe2Zw3Zqqh1n8\n65hJsYB6OwZnq7hctbAhxm1EVZEjTRcIU7vSwFgqgaem0oZjWiBX2l0ZIKXw\nCKbqqTTlw3zElPHgtun7SAsDUARLfP/b0tTiFLeKUS94rXeWutAunTZSHyrX\n1bVhF4LsYxF9cZard4oyJ0uLyGsr4d/xaJdxzdl/YyNHcidVjfpJKt3fa8i5\nuxvm9Xilp4iBEPkZxRVzd/wjqif41Ez9t1puXS2Z4Q1v5xBx5SfBnj+Plw17\nSIQlPYrZK0E9SKMOlsaLhwmbyc25TAJ2voTUm9G4ihbLQ9bcMV2BST5G/re6\nJZPp\r\n=HJp6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4947bb2e1946fcc1e6e77b6c1b06766e03360495","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c88e1c8-1597288407560_1597288470965_0.17729245395438387","host":"s3://npm-registry-packages"}},"2.2.0-canary-79722ad-1597359216509":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-79722ad-1597359216509","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-79722ad-1597359216509","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3cd35158f2383285aec0bebef62ed0abe8643fbb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-79722ad-1597359216509.tgz","fileCount":26,"integrity":"sha512-BzlbdQLC0kVMeNsZHGhst9n5zBgQooC4P3pHreEzUlc0Iy1fCMl0D7dfo4stwbZa+q/C13hwJPch4J6jSkEkZQ==","signatures":[{"sig":"MEQCIAyc6tEAjZUPAtejbDqGwsc0fXFhMGOjON3p1g43OzPlAiBeNQBv97GW6ca9/6kS7vVlMiaWGifnIfQvih7BpzG4nQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNcSlCRA9TVsSAnZWagAApvkP/jfDoYytzH4BYyZuV8qn\n7VwWEDFA3cWThO231EIwskMCxx1yMn9t/98e7p7W5uZGFU8gZZndyCUgHdDW\n20kzOWK7wxys2wkBRuuldCrxUzjrYYZ2hxXOS00NBbLnw7A6feXd8+mxsrw8\nK/fG17R/MqmOrkmjEalH+VcseBomnSbes3zW2d1wkLw7W1NHQqZhoPaIm/CN\ne9qqoEOKSItaDNaeyz2+VoE8Eq+jStG8LRCUHn6Gq7I+LjIdvyCoYW/ZB5xO\nhKjR//VLw/wG93cJOWKD5tGhHCGet37dBhMLSEDzIiIkX98h2tloW2SftsuF\ntS2M56NsgRGtM3pfcsQT0JuCXSkexESIH+jAPnkAVP5uL+XwYVdxYZtXshEy\nNIR7GI+NnIUIro7ah5STZyxDesIS55u3ylp298+owwHiSnZJGJRNWQTv6Dxz\nwTAh0z2Nz7gV5psJ4Ohlh/qoyDvexK+3O/W6F/RzSbDfVQoB/a+yWbv4nd4Z\nG/0LFopsx7Fz4CsojhDGVBXt9oxiOHShs3ZeTgeoN3OxygWGEHyEjUCPwOtm\nMzY6ll7lMgUCHeETdyBdw/CYP8rbhFHqT3yoPv9fuOQEuWiTJn3b/1XcEwK+\n2wssG31nB9bU0952cAeME+i8Bc6w6/p/zHpG9SLcrYlKnmvNdyl6ATkeLBK6\nRrbc\r\n=euSp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f941f5f0bd083927e5d7de785b49a73bc44e5ead","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-79722ad-1597359216509_1597359269241_0.2909156465861982","host":"s3://npm-registry-packages"}},"2.2.0-canary-0dea971-1597362777750":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0dea971-1597362777750","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0dea971-1597362777750","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ec07043a45798d8f46bc6a582ee268c8636d8e23","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0dea971-1597362777750.tgz","fileCount":26,"integrity":"sha512-NEFKt697+SqYieW8PnpB6RofJ6AGImE/NZcS+Tc9k219ekeHNi7zu3kdRhx0szMj1K/l+T7SxYkH5Rfx2wlNDA==","signatures":[{"sig":"MEUCIQC/Tj6thAa2UAaK4Wone+myksJ17MO9gHVrR8eOQMSqFAIgKclRrt/m8Roys/m9m4E5e08A3ZRqohRLHPBXMg4sTtI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNdKQCRA9TVsSAnZWagAAsjIP/2kNUTTo56Omcuv6MFoN\n7So/iKbFMSB1R9uSKfBDHMfB8NAEfZGEY1Lgxu3W2L8kIeAnjnqOtd5o5WgI\ntDe/4X4sz8KE9HeTeraSAD2F3wjjH+CE/WC1GDm+vxaBecX9yNi2NOHUWsfT\nITS5s5pQs6VHXl3L7uY38ABagGtxDJj3kZvTQsQBrHcqlWZVCfeWgsImuLXs\n/MYcBqa31iq02iUODAm/fnq8R3oora8TwDRt6jwVpgLOB56YeY0otgUeBGql\nHMDprCImlkrdubsQ244X6R7BzfcguBsiqBJXohJVkCmK1WhNrC/YyWJXKB3N\nc1D1SOIEsBW5ImEsHQspzXwuPDBxosUIr2PjMOw8O8PI3jUntf8c4iCYkB78\nUS1h7s7ZpumkkgMHsGKwCABmYsRvkTN+Gja4bSqLM+BmMZ+HEEf3n/4FmLL5\noUSDNR0KxHqTbOcnE2erYraX/siXLK4QGbjGGjh2VaYHETdqqhYYzu7aQhW2\nayaazpmaitNI+iAlh0M20+qxKs1yrSPgKnsCOilRW7Tz0/4yROqJZCfEr+K1\ntMON7Le9K+RVHFSRTixfBsAkvxFtYGZxzy/QXj2kpsll+/BSrzPUQTAsDFlH\nMru126wh9lXg7FMYSMhg06O/NN+VRh3W4EPOEQkW4XIpeG/DCs4uqZ0G44pc\nOi5i\r\n=DzPJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2a6697855f9cbc020d6844e57678edc3c3b3d448","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0dea971-1597362777750_1597362832061_0.38997934134839785","host":"s3://npm-registry-packages"}},"2.2.0-canary-6e8fb4b-1597369511392":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6e8fb4b-1597369511392","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6e8fb4b-1597369511392","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fb49be95d9d9cf937cece2730c2cf8a883fc35ee","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6e8fb4b-1597369511392.tgz","fileCount":26,"integrity":"sha512-i/rwCY5VcR5hZukju7bv2BxW8HAWH2h0eKxvKJ7Bf8dAR4KBINbxUCY9BEQz90wdJ1DCS3WdNx+/CdFS8tHJHg==","signatures":[{"sig":"MEYCIQCiXUU+hzN+8gszXNSnCAHizmwpw1fUKdCHWfLvbziMMwIhAPuLB91VMJfsZcyYB34VxdBA/aWG+1nGASVz27AHfg6l","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNezmCRA9TVsSAnZWagAAsHUP/iXPyZP8g/xFxUYZCNLy\nxhDxkLNXmP8iFYArsxEIG8z8rmqW6Bb8BpDtlDme5u2nWi7uXMV5IcLBYywp\nE6Lpc6A2djZ/Cw5NfatYZDOGnyKbXwmCGm8p2g0+v2uJDZWeChI4filh4tN9\nSZd2N5RqT+BL7kIdjicHkCDBw/3Ap+/kgIGCWRTooYhdCQaq+K/iGVXpWkew\niMPtEyFQ6z37jUe/+0rhbVf5+Vyw3CszuIQMuTm7a5ukhsRxlT1qyMnSG2iW\n2bjHYq4uqGHGh32dNVMjk+k4OGSnbBYXypnl5TxQNwKqK7wSN6gpzw2lFMgy\n5DHXxBYF1w/IN7aAB9hkTZNHABcP3gmTwlD6PPyMyWcpPIXL3QkddpC20+MC\nkxkIJZAQHI4I4r5nNfgqtJ9UIn+eOrV+nF1HaPy9mvSdKVrm2Acy4kQ5xiuk\nDyK8DlJW7jyBJJoxj/t9zJOivNuNNOHegspX9m641ZbzqI1qIl37Kn6Mot1c\nV2frhMCne43gIQ22Dugv6hfCaE3ilVV96wbhiwaqbAwNbSq3lmgRsAwp6twI\nsbBvOLMCIBnNl/p9NoU2UIEFafEgxuiKmmDT1cye4iSAuWux0JoUrUBcxw4R\ne70vnmHTmsECnoIPXqh0Ci6Y65dX7NeCFIqMpMD936Hi7ECVYXVUwssebbNo\nu+J5\r\n=iShQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6e36746b7f8016e8baa5211529193a6dd1d3ed42","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6e8fb4b-1597369511392_1597369574293_0.9243772043823952","host":"s3://npm-registry-packages"}},"2.2.0-canary-80d19e3-1597388961050":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-80d19e3-1597388961050","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-80d19e3-1597388961050","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"aeef738ab15df48b7dfa4257c2573c636b3fe3c5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-80d19e3-1597388961050.tgz","fileCount":26,"integrity":"sha512-Zskx49Ma0pGKlsIlj57tAysbrfZ/vGLv6pIUHxw6js9oCWthfYxvC80tICAHLM5t2hbVzjF2WnjZuY1K1bFg6Q==","signatures":[{"sig":"MEYCIQDj/OhOWKhNtOOfEVgoAqlGPLG1Emuzks7NzvsHaF2c5QIhAJPplgFaywcGRB+7W8j9qjxTmrsE2FIrXxFT2gTgIk99","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNjjiCRA9TVsSAnZWagAAzysQAIyK9YB2dB+q27LDcHRy\nx6fohHWb5ZBmdH5b3acddUwXl2gjINYPcD9IK9O9+QMDYaSTDijpzU6sFUCt\nW19zvRXLyLBdmk0xdZ1qa3igYLdOf2n5D7K6AFvFVxr7SFLhyqIKMNFoV4id\n5ez3mQLAc34YSjZcddRZ4wsiCOHMny/krc/EESMWgJdIRdV3NlAz0QfCVbBu\nCb3qFH/L3reA4agPaGCATeFn45AXiDWvWJ55cqK+6xUyXYW2v0E1WLAr7+RG\nut68q0BR16+xrIVSxf4/AAyO/0finpNYJbwJ5MTmsJGG8AU81HxXjxZzB3EB\nb4HltvmfZ/ceAOS9adruezlISQ/ikMHmtLfMXNiBFLNlNxKPoeRsbmnjHyVU\n3x8krBdcRRt6qD2UcXsrrfjAD8OvAr8rYoEoPcU9Y9fxR4CKD9qEXwKsQfKr\nrZF3N1iZCJi/zll5wzAIJ6t8sDYIawwZhEwSEipV8vYgc+IqVA+RKRpSfE6l\n448zAmG8f/SjqI3WyHmP3YcvM3019b8V3Z4EcItXINP4a78Rvr6hBaPpJlr6\nb0Ev/9tSbk9v3Nu+/4gaiiQmd6ktmgTig9Psld2CV9y+PYGJsCIpPX4ugHgz\nWy2Ujjm+vVAjSUD/K87j+vY1nCx9E1qpnN8MoJLNW8ME6tv8D+uTxDDrDSkr\nRKWf\r\n=uWMN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"64bb57fead4eb28bce9e6c904fc85750576967ea","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^8.4.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-80d19e3-1597388961050_1597389026447_0.8584016184453365","host":"s3://npm-registry-packages"}},"2.2.0-canary-4f93d32-1597388976435":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4f93d32-1597388976435","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4f93d32-1597388976435","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f6ad9f858156047f86787e72b14a3f14c2659f3d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4f93d32-1597388976435.tgz","fileCount":26,"integrity":"sha512-+ZBT2sDH2OmqYhEizDAqtRiy68QaTl4U/fOV8nKuabMfqgETLS810xwdjGot24GnMgpDjPn7KpnCMWBBCOoyJg==","signatures":[{"sig":"MEUCIQCNzdwRaKIPSnwh6prbxKHvR9n2mM0m78QswXdAgwd2ZQIgZmhApU+/kLfUpSiE1sCOs0ypWxh/rIR5ae1GWjGCU4M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNjjnCRA9TVsSAnZWagAAcVgP/09bHVQ5gE2WH6un7ADf\nm+vNz1B0mMQu04rYPPnp3TvAxNhTPy1uN9GPGAur81l3Q27oqhNt+Cyo/c5t\nmEn0Se+7DKM83CnNYmIi93fKT354I0NqKFqcx8uA/i/PJ/aQWkPkbooObwLV\nE7p9n70uTxVed3dsyUbkrDfKvohgbHickQpWyFsMUbrwEfXKuyFUyum7Rgli\nCqe8b2GIzeYhZk8Z0ofy/kWP/J56RyPgYLRTpdMZxx6zCoABY2OATKSC7ZIc\nDqSF6X4RUr+NkyT+LgI6hS1hGbIK5vPETvoFw+Hqk0I7MXxjZRbR1sKbt7s9\ne3KxTN+Ssy54fVaesxRK1SAnYl09zaNxg6wNXiVQX8fZ8RpLi8rs06OLYkBA\nSffd48PwIsgMPCFC7Wcfw+yIqyj+B6iPRmwAq3wE/04Y2SWBZ/IEZdvvreER\nnR3x9Kxtp+M4+KhfrOWmpKFFvF2OdHtJg+JY2UJRRNlH2Oz7f/Qt955+ST2x\nbWbvEtDigL7PtzVmxAAyV6fdtgvmpWaRXfLwRHrkhAI6CmXtHPOmH9mLwy2V\n6AM9nQWCPr/95d7Dn71nQ7afTtBIis9zF5l7gRyIEmtPJG0vouRY9+YYhOPy\nw8qTg7om9tLX2HcrNzUFBoeoPwS0JEwvjvkphub7KEZtRfkoylzKaKqtA24e\nGTVe\r\n=sRf3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"eb5f7011bc3f74b0d1cee16e610b037cc06936ce","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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":"^14.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4f93d32-1597388976435_1597389031062_0.09000603141369923","host":"s3://npm-registry-packages"}},"2.2.0-canary-32d7d9f-1597389206847":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-32d7d9f-1597389206847","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-32d7d9f-1597389206847","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b9ea44391033dd6d34cc6e5b676edd151feba6fa","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-32d7d9f-1597389206847.tgz","fileCount":26,"integrity":"sha512-GbZaNkNVVxNKXjMSTE6pklpaYttHch3oU1TTs8p9Lud1kpIwY+xhGWcTf7PkuYtDQooL8fMxEw1XKSrCKAiVQA==","signatures":[{"sig":"MEUCIQDGT2Wr4W1YLnweTde5nggpBw4qwxlUdVIjEwtd42ZYTAIgWDgSbY0+dticN0FR2OM94AxMdtOOadEVE3ijA2Qon50=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNjnUCRA9TVsSAnZWagAAC1YP/1FSGHom4DwqzH6NreDk\nJ8O5x8n9O8Z8qddYSwyb5j9NCOJs+Lw8LuXVTnQH/bihjPnSFr6n9Qem0Bv9\nY2LYkXU0skC47Zp9th/b+T46lZcG+R+aVBAvi6EYcpXO5Tub6nScEtaBJjge\nP4HlcKcK2XGdMQlb1M/kgGm35uUnHTRNv5JKYew2pRAL/Gq+MLeOeUxB58PZ\nT5CtM6C/V4TiMBAXUKhGn0Gx5jxbrwe6MQqdwW5sHRKir32OHZ0xYsh4sWTK\ngxE0FnN3j0oyi9fnBHalEpnb04T2P3CKmFkXqdzJ9TTnwZqoHnH6wGT25Y/8\n6+xfFDzGYQZJbq36PzJUsADY0ugwFQzd0GLUN1tuY8oXyj4LifyhkA5Mmr4b\n33WB5N2v3ZaUV8pdGB8vGH7s2dstPVpTF0uQixfbbfYCMnQMmI4Ff8IKCuCz\ncuZYieZG+emsbaUV9QuvhS/uFiso4Dee3JNUvhaWqIwdEFIgVrM3jOxPOjmx\ngfhMAl8ogUrAH+APPxs1z1/ftuCVr8l+3N0xJpV1euV6pGEex+eZRRdHMhEc\nP5XJXFP5lWu3n7eUYcm6pqJPbMajsCAKZUXancXez6s8EKbou7rvzvEG+Fw/\npd68KzqWfgqO6RMk0+9W6/OTKyonpu+MQ/gL4YOEAmaojBjE2ULZ7SNkv+SX\nK8W2\r\n=GyWO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"feeb28900255b356528a190d75a835060e8db1da","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-32d7d9f-1597389206847_1597389267601_0.050014783178805144","host":"s3://npm-registry-packages"}},"2.2.0-canary-5d10095-1597400775506":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5d10095-1597400775506","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5d10095-1597400775506","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a7127add57b70e9853a0bcbc74c64358baec8a2a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5d10095-1597400775506.tgz","fileCount":26,"integrity":"sha512-K83XRUtnVLkkLcBYR0XDAEp+FHPuu9qSAxYyPuVXzZ61SGQ7b579WSzOvQi7lX5AS6ckQU3O4n93oPB5fVLl5g==","signatures":[{"sig":"MEUCIQCcBXAetj0WtHJSQQOQaAWjT1UJEF9sbD3l350/Q/7kzwIgQOmow4gj1k5OguTXmx1XcwJN/LtjkX59lF5imNmOIFA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNmcWCRA9TVsSAnZWagAAX+gP/0VWCnv0OdEvALj5j2+f\nGd4T0K71owKViKlOyD0GGE+KuO0Z/+r9+WjzNZYxQ8l9w+sts0zMHyLY7Sce\nuUEv7K1LGYa3tg7ZU7tX6/wZ8oWXfHC3jItBYmLryuiQ0hBDmndJ02/L3QZV\ndwxURsgYqnTYcKCmmNC5Fs3hrGCYfq+0fCMuX6NTdV5G2NwRhY0nkdfGUg5h\nUUo1BlvwsVndgR18Szw+jFdbxgaFMw//KGnHZ7WmvZysGOTSG7xz/lC1dXE1\n9atimqPXXmPZ/TA3e2VW75MvSMgIWO/oSHUoDzPhGAgr12QoXljZ0Kek/piS\n5aFMYvsjuljXvAUEXKawQ5h1yiXFSiMDU80JHRq5JPNku50UBQubRd8NsDTj\nfZLhTitGO7qmKDWu4NODZD2bSVwANxbWQpRF9Bqfsqsh4NOFoHQyviNMbwsC\nFiS0ZSAhFB9FnRouHfVUEJbEXInirvoZZ7APDfXSmgCK99hx6JB2l6jPGpOS\n3S9vDD0/ghOkpzWvCggI/qN2XYSwDuXpflrWwCkXeL4nM3ZjvJ6lf3y5W6IR\nmc3xSek74/GrnUbIU4RQPfntLh/scsYCoCtc4kWSidLrvn1OcQmmVxvdozxf\nfieSE+ZGFabjZSFQDgfnSm8ceEhWGBSSmvr50pnaGV5SnpCJbcImqwFSyihV\nOpTA\r\n=l7J1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"32b7ebf0b4339bfb4fc24f9e800d564c9816bef9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5d10095-1597400775506_1597400854352_0.9602389308546591","host":"s3://npm-registry-packages"}},"2.2.0-canary-f692689-1597454237775":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f692689-1597454237775","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f692689-1597454237775","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ac9fa3ae954ac9f57ae332fbdac67fe419812b26","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f692689-1597454237775.tgz","fileCount":26,"integrity":"sha512-QnDuMSJkZHoor2AwUicryj+x/9DNJvhDO2jixolEa935HrW3AAw2XO+W5/j27+3gLUBrDlpBYVCEFJcZM5KphA==","signatures":[{"sig":"MEYCIQDqDcoFlTrdJVJpktsgH7VMdZldHIf07A7Awnd9V1hxOAIhAP2Y08J3fiiFrd8fJcfhrRMYljFEotpQXW4pMwGPXEtX","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19113,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNzfXCRA9TVsSAnZWagAAamUP/A6k2ZJ2j4sBHEP0/+yr\naTLZd+SEA7zBiJbsENboaEhoKywjvoBMtfyOrvZUBy8eFS8b7SDCFFG4WhuO\njejfjsMTqVpjpuDg0KZfJnYg7PvDAuTucSOjnvMW2cjsPbGPbmA2AuUPXG6R\nha6VzVqrUTCElV1nmbQ9ck99pLwpRccj/UYxqBAkWkEM6P/rvYTcMIeRBbvr\n7WQ6Dib3hCxy1fXRYpYgBzCt/w+lrOXerYZsWcDmyJGPzXNkyAUO3sOGBWE+\nUaXY7N1ph4lcwLBEb+pJh42kS1TgOyPaOO4Jjq8LgNJsK2jjTrvX/pwC96eK\nfzusuUSAHhcmoj8zGXWDDELXV5JSJah8D0nRRbzOUb3rSVlKcQIrsdBXjUp2\nb/6I1Ga6rPT/iw89jbHHP4OJ3TUYJgZ2U9R7RFMBcr2eVs0LW/0uS1zjMtx7\nwf5U6q2P62wLuj+RdQBm1g+Gl9GMqDK2ktaDBqZggABNSW4hrU2Mcy2BRQLY\nQgTlXYYo+FyjdtrkouNuSaSwC3IA4GflOQiqqKerliWJb+lcgib7BNjpY4AR\nmtTmhp93iWjdU+YtYlSzf0ja/C1pTRYM9apPa4jIvehQUQ4f2bxRvbbsrGiQ\nn76iif6Hq0KXqFSVSugMiXBEl/dw5xOjx/3VC3KjCNKKOchPUyqEJm6/RCWC\n5xpC\r\n=yLVs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8b8ab6799d789991158f6cc2447a969ad40d3ff9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f692689-1597454237775_1597454294605_0.13457769763318117","host":"s3://npm-registry-packages"}},"2.2.0-canary-9f7f124-1597454832290":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-9f7f124-1597454832290","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-9f7f124-1597454832290","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7c295f2dfedffa62897051387f1ad826ae4a031a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-9f7f124-1597454832290.tgz","fileCount":26,"integrity":"sha512-e9j3wHJqD7REqDBXQA5zzZU4pgRSlFY2fnggiSPZxoy3JWS5Fd5cdKoYGcg4UsEVRY4u2X5bbXXauwVXB9zw6Q==","signatures":[{"sig":"MEUCIFatuV+o05e50kV+BPwwdjzSDOstnHK9225aWWxXTdZwAiEAwljP2s2ycKvBBouLuaWxKjYMkpFaQbiH7KVUmQfqv5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNzolCRA9TVsSAnZWagAAMeYP/RkLGsWa+vo3bh+nNO9d\nICKhIZtBSpToPKWf567MkOtw2Bt34FguzfxzqUKxLmEW2CBFB0g3lKZ1Vc8k\nOEVeJBimuaUESg/4/RG/Y8zWPHN2lZXX+ab9bM1cSZEuw2MgATTgYEplaRdl\n00IHnLoq9EhnnGNbKSNKGgtGecu52FBdpS4bIoGAp2TUf7dXz3TRKvKbgW/D\n2QF0Jv4ParQKEXHW4kLkpMrS806tIkCzxmmQn6gvc1c990xaCUiPm7kC2K3F\nPjq296XB0ZrhO7s7dTOrNsQvtfsT8zRvokH57CNK294Zs6Sknj6Ll9Yb6j99\nZ1IZmgbROEw82cJC362UN43Z8pGHsHCRftu3IHW14WK6ZqWdM5wm9UbFF/DO\noJvPAWOAtAKTRdfMBOfY6CITFL4TYMbxUv2xOEmhWoFFuuDzNnV34SGVfHl0\nhN7NJ/xcvxsls+Wp6JXgM+alAev/YEinxZF7TboACKEJFt92COWbe0YhhR35\nJhFnwAYyhQVvLV4n2GuKx0KRKaQG2P1N0VT4NgtkNwrMJ2fevVTvD2loZydg\nD6KCEF1vTmZmG1S0hljPSY6OHGLgZPw2pwiRxC+tbC1/ftVW81U5xjfRVmbG\ngmkCrgYX/v3d238g3PAZBjXI1QsCHOFYDecEvW14qRfCKX7fMvEKscLRedbw\nUeTF\r\n=7WP/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4f5e3de71db5e7362d2f79d117c396000b48e38c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-9f7f124-1597454832290_1597454884607_0.6951420928905665","host":"s3://npm-registry-packages"}},"2.2.0-canary-dde4aa1-1597467250690":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-dde4aa1-1597467250690","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-dde4aa1-1597467250690","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"295267355032f382219f1bd65b6167fbc40d2c18","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-dde4aa1-1597467250690.tgz","fileCount":26,"integrity":"sha512-wTXzl2Kwe30psa1Us18zCMqU9eIZz1ivtlAanygIDPC3RDAy03Acq23LJRYaaEj6FTo8DQLUKV2gCYsOPEqIng==","signatures":[{"sig":"MEUCIQDttmxGFgVXEnTRvw0/WiWSYC491DEOdoLL4p+DGD9rkAIgFzNQUZootWexi3yXGolp3Rup/MuJ4QT7HAmJwiMmZJA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfN2qsCRA9TVsSAnZWagAAAJcP/iGc78FIaV6nq8pHy09x\nDibAhvUO/TWbO9TbhSVv8PXTZ1kw1LYcIEWgWHrZuYCSqMGID8NcoA3al3ij\nSXSaYRwX1wDkM3EgJJM33zshVMq920cLtguRvhbVlBsJwm361wfByx8uVqAc\nhTCVXfTH+aV3COhCnxy1gdYWdjxj7UebQS4aDzdPSnfoDq2OANmElFj3wgT+\nRfC5DgdZnhEdiQ+TSyWd82A/Nre4VVhoSO1Te/GeARcIyO5ZMJX2J7l57QOu\nMmVvO8zolzZKEV0Cr7ikwa0D7l1ulwJ0PjcD4SGp8qL6vWhT+YBo++2kiK5g\nFndTX4j3Cn2oiQQzERsermFCZYgrxYx875AC2+6JzDRIPwKsgPJy0jajVQrT\nxN1I5qW2+ZKaTyVnAoVsnL80JI64YZlY21mwxB+W6Wppah/VLoctONPE+jI9\nJp8Re9lIEvBfjQbUV9a7oEieVjwKjIeeNg2RFqqk4AQMOf1DqME70tNVIc2z\nyWCvwcWFlYGRlT/O9sy7XjfeTeA0QMGpy7pNe9YoJgAmEKgg7xLhhi5gH+Ik\nKQm+DcfsMOhlMogNgI+WpjIRkhFaAiT3iue0vHcLJO4IPVNscAAZ2vN1ZFaU\nRLxhL3VkDjY4TrTP8ny7JsYzUhZjchBYrbcr/PhdORKStBGaCNbDmsORmVdJ\n5xtA\r\n=taEA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"58901672af4b2581fee0150bc66872f3eb6e0137","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-dde4aa1-1597467250690_1597467307798_0.17298355807829568","host":"s3://npm-registry-packages"}},"2.2.0-canary-42f3ebc-1597553710869":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-42f3ebc-1597553710869","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-42f3ebc-1597553710869","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"57b75a6e50ded43724507e9effd416f612b11635","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-42f3ebc-1597553710869.tgz","fileCount":26,"integrity":"sha512-vtdX8FveCsNPG6Q/RwVxI97YOrWvmLzz3ywSTGTj8m6EeN23qE9Zmmj2R8myZWL/pw3LZhnRXdfhN3Hu99Bm3w==","signatures":[{"sig":"MEQCIE345CWZkFcTKSegurDY4CtzODxDCnfQu1cKMgUxF3/sAiB5/5z408eJ8r6Fu4ATlIOX+QoxXimmu8uxtutvk/YT8g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOLxmCRA9TVsSAnZWagAAv5QP/3OJOFzPHOnqzJNL55tS\nsDjMz47vtpssDDxkh7YzIzGwSbs0pmMcBK/4CTYsFWhvv22M00t7JfeE4orI\nc4TGknR3WZkdh+k4LInQrNiiAiGLIvNNxafWMaG2xRL4JKlmSqo1b+Wf1nBF\nLdDoNjEz3u/FXr0ZK3XYfjDwADRTdfwjSxcSQqoI9IksVr5dIePSsqMalX/v\nSGk1gB6oj2QDBjvmrLxx1yP/TDByy/Mjm+HKYe25EMApKQ492jYYt/khaTJw\nwmg57lpb5i5zHU4bVTXYvrtsX0yNLE+uV/lIzJodSGcuFcTTqGt9FgfS1S+z\nj0OCdbnNIgMl7gQDKd72HQ4Wzif/h5WKVXzC23T0EmfaUFIDVh6Oo4PIKq3B\n/ayMW06KfaGg3xkZ/T3GWVNdPR9jlIh/Vn488YfG14yE16hOLO596xmXSeP6\nMfeMmrT9qfcBXTgsLxUiyV6R6XwulPC6keK8FvLoHicjPF9XBOX6Op+obQfJ\n2BE1X6kzXJ5y5fS7HQh67CMozIfCAAZENs5Vw5XqYcshFu0jg4W6ErG61WYX\npYwDPH0+bdjy5eiB2/xuLtXbPW4gmDtxB8L9N1fsx0oGxZ3S+n/5TRXb31UM\niilZ/L9Wdw2EpcePNQEjLFvME+TFc0C9ZAsF1CC+tX0wkKiMMS4d8NzWJSBA\njhMe\r\n=58Xb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"32517a6e019b2c0edddc5ed0bef4c97c8b0fb737","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-42f3ebc-1597553710869_1597553765566_0.9915862471024885","host":"s3://npm-registry-packages"}},"2.2.0-canary-21c8dae-1597557827451":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-21c8dae-1597557827451","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-21c8dae-1597557827451","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"12f728903f77009d62a9257bc374c944e5cd7a14","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-21c8dae-1597557827451.tgz","fileCount":26,"integrity":"sha512-S8SxmaOX3iIrgvpP/VoXucwJUeplXWNMe6lh7q5ee6A7nWo/9JapsSiyrJmuRvEARBFKiVfES0s6leKB+eiaTg==","signatures":[{"sig":"MEMCH35/Mfv1KJRtkgYi0kAbbfnsRKCEO2jiesCGsjExcLACIHykwVexNiyVYC4QqJ3XYT80Arl0NTGietywcm+szRVf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOMyDCRA9TVsSAnZWagAAS3EP/AsBNVySM0RTUrMOg6KW\nnO8H72stSt1DHjvit3WKrOWv3WrQDVpZAV361t4hfJo00+XrO9aJh4gltYot\nBVSMjeVjr5PtHy32pR6I4+5CHbZzXidRgnJ8YSstyoslSzKqZYo/xLu7w2PE\nwgXK54Z77kp14u/Xxy3RdUbDPmR+SF+kFp7y/Jh2X6/fQZ1GZWEYMQjy3twk\njis5P5ra8rrL99AI6JWjIXtDrmzVKwk3IdeWqxN4TTHiK0kTwQ0WH54NYEfv\nZsH1928T57+YNLWQa1VhX9cddgpinNq1tAeX7zb/tJvTiKhkQrSqjSs9YSiz\nuefNxgB62WriCq8dz5yNSIPiMnInu/ZggtCPev3JR1u9Vmgca0lDh8ZoF+vp\nBlY/1KAvIlQ9DHAmPTRV7EBtqhUZ4i0fvJy3ROYtiTzVLPuYwfJWaOjhlDOu\nh+4+KgWkZ/CmOy3ju4yfXu0a2aMifPbMjy88qIvLf7IopPqxTK0EZZRP3Mlg\n9tIARPw5jL/nDWKQSgTZ8uYb6sUz30OlLq5uPOOVwr0tik2BZOyrtkgSjUQW\n5v44cHTR19XIx9SHAVOl7bBZez2qFe/JiptOJuhczaiKqcABBYxeVO01FDnt\ngP7O+oDVW/YTDc2/rlYZpYXcNbLYcwv8/NBYPAtd7Hvtia/19sEpS3xtj7i2\nRu9S\r\n=yfia\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"12ab286318935451e3983085806824cb2ecd08ee","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-21c8dae-1597557827451_1597557891093_0.9032352397594965","host":"s3://npm-registry-packages"}},"2.2.0-canary-5d5e098-1597607676253":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5d5e098-1597607676253","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5d5e098-1597607676253","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2f2911740ef11b59e03aa6fd2b796badb96722e2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5d5e098-1597607676253.tgz","fileCount":26,"integrity":"sha512-8j0GYnqa7mfqFA/2DlcowtnzRVD94TY8dM7A3fEI78iir/WLvtrMyBz4NyalP9FDyqiuB7F0uGZOvXFhG1sDiw==","signatures":[{"sig":"MEUCIQDBbjgAUxO9OVDnS3Kk8HMr2B+QE/P05rz/nTF1yiaCugIgfkrhHKp2xDciuLXFw7qJpmOmC2uf/ULWl8tCig+vKio=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOY89CRA9TVsSAnZWagAA97EP/3OsHNqf6ZzbGYYsQ5yq\n68sCoyo+quultedNz6XKg0P87VB43LCt6iUdWNFCWq7s2nL27f9s+3A0SRFc\nShQOo11HfN+hKrDdy8665CvVJFdhB11WEn2L+FZUbisL741hw+fBn+/QyeLH\nrLpjTn99JJbPg8aspzFMyk/rs0pnFDfSEs5pJluqBye5pwCkx7x3NK9m+7ru\nIcHRqgWqD0B2r3duqLkDT9rOsqA/d4TIgCq+e8YELB8rC6+dV5ED04z4NCy+\nNvpU7fPlnHkV0IbLPZQa9y1+Z6HjRHgAiyK2eDQJ2D+lA4B8uWYw6PSkg/PD\nzUxHdY/QHKwYh56phpjBHDRZq1dDYKDMNx4PpYkhPmzSjurdlJMWqtGXCHtb\nbpelIy0DuBwTcFa0CAHfAgY9jgXJS4hIIYFGSn0m5udkMtpoUThQplkmiQUV\nQ/8scQkSkUJJ6gI5oZxVE/S8Qh4pEVBMntEX9ih1D8KzvV6g5Dw0sIN+jvoy\nDdvpFoG9/+fTiU6xTsVs4fZyjj394kjpUa4Jo3FuicF62Wncuf8QH0btE/zD\nBLZ81xVc34Y/ZmJ6yw3YYbPxp2Zi9mYRhfGbgpe8DPlpgcYULdspduOfu+18\nmJnv/YE9vd7G1jwvc8o5oQjbrr64plY631ZKHBtTjnNlCe7M3t0+GbZUP5/F\nwctE\r\n=aD4a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"eee128af04a39752223090958dc2dfde90b0aa5b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5d5e098-1597607676253_1597607741171_0.9709558559093019","host":"s3://npm-registry-packages"}},"2.2.0-canary-c7c21d8-1597832665653":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c7c21d8-1597832665653","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c7c21d8-1597832665653","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"054524530655272ada0c6a7dd424049f7187cd71","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c7c21d8-1597832665653.tgz","fileCount":26,"integrity":"sha512-v0tuhMVMqLi+GIcN+YS7LxF8vob0pfP4ulCTMZc2nNhmWtUAM91Hewc11QeScpzwv0qCPqItvjOXm7i6jXyihA==","signatures":[{"sig":"MEYCIQDzp14B0ob6VEBRWj/EMlh73wtlbELUCFOzaNEDOqEkAAIhAKTmNT+ArIqFUhptwGimSV8U5Wu03my6xlZNSSCkiQkI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPP4YCRA9TVsSAnZWagAAV78P/1MRBTYsHTT1TgEiliYk\n0TLzFXTQw8aw1yUbBymEndZKBokdRiW0Gqzr/m/RNLpETVnsnYyPFV+afhuL\nHpajtfGwVO08IE1RQNf+aVH3rNrGEQVLxLy4YuFPrOWLtCtLAZw6oMvH1g16\nCwJmc0S86NGq/QoRVu2nbr8ZDYY8mFN9daUcH0iFSKmR21iVjJpPFc5Iyju7\np5Shk7UoYl6S2++1F7EyI61qO6FCLoU2XYn8yrsbjrSOpI8btI1uxrIHKKWM\nyHgNnL8/KUMVr2d5mmmxwgrTcplvS9iRWFGlTQ6JjHJCJWTDahiXTPI8tJQt\nc+buAWu5ACefslpTwYGUtrCnpUwBsf4Ycolgn8w3A+tPmRck0uapFEtPZxM3\nDXIb7BTFrFWMViPSm98j3obdaoSVKnWY69uugYZIf3XsZe1eEy7NPEq50Knp\ngMCe2GhoBHCHqQ4CrhfCgLnLwIdWYQQMgwmQKYTf8E2kLuO/atnORSLXmBqC\nGseuIcmDAGd92PMY34HfZo7cvQe/uXgEqhAz6HDTeVE8uYDTzz/FkGlILEQt\n76t6OaKWpQYRH6y54cOJbnj4UfiLfLNhQ9YmtPCJbDeHaVdt1Em7oM3YAZdl\nXXZrf2TkRK7EZhPRUXWBfsVahwkMvpFZI4yUmldJ7D7AFDC50UyXH3cvr+8d\nwNPu\r\n=b/Q9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f83f7dfea4528046c760112d5b490cab261c5b31","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c7c21d8-1597832665653_1597832728466_0.3508754452073508","host":"s3://npm-registry-packages"}},"2.2.0-canary-c3f35c8-1598079876707":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c3f35c8-1598079876707","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c3f35c8-1598079876707","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"73e0d511ba31ceacd4e4e3fe5d049224d9fd4ffb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c3f35c8-1598079876707.tgz","fileCount":26,"integrity":"sha512-RfKCdFpOvkZSi2KQrq9KQIqt1wNByy69QcuT83uLrlA3CTTmba7B18AT1yzT1f3+Xs2NKdO3SAqER84444HmnA==","signatures":[{"sig":"MEUCIQDIMQz6JxIp99MOvOct+yOLpCk7UcUt0CU/0RnvKz6NiQIgSe0MfHAGNJpUjrLs3JZwgadns/AzM4sdLD5h40n1u5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQMO/CRA9TVsSAnZWagAAyRcP/irAEA2CKkiTt7uxIRoY\neb9HkRVO1s3ExKE3SHc1JYWFVZn96BTwxh8MxvLUAPKu3U/n2BzIJSRwW0Q1\nVl3mS3qgtJ7mPE9L7/s+GVW9SJIY+0lpv3pYoHbeH2FHaNg4+iqf5Tehi2zJ\nzm0Tm3BdjrIw5wjl9GxUCtgqV0HPGnHS2Kjkb9sgkCT8chSRxvM66Cnm0owY\n04BOw/unGPiN/qqKcyKBloNWHgTun6y1T+Rc+mN3619Uq3woTtB/hndKLRwc\nvMbt4qfRCbBtjvrmBjtaA3b44rzHLEDOkkcBYiDjoidfo/k6NWpxPx1VB+tP\nYRhTugYGlkgAxINoLc8awZUaCn/9B0sKYO++mRx+Gpx5Uw1xVYsPq750pJ+Z\nMSEjfKCo4edYhp2R8fFVAhvhYmU9Pxq3oQuZfcbKGgIaM0yO62nLQI5BTW9f\nliHhKagBa9SDbb3dEovW4CUgJ20hry/3xOoB/nKsW3frisZ4eTD38cnI0r7z\nn0BQZVUB203MpfJferlO+GMeUwBlt/trKkHfx30B8oIKf6pD+/MtW1pI+Mck\nzxMaZpSC1mbFmKGAXmwuWI5ZiZhLadHg1ZYRhk4lH6nPcEuHP9U7S3nfN8U3\nUbqUa3l2c52b5tygcAcwxUMzx6fAnzp54Yl4BDbuq4yjZiODOM+ODxP8/3+L\nB6uS\r\n=HP7y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"81d025bd0347121ad0d4cb55255bac2f001a51db","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c3f35c8-1598079876707_1598079935196_0.1404632355849491","host":"s3://npm-registry-packages"}},"2.2.0-canary-8285496-1598101962927":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8285496-1598101962927","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8285496-1598101962927","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ce1e1af7059bd972494f4a2109a285e7b727b08e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8285496-1598101962927.tgz","fileCount":26,"integrity":"sha512-2MQABaZYefnAlFh+WCSscN3Y4CqIYCHxvZtQwfeU6yVQvUWdElb9G9ykgmHe9G/hbrDaR69B82zX3wrTOPwKHQ==","signatures":[{"sig":"MEUCIQCfDvhwsov6yJQ19MFKZ7D0KWzXxNP5p2hnZxghQmpnCAIgByuCHXd7pJJMfSyEnnnUML8NDJbnGKqYTp+ZfTrbZUA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQRoLCRA9TVsSAnZWagAAYgEP/iLa1/ehG4fhgUhm2xcp\nLlSFARywfA/DCzbA57xu8mrlLoR1AjIqOWumxLYM1yoF0J68fGYEHBOL/df1\nrbzC+jwuJy+GLWA3M76FvMrfNmbJj26kKGjvxJCjmXtYM69zT6k233+prnDb\noeKLWztgHDgDXcSOemybL6L8KxaS3TyIBmeoMJRS2OEB/+t8/0oaaQeTM2iH\n7rbHnnCFWx96lIfIqin5PR8wT5KifSXT6QB51j7DDRO9eW9VSxJvQ2frqBI2\nQiAvd/LqPQEysgb4cG3wU9y9pMqPcAdvjvmUwoiGH+nDtoaiJgJnnCb+prZd\nyoD7vFIRgeHlu+OM/7IDF6aESi14ZmkJ3+mYo0vsldTVtIMBu1GSt10ZIBme\nbTgIRAUp8gz6enW7zvFYFAvDiUO0kDkg06RxfBN8Wb0bXgqB9J4/mCtZ3vnO\nuYlYYGWvxIaUK6YOrMNtUeqgM8BUpptlPk4FIxeg82RkpnhyFObJAqDj7+Z/\n9K3tTNlsVQbG4UZw0bsSeZQEVCGXm98WlGpirdftba6UHp/dkiN8usVqeDcc\nlxL4nWSySzEDx2oIw2apQiTocU8zVunJ+08oIKDdPH8yg2Fyh2GPByV/BXb6\nYrpqF0UJ0B4DMDMddcCxGMPtxJKfpq+xtkFpEtGZxgChyPFvQ5Hz6ElX4M5b\naXUm\r\n=ji6B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"86078eded941f169a07ac78ada14c4ffb47d1662","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8285496-1598101962927_1598102027411_0.11252933537604903","host":"s3://npm-registry-packages"}},"2.2.0-canary-e9e20bb-1598345113815":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e9e20bb-1598345113815","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e9e20bb-1598345113815","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c0af51df4dff70c00dc3b789f16f71b858a8bac6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e9e20bb-1598345113815.tgz","fileCount":26,"integrity":"sha512-ZPGzOWJ8cu/Afn0mFNwx/HHwppsVBKTB13RkAdRWjgHNl0BfoiEfYOgP98DlbtTBO2BmcKGlX7EeE5dD92uKbA==","signatures":[{"sig":"MEYCIQD4ay1o2k5ldS91bwQn0xsVgxKsk7VBy9RcoFrqwtWzNAIhAKCR5SgenJyRzJmrEys5km/5ELBWSB5C9ZET7Vopy72Q","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfRM/SCRA9TVsSAnZWagAAH14P/35R4I0vGUlt7d49wmSy\nhIw5OwaF06FbvYO1YhNRl3Do+Sm/8wPOVakxzYjTq1xN4w+dLS3Eqd9XUmTP\ntdEgi/3lTkiyYIT1Vk5FtzzAxsQiyXp8QWeYCub4KLPNc6uUw3aLlbXLk9Do\nA+CDq+fYguD9IwYyAiNSZL+gxLQgT6OQfNxOakQijeUY3PmIPxMCt2iCwRrx\n6B50QWqdbgFsD6jQC8N4yYnd1GhGpo5ZlbPGi5VDdLNGgPL4anuSZci6QBjP\nBCnuUAnmyzPW4OMQ3iFrDTKEqij6RjxyCRO5eR9RI43sYiOd+29YfzW0UE/7\nwk7QX91L+71HgdKJBabl+EOtorQ7O7ydxoqgqEwwiiEO+R/PXa2+ZTrN7B9r\nxGinVM8aDSR44a5jyUENL8nz/PVxCa5FS8AjbxwGnicfzMpDJfybnS0qxG7R\n1Z6+wN2sI4ZAtkOM6Xwef6A6spsiIaQiEPKI0wUXiCw4+p+YPsZmIgThi2aZ\novWUsOXH9EhItrjGuLWAMzTKBPKOCmLJX8S9AR7erEZK3H0fmIGnyp5Il404\nc/oAwCupIcebpkDaJNxDh3rrtSODbfYfhYGfvSccEOfpOUehzks4kbNEOd6q\ner8rqpNQmsbeDNYw49JwcufAZCuQAglRC2MwrNXPnL94Rtvq9tahyRYqq/OF\nET5n\r\n=3cFB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"03a80dca8022f49692d61806d85c6e85b37e8029","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e9e20bb-1598345113815_1598345170494_0.7758649602683532","host":"s3://npm-registry-packages"}},"2.2.0-canary-83a036c-1598508052260":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-83a036c-1598508052260","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-83a036c-1598508052260","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a29daf1f30bf5a8b3fa5f44231958a3a2b91f59a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-83a036c-1598508052260.tgz","fileCount":26,"integrity":"sha512-kZX/NVzQm0SqBtVzV89GZuGrsO0xOtQ5dUZyxMjLMyN4ZfeZ5DlbtAnIoiNv1SOynqewDINsr5/aQ2OYqO6ifw==","signatures":[{"sig":"MEYCIQCuGPmQbVdlMDKsJ5ptMqMOdFktCq0bdg9x7QcBFAq0ZAIhAPKEqNC1SaD0OlyOE1/UskqB7Ft3x0Qoe96URgLkAjBH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR0xKCRA9TVsSAnZWagAAWIEP/RYd7zwOHRiT4EVtOhQ7\nKmJgHm0uTvjF2PDhciUU6uzEpx0m2N+hMjIzOLCdObGYhVkqvmhAXkiBAeZa\nWkJ9MAnBGtj6WAWyrP8WRrpSAgNlemRQvytrJFMsrXOWg6AGmM/5sU/jS4tq\n/cJBQwPPZFTp2ZrLE/Jc3aW9+K3uuOzBFu+EgOm5Yv2CtCNUvRPlRbFQo4Rd\nNADyu006nVX3QcYDPhUeHr+hLLkHRZ8lPAmqzzVUgxMX+18C5hN8FXCx5T/C\niD7a3xw0NgBTOGqGx89aMsyUIrSTc0kub1JlWk6imscLlCHLiv6cZuyhx70u\nxZa3aYA+5IjyZ8C0GJs0JSZOYdiFvQ/Yy/z8MmtfbxxbC8qqLD7bvyWCin5y\nvVG1NowQo9np4pgKbP+++TO88gX+LAeK9VjlZqPWK5cAYjOhMnJqTrMR6yHu\nXt4eWWmLUMop0YpuH93iWzt42fZovLMapoXXkLbBvDa77XT/iGB8veT/j1Eh\nWVs8RPsqGnGzaFuxZQ+XeSxVE8+B4YgTw4rcZDISnahXxLdb3CZeUbQLSXkw\nPnRxDA8rczIiv4ivg39mu5hEvftFidOsNGTHjIH2LRmSgvHoboxCAe21/CUm\nNo3jwUiMNQyk/Q7lxG3SL/o99PfvaBu1T27zJR9RNVjh6cw9QtZmiZuO0ihl\n1BPO\r\n=msfJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7096ca6492db6fb47d798548937f178a44c69bde","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-83a036c-1598508052260_1598508105418_0.09029217220434504","host":"s3://npm-registry-packages"}},"2.2.0-canary-cdf4456-1598510794424":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-cdf4456-1598510794424","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-cdf4456-1598510794424","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e725cff60914b206c1ea28ce35182b1e90ac5ee1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-cdf4456-1598510794424.tgz","fileCount":26,"integrity":"sha512-XeWhi9IACY7OchKEtu8C8E8pRRGrPuBEbN/Z9FXfZYECU1LE1Bd4v01SkSTU5Hqm1ZCffpe85YWS1Av/ZCnGYQ==","signatures":[{"sig":"MEQCIDS17pd5hM7hNGMx7aciNQAfauQ4j0S8MEYuLlBI7nU8AiA6PLVoLbA3DBhLz+t3Oz4c6CMFLdtAZB1cHgNuUj/O1A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR1cICRA9TVsSAnZWagAAkrMP/iSoJ9Q77HIddGw8qG8A\nV3apU6h1KgNuujS8bPrH7NQLO4c96TdjTnxsSQz+5UccDj/eBq7Vtos/IdGZ\nlusWwIy60RBnH5BcV9RQbg5tIIT82b0vZOhICKWCMeaZ+cUusHYUjrmWb9yC\ncPw/hFim5vafiZeUfKQ+hKtqA2bS+bK0eOHULMMyMil5qVzB9S+yNeNWwvKU\nmiydIJ2lrdOyTBJIS6s4hWapaQDq0lZyPuh9F8g5TihkIvq7Wkedpx22g5Tx\ncpZmaHKa4wbQQ4of69ZLdbyoJtU9+Nx4e2NMcagt5baGza9BtWNk8KfZJ2A5\n/Fj4pUrX2dDWYtJWBJpLdRoTPPzwTcJ6IwTvKxiQxAELgGsz6Qz0ZhbgWhZV\nViZSbZa68ObuWJa2r3VO12scrqvoZWuMu00jMyedULqFwL7U8ZvG9GD1bsXU\nXpGAb5LSZRr5MFPU6AnYAwoedPqGWFx4NhImWN6gUCnkOtsi48xdgI7Z3EZV\nKaZjK9h9o4DvLkuSJYnjZeff2NcCdBCMbv+PkQJQssWrbJat+pFCWT7g3D49\nVVzZlbM8PczKYqf8F0YTgCRO3pWayfDmRBOKS+rFUYpvmzOVigmDaO2Zs2v+\nxOi/tCMCvJEG9Rys6A3KPcViVOhbfx//TO8izP7SN5D7EK4nOMq/JQbEZUJj\nQA0I\r\n=DCny\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b5b7e91248fd8f5aa3869e35d5cee5cf6fd6a271","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-cdf4456-1598510794424_1598510855804_0.28075538749348095","host":"s3://npm-registry-packages"}},"2.2.0-canary-0ea6a9b-1598592452430":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0ea6a9b-1598592452430","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0ea6a9b-1598592452430","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b040d8d0c6beee0e694ed8c38bba5152b0630184","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0ea6a9b-1598592452430.tgz","fileCount":26,"integrity":"sha512-L4FTf79/0tiLBDTh1sLBfzkdyZOZuAZuEiUJq6qByxNWd1F5XNCfYaRdpW2y/uFJJr5nfb22ak34qyYRy/Rp5Q==","signatures":[{"sig":"MEYCIQDxvoIBcAzBorEr/kzV0T27LFsNJLiNcPfMYwZwxf2zmAIhAP7yTFHACNhf5J1clRmRit5Lxvd6d43XVDBZQKLrEpoI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSJYFCRA9TVsSAnZWagAA4QYP/RnuxxA2gE2fbTHpWytV\nwHtIi+1X4+D480amFI9TBtxlSulOr60huoM7T1znQ2yR9m+lmqkcVoTdPHf2\n+coKTlvavmJs46PQmHgBEWiCvlzGEFl4ApEGW9upf7QFFiZa9VxGChZP9hEj\nNH0MDbMmuGf0P3xQVv//U0s3xTymiRPfw0MrtAlhbIvFtOsmCMbyi7ApOJMB\nSWdszAKC5YiHeHi1CuIFNZ3gKQhCjfuci8g/qU/qSD4ToIPJdYBrMx1crNRn\nqnMqkYXRrbD/uvvx0Zmi5nfzOw0c3m9rJjMjky1hkwPZRg1j43OpKLOU/hqo\nef0pB1mHqTUD25ivTMVc1iSU8JTXkYGYCDtsKKN37VQAXsFSjIREgr71FRl2\nfnvu1ND3te4f4y6KxXnrErnWA9zk2uYB238I5a9jhPZPJcPqKQPO9lOiRnDv\nCpM5LvwapEa+XG9SQDGTF6otmDyG1OqbVqgrj2rt5eirTvp+9Gm1Xm03cLyb\nddRN2GumgH9858yRhB71kRNpYEeKVsRzX82ZvO4S107D0jhMeaiDohQ5cFeQ\n9qfAsN3g3Lu0poYgGUOuNpv2VfFo4JrgT9coIqv5CW+z6/anZckWRbW1ZyWz\n3FMi4M873+0IE9h+r3sf7oVOqZ9xTetfw29wY2N6rpHjKKSlWonSLadJaJgj\nI0ZQ\r\n=z5Mo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6f95fa46864d6daa378c7cfa58439b3d8d6af546","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0ea6a9b-1598592452430_1598592516573_0.046620804197681","host":"s3://npm-registry-packages"}},"2.2.0-canary-cd42db6-1598708271708":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-cd42db6-1598708271708","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-cd42db6-1598708271708","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"40369e73a6b80cc9cc94683218d390fa8cfb63b2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-cd42db6-1598708271708.tgz","fileCount":26,"integrity":"sha512-G+N7fmRR9SiR3CgbSPmeTW4j/JLbzJwsQ2q4+aesAdzIHyCzgHt8vYPk4RtBmyjJ4fmIyz9dP77eotEnMXM6eg==","signatures":[{"sig":"MEUCIHZSmXfReVSK2tBbIymTmR0yMEHWpCScVONzPk93SsClAiEApnjJJHw6Yfk0i45kMZr5IzmPwvax0skB7DF1eQquWhg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSlpuCRA9TVsSAnZWagAApYEP/inSYiaPjOuX3z286qeJ\n7Fhra6Dfz63n46PCj5rHzQx8aw8+hZCLEFbIBr5yGD7MGZZzFy30JHoD31wW\nR0MmxfKrbg4Ag/OH4Vcu3Fyj6g87FDgwyVJ7A3dkdxwMX1LAtPdXo6hMzgLa\nWR6IuqwpuEf5gwSDf+y9i6qCFQfNAxfF1hv2A5yp+vIoSopHnm/A/ZgR2So9\nQO+j/9r0nNSAtqwzsyO/w5ZDrihocGZ4xWs29zsO1uvfG0zCH4TgxS1UrWPr\nZbjWQGKHFZ0Juae1BCYMa28wp6555h0IBe5fLS/98brRuxhR8U/r6Mb65erJ\nTXyo0CF9K1GDuxX7h37usxF+GtZC7JTPnz/v8s+mWyXk/rN82qEsIhTiTyJ1\n8NkTv2+sgKQA52tukDoXCcj+8uR7FlfYf71lXJPIqWHQa7f/j4+/A8n2QREl\nYO5i0MJxlqBCAY50VzZUYGMFLTa0c/iqfVfe1/+lyqcYhw7BU6qnSyNkw4G5\npgDh1nhHhhbEiXs7090KeDBxXO9Boc19LyznX0gepAPl+pFfP8NMajDn80dU\nbyWEm0E4fTNRmrtf2jfh3rWvbwAzC6ai/mpEp21p1ti+BfVSXiZ6yEa2hqmo\nWXuMd1KNzU3pYWAwVwQ4wAB1da7df0lxCRC+/oGV3+JoDA0kIYN3SmcqbPjy\nEuAt\r\n=Bpms\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4348baa25e5fd1cb5dbd41a3816d51cd977078f6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-cd42db6-1598708271708_1598708334201_0.9073673768499702","host":"s3://npm-registry-packages"}},"2.2.0-canary-800f0e6-1598710210847":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-800f0e6-1598710210847","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-800f0e6-1598710210847","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e7a36f4ec9c33b1a649dd611ae79482d0fd87891","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-800f0e6-1598710210847.tgz","fileCount":26,"integrity":"sha512-xf4WDNSUFKu9zGbJulrTIP6ZTDOH5wmfr2DHFqfy+nkPmOxwEvmnPYPsDUF6y1c/SdATGN4QkDqcFAsZ1mPkKw==","signatures":[{"sig":"MEYCIQCUAIo3B/iiX0L2+uqLf25CdCjOFs2+B8U/yVY4CtYO3QIhAIWz9IrjQpVjdIPoQSTXJQezk61SBQ6EHSGcpPiiZKMo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmIKCRA9TVsSAnZWagAAr5EQAIP5+ZUAd0znivE2w3QU\nZ44RmFjX/HZocUWVhkHpPvMY5umAt3sPRMScyRaUnCRPIDx5mPr0vnvV6KWW\nBFQDErtpSz0OOU5G16qMopge5rTnz+SKHETKkk5jlcLLXkedAllveXGc0ydL\nmgeTqa/RnDOiJmbUjzNiRtui8TZNV3OhaeyB4+gmkWQPQhN7JSJj5Orfi8CF\nZFMvxsQb/lySJV7aP+RrJzxMGKooo7hVGkE7tnN/mor4d091WLVWEtD4AV0q\nE2hU5/Uh3201mFu3GWaj+dRDfhk6ZiNq31uiHu7xImQhIkTuB8WGtqv5obsm\n5cwrL8MfAojI/ciZsuTJ9hIppBaAKr2UclK7qJlHoWxWdSmGCZ1Q3Xqaqi6W\n5tT//s9JHakDZEvBghT8O3+RgEp2WFVr4DjI4a8saKmEHe+573oF7hICBh1l\nMfHF0VKmrYjrd5H/dlHGtZl6q/9ierHmpqm1RzrvQu2Mi397RTr3UqiTVwS6\nxHNyrTG/sb7Pt1EDBYYuU1n4FVRHvmMG4Nrz10LkwQbLnmODJtZcdg6LFI6k\n59wH1lxDTT4ci4gASclGXCIHGdi1uG/zPeK2RHJY8KZduJ3Qc8+/xgFOmh0K\nBQ27mmwToEsemf9OueCxvNNJwHoDtsa25ODwQP8sYL3f4tKbRZhOIEbSXYPs\n6Hvm\r\n=jbTi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"bc70823607a0b11a6d5fe4963cb56444ef555954","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-800f0e6-1598710210847_1598710281724_0.8745373891818853","host":"s3://npm-registry-packages"}},"2.2.0-canary-d5d7bfa-1598712128332":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d5d7bfa-1598712128332","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d5d7bfa-1598712128332","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0c829a4c56feac4f0a83461bfefc47421fc8c2f8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d5d7bfa-1598712128332.tgz","fileCount":26,"integrity":"sha512-xdMgFbJY49j8IQTyfc/PP7TwLrewshgMcnz/JY1T3dbKJRyubqq24f60B+ZJBf5iKbJVjIw19JMulwqg1kcx1g==","signatures":[{"sig":"MEQCIH/ON1fkzbT5ekj0bAoDhkrGsIV+fBiTLJBctyvhNT5rAiBbigm25HjjEmh8Gj8gJ7l+Xsi+2UCXRoPOwvqYcTM8BQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSml+CRA9TVsSAnZWagAAamkP/1KFW0iZtoFcXC3QeMod\n1YIW/phzJV9a+Lh7ZGCPUIRvRE1W6SxHJgEWRragcSEpuBl+AaFPNn8cNIsg\nE6jCGyfud97RlSZ+ic6wkSI8+msycyi3AvSLa1v+jz+apzufjkOi8T4pszIM\nVrAUR8ZgMQiGW4Uft0+JHm01ceR5LlUuttPJCCpa9xJ1pxg18bFKwEIung9M\nHfcr5k+0nJmxYnOTfVgL3hjG8E3+5kF3RUpzG9L/0tgZjh7ddofAjpmXsXmr\nGKn5QSdx7PolzB1Yr0YqEygfkuAa8xuaJ2qTcsfrE9VPHrEeOkAFksg9Du8P\nn7yJf+6Gmn7qh0RIG2qZb8AeCAng1cGvHaGd6PeEnPvXPXfl+5G6YAmFDFkM\nOZG9otJ9WQSDR8/5s9iPCtOQkhoO+bNOSbNRhcIgBPfQst8jHM5gR5b4tGnl\naYjowIWOrwocPomdf55Ea7OzBQkJWo65QA41HHYuKoOzzyjiIBwoJf+/b0/O\npIFQ9QZD6xkh04YOzSsRPClCZcZhec3/SVzZVmoN8gkeykG+TIdBM5lYAaYu\nuuKexXQi+XXiuX3WJQFnilHIWgCOP50rbG8gUeOY+uDsu5tZkhLTEUxwztYa\n4QRGEkW5M/niHqi3SMb65URSX/nzXGv/MBwi2ltpo14Dyb5DMepMTNoJElrP\nfaZ+\r\n=XoNH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9bb6fa829f1522f03ae8ddfa903293f5a4039a87","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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.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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d5d7bfa-1598712128332_1598712190236_0.17865934235829983","host":"s3://npm-registry-packages"}},"2.2.0-canary-75a8d70-1598814392584":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-75a8d70-1598814392584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-75a8d70-1598814392584","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"88a05f58f33075132e34f61022ef7c361cdedab1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-75a8d70-1598814392584.tgz","fileCount":26,"integrity":"sha512-rZALbGW5Cbqquo1K7IcQ6n5Cd/Cp69j6hWbxlHKb6k6SkBZb6UW8rNjQZOPcJzXkOoS6H2TF3U8pTEl3gM+joQ==","signatures":[{"sig":"MEQCIBaG8ShpptiK7UZMk68f9XGQV9RQDslVHLOWrkjkER/cAiBAHt/sGyDj3w0s4cunGevS3AjSdCM9X3a/Y3mfMFMGkg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfS/kDCRA9TVsSAnZWagAA9D4P/iZPA76gcDnmQUx5r+B+\nfdOCbXI+hHB3v87eCW6s0zItZcF6bEN9pi+owjBWKGuBYgjoim9y/6eDaxF7\nYNpdtalyHU5YDXyvfF0rUqWL/T97KGivsCj1Ua9AzMU4IJVR2vkd1MmrQp4E\ncQkl0pde++m10nwAaymJtz+voKiUHI+ju3daMKBP5dbSKifx+mLZD1AT3wtc\ne4sEv0h+CyxfdOybodj0WcafUfgP/9nmMPBbTF0wHwLO0odhv+xICTC4KS27\n/IyraT8BVnJzo1lZP0sDDFVOwlAHaYndWAfSAY7KjySR4EKKL5epdQop1xup\nODEVm/ounWwOtKMmstK8QGrIzCqT2OXhPr5xfl0eq+uvSLIRIYPTkPm9XE8u\n9q+kN6kmRjGN69vmqT7tnJ4cIUByk+QXy9lypN9lk2WYuwat+6wCuCxZbBcu\nl1oId7r4S2PQ6N8kmGdfg1Vy3CQgdx0nYu7Ufq/K+/LgZzN3n6f7J4/fdet2\nFn54u/lk3e6shuTMZ4m5cJx0R2/v7kMdHF7Xnr/y/flZJk9M2n3sps1VSwg9\nxoXHIu9KjN+fOaSJGjlD7iyu9XqnOdj/BXzuOFnVCGvnQInnj7mm84Fy0xZ2\nKRTUKgwv0lUUG1fG4QgvpYwNBgcOlNohCKbqgoLLDzIknFiOLhBf/1c8Im4j\neQcO\r\n=ScQh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"460745e365189fb51521ecf148b0882562db31d2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-75a8d70-1598814392584_1598814467167_0.8843840584602396","host":"s3://npm-registry-packages"}},"2.2.0-canary-961bd00-1598912112078":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-961bd00-1598912112078","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-961bd00-1598912112078","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"89255744f980177bc2a6e3a81414c05e5bf7a5cd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-961bd00-1598912112078.tgz","fileCount":26,"integrity":"sha512-rJXfPvKrTN2uYoQv091P5/80auCedL//o9g54K/BczYYhi3h5u+J1FYgpg95lztxtY2oFs3WHOO4T4w4oa7Qig==","signatures":[{"sig":"MEQCIBDQyMCWm70OqjSkINBLKDvfWVKsVc8BfToMekYaZNBoAiAgzXbjcOB0p7+gZBLLZK/4/xN3Gq0kwzYVQB5bCg4CUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTXa1CRA9TVsSAnZWagAA0rwP+wToydG0dFa6+T7AlJQv\neztLywzer3r4Q1B9LJybVCew32cuD32VUyIbF6mt+6zxlipRuujU2ZunmwTV\nkdzpPJ4MSAUwknZR0IR3z3u6VYcw+eIW2/6S7N7WxDJji4LwiRDq8PMq3w2j\nui1XJ5r2K6sYJlDYK4omgUSaPWaCCcrwzxpzRbYzAJa0noDHHy1mlbDGTETZ\n3Homj23UuWqowClQaEjHRca1eo4PAlUI13W5/DDhuj7wqZ6k8xwl5PYaA6Am\nppUuPHD5v8zybynSKsJ8aN12Yicz9BlbJYbOo7/lyP70RxFqHAFTXNNvzF3h\nkjdbGKcoRiqyi2/oLpd5HYkpx5gn6gLWHGgAmTHVu8sWXwKqSziqcSUoOt+d\neJnxk6SIf5rgVHmuE0m1veI5pHokIvlFjaucJPC42WJTqMd5vmSvUqOphk8i\nxrSRbrBIau6rmL58MGAgtrW2D0/zMUxGOVSTjny15tJZ1oHiA5WLZEUeK0ck\nr6F+DRbscmhU7jKiC8SsY4sbQaumCNmrBzVPc23o/fM209I8eD2dK6IWs64o\nEDzMYBAbdhql9mN4DyvcLCzfNT2+KO/6XsBANkPsYxnnWmcEQGQfFlpz2c9+\nhBsMVQEsyheE9rJXz8wRwBAGhXsXSHK2nmz27e/tAidSBxrZLp4h9FJC1Wys\n1Sj+\r\n=/Q98\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c789ae3f0f8535096b3f327b73fff77cd702267d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-961bd00-1598912112078_1598912180824_0.6910226723608921","host":"s3://npm-registry-packages"}},"2.2.0-canary-a2d9528-1598968796196":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a2d9528-1598968796196","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a2d9528-1598968796196","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6ce63cda7a158c5327c08f18b9587ed95a737a65","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a2d9528-1598968796196.tgz","fileCount":26,"integrity":"sha512-0brqfEFFr8gEee6713qq8M/NS0CteOCD2zR1iXGkZfDW0QSHjh7Aw4zZkrqK8SJ12DQwIddWOjrhzvZw/o1uAw==","signatures":[{"sig":"MEYCIQCbniSuI89SQAwS1LVsEUxOmEeChzBS19ZbCu/kJiNP6wIhAKqkCbhYOZYDO8sFOkLrAc3p/t9r63IBI/58IDld/+XI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTlQrCRA9TVsSAnZWagAAixYP/iVo9RV8z4e3RyABBZ5P\n4Jvyv9zNhklwih3O05GVDJL7gD11OydcLB4toAqitdNe+LgTSIhD/tcJwKYC\nr01ua6hzCcpyS8oPTwWck+4kV/Dih9m8WiYLaGpLN3U3KR4lvV8nkuIkS6c2\nS4SciO8Q9VPYy7Js7LJKatrF2cftD2e2X+bLJ6RoRPEAYmQ5HxsEmuju0tPN\nVOzC510CTpE3HZ0PPHLtwWD/dSE0TR7A/wfvN1xS+RQHtZSXNZbQsp9pigmN\n0aJ4xC+4zC2cHetgKr2i3Ri6hnlDS2RPTIhs1xicOLs82qow/jg9+atojd0R\nSN5Srs5D/oxIB0hr8v0YsEEFqgP5c57Yxz7jnN1XgBGetxYieqUQIrOGYlKx\nfaqE2BMgQcDbDsI1oY5f7sEkX+iG7NqgUpmEcdeVA1QwF2B5ESXoBE4Pu034\nkLg/s/hKoz6/NjpZmI73CBzjx4/qOmw/3HC+H7+fpjoI2H1ImjNt6dsivXuC\ndrtJ15ehr1GB+cWuduklid/qg3lp+1o2r/8ujV5UNJ/wn8LZ+5GjuwVC4MPE\n/lGXI0JHPjsmZ0B0AT7InEZH/xvJtNGYW7tS2d4aDI49m4lBbvLg9DYTx0Ku\nSFeCIbJrsCD1Jjmprms7UB4SJq60fN09HdilEmW2Pa3bs5hs5eO9qQTnSIDX\nZoB/\r\n=wjGC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f448a751b6ebca4af46180baf010c4fdcd697141","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a2d9528-1598968796196_1598968874628_0.24566599847072412","host":"s3://npm-registry-packages"}},"2.2.0-canary-08da3a3-1598975270543":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-08da3a3-1598975270543","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-08da3a3-1598975270543","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7735d6dc59c692c6e037c87b77513ea24bd5d4dc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-08da3a3-1598975270543.tgz","fileCount":26,"integrity":"sha512-GyHQfaBWs1glon2HxKfab71Zcq3dCpZe/VLdm2BfYr6mWY3DCfPRsO0RE/Gkr7r0mEvF91bSVtsHk8HixXza1Q==","signatures":[{"sig":"MEUCIBNngD2COrVPj3lV6gS0NRRTqyLmZmIYd/xToRvVv9H2AiEAywbZuPyNwjYeXVvjULAI3oOok/JKFJuWcnLzV0dTpis=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTm1pCRA9TVsSAnZWagAAQk4QAKE8J7Qat6sYSJBBEtXZ\nPGIpqCce/6GCNTY902LzxmBntVfOzDPDZPuKNUAJmrUX6tVtImyOZ6l4oo4N\n78DCld+wkOJnlkrBbAoLdrYR2yJ24dyh5WUGHtJuxl9ftwIWmUtBJ5nh05ip\nttsoWDm3Y5D2wyDNwtdflEABw1960ZwjjzrgIgq9JdTivsasoI9/YU9Gr4oe\nQWbcT87f+ZDNeonuDOrjDteq0Mtm5ikJx7l6DvFL4b8S/UXBw45U5nG8YI/I\nMD/eJBWuXZhlgjM7207WxIIQq5z1uOfq16INRyqHuWE7EgDJvCtEkX/gYuj6\nkbD0WHKKowWhQjjhG5R1jvh3GHy1Az869Ct8MluKiNyfTd56fWSXzN4PEfpc\nc6Bq0blPJ/pKrH1K0KT0r/EgM6sDzwoTLFUpWCt61W0lXl++ZZ36rl7HYqg5\nkBxAImbXURLHuWr9fGMNrpmoP9ROAbUXRMuumwshLxan+X2AXBnSUWp0hNAs\nDa2eeb3jhH3B0w0wPzLG2Wa6bkMZmr0x0ny9S1hOyt3p2+e0YZBzT+cXOToN\nHoU+I8LN7kKKGrurQIdiSAcS3FZ33gAisk5PNC47JTJjTs5lpeGNVFKoH9Gz\nluhk/n5SUKZ0LA9dvhENgTJgflbPE7Ba01UWlwHHhn9KrDr/GnCqKo1kC7H9\nn2wc\r\n=81m2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b9a3781b6ffe80015c428ec0735a6e4f352ca01d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-08da3a3-1598975270543_1598975337001_0.7507949655379655","host":"s3://npm-registry-packages"}},"2.2.0-canary-b518123-1599031436461":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b518123-1599031436461","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b518123-1599031436461","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"1e236ae87baf872e7b458b22ef92e4066eb7b36a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b518123-1599031436461.tgz","fileCount":26,"integrity":"sha512-y3npL1F6NVvji4czNqdryoe+gXY+7cN75/sw9eVqMsQvlJRRngrDp1s6jraheWV9Lo15VsGbBUcPJDgVPKI65Q==","signatures":[{"sig":"MEUCIFz8mkUY2YaMg6TzTA/qMJh3bXDitnPIGClD+35UwugiAiEA1chiNIgMuHralW1JiJhNfXh5ijYl9YE37SsXkOvF2dk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT0jJCRA9TVsSAnZWagAAIWEQAJ4643bHT/A8XfhdN8JH\nWbJbPPSCpJj6SYmwh5UkXL0eHXRPGKMOwsemQxTmu9BpZB5I1p28ykiMg5iE\n5ba9Yk3d8oPYIgTLAOeLEJ5L8js2hfr+51NR6Ws3fb43P3cqWp00h36cRRdH\n6+3ogrzRXGzvTXStmG9xmFD1bDUmvcKQ8SCW1j/WtFot0GsR5yiSURqDWjyl\nOrMl7eAcquWwqO1/vkeM/dI96mW/idq22j5z+hDIdAsztzofZ6Xlzu9JxNUs\nfl8goe7yUlPL+hhU5bPu0MB5WkYbk0hxia54MYwKWGlp/iMu2rcF6lVvSn13\njjkJ4KO76uWpCeseBZNKbr6hkzH337bcwDw7ZZxcxNNdH2FQcJrp2ydLKOTW\nNdD2gxpUpS/hO1ZM2TqEISJkXBG5agtD0AWaiqC3Hwk8L4cN1aKdc1I8mMls\nhbIL9Ovl8XDIOwuxow8Snl9P4tHNuh6loZBtnyGEn8HXMyE2UpoLODdxzi1h\n6dwEn1IVHPQIYLYasrbYIn450bf4ViXgSQy6iq2HnknBu+Wwd6HhPHeI2Ux2\n6f34O52Cp7AF+N2lBFLGOdW3acdPrvUI3elLGmSGW6tT1l+QwwTUiXXWRwQV\nveLUsHP51FNV+jAciTpFoMIWJ7hgMGvNVX0QGhwKQYMXKMEvJxzqDRTnyM8W\nSH8c\r\n=k6ow\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7fc5654eab18a725f9c0abfd1265326ac9044306","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b518123-1599031436461_1599031496736_0.24872890212505627","host":"s3://npm-registry-packages"}},"2.2.0-canary-ec257c6-1599067281309":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ec257c6-1599067281309","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ec257c6-1599067281309","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"94eecb5c0ddd8b5df569b150c9a4eb7cc6843e53","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ec257c6-1599067281309.tgz","fileCount":26,"integrity":"sha512-OfyOaGIWUHpHS4nUySwKQAcz/2qwBp+Lv8N7jFAwG3AaemwCj0R13U+vS7FDLf5HSd6JVNDLsnaBo5pqbvbKYQ==","signatures":[{"sig":"MEQCIFCZ9P71R2rxiNDM2z8zDyt9pua8qfg6OzRR12mZfe8EAiAWmV4+1xJd95zkg87BXL2a9Basvv3JN168WyClTHeBig==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT9TRCRA9TVsSAnZWagAA1YIP/R3M1ST93MRqRi590/h6\nI6RjC85WhqOPnJSLkYl+wM3Ng7vhsOfWlwyXwiiHiZwJjBzbZHzFAH+Ej1at\nMAqivgBI+p2Gri0pLTILHvPJ5xbAg6mu9VD53GIFNDTWydVn5jvGjlG0LdcE\nMYsR3qnf72CDYnlz9a6I5ZjLiPqMxgIXHCqNDe+5DZ0e6s3hr9bdIDxBxWFc\nI4LFENrQCtk3sivCTIJNLmQQ2fXJLcmQX4y1Gmbtig1kswb7UB3HITfeQ2dl\nKCtXLVIdn2JmWJyJ15bufu/TjfvtPYy2T7X0yQnIl7xCelSpJcqjqZw5YOia\n1gb2ECxrvveAblsEzC3skmAZoE/krPOmUeAm3sxnUYx09zYPcGd5jd7xJMwx\ncxI102I6YlVxMpqUKPQ4e7noSgisvot3bwnKrxJ1f7jFxEHWNHoyZxSQP/aL\n4+bpBxO1MSmBIToYlu2dbfm7ORmr7Fj8MtgErjXg0lRI3pmx9WomNO8/Umwd\nrlEzarOnD32gHJPSWKNO7SyzEyvTCsrL17awVdZU2KyYqJwhfUM0XzpvK97y\n6cMuRQK/fWffTixQd2vJyGBpH8smWmx14u6DTsX23QsYNVzGpizqwyGxY5ni\nIEEb3scoXrC6fFfFb5LhHGUlinvw+2zPZcoLpCTSZHWgdMYsxZ1TbcTZEIA/\nnpog\r\n=9UYi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"332305d52384a53c44c97739cab649078fd84e9f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ec257c6-1599067281309_1599067345132_0.0157425080187803","host":"s3://npm-registry-packages"}},"2.2.0-canary-ace7e2d-1599145596390":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ace7e2d-1599145596390","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ace7e2d-1599145596390","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d0c19bd05ce63282735cf626c4b04c481d1acfde","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ace7e2d-1599145596390.tgz","fileCount":26,"integrity":"sha512-YhvF6M5MRWl5sA2v6Qmb3IP9wWub4B1VOIDM/Fp4leLZuj/E1GSkGoQ9P0/K86qKYK6vOw+b4kE30uLrijw6ow==","signatures":[{"sig":"MEUCIQDb4Y5wEo7Gldi94/UTEZOEv1fXDjvJM667+JmENzposAIgbQD+DU5vxiaPMrcWD0pdHq53daec9viO4e2q6VYhW0c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUQa7CRA9TVsSAnZWagAAKN4P/2T3jjuY1CkIrDb8ZsCO\nUq0zr8bE1txy6D5U3xjikHLuwZByc3bxAZws8fJtFdZOaFGVlhom6fzegd4R\nr+OiCRNTujr9uIdsjLSv+5IQNuebOXA7nU/APW1/+gm/ap3+fjDAL6Cz1C5w\niNDQ7T4u/u0xhRPcgBf4TNb5bSy8EK61CBjNPSWUFwhpZ1aAbO6fRpsIgOTL\nQd1XpRV9u9/swimkKG68rbdIZZo1jzjjffYjXQLuvmnbK4qI9YbNztDuy1v4\nfdoKGTllSF7Vcm95HZ+BiwhwK57SYLnoc/0mwUYMBkfi8P25NhbzoKDnPiUU\nOaLC/Py2DN3yHLwGJyIKgul0geB8k2Fcz+JqJvzGj5A5xzOJQUN+hwEBiUQG\ncZkU3fhjRs5GZGSyzfAOvdctR8eDqjgupNDkgwNg5QD5KFc7ZQA+Expyoc4Z\nMDUCgU17j5x5IeoInW0+kPLCH3tamtw0KpOrxgpuPsoRi1hQ6Yv+mAHZ9PW/\nEIs/r1HH97rPST3k8xgz4cCz/QOj7yze2R8u9KtnD1EFAK9lISZLViWaTHIv\nWzhc2MAMypOHdUAo/CbyQzGcoyfVNbq7OXveOMEwreTdHo3qZfpUgCApWqaI\nov/g6YMp29Kq+1Q0cxQiHfymKMLMwqINmek0hQOI1w7XETKvp4iwJKHUErEt\nrA4P\r\n=FELw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"db92b62123abeefa614fcbf0ca365aa4fb0f5a55","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ace7e2d-1599145596390_1599145658854_0.7834395149873377","host":"s3://npm-registry-packages"}},"2.2.0-canary-eefb756-1599330130341":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-eefb756-1599330130341","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-eefb756-1599330130341","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6c2e1a5647a80711055d95bd8c003d6f4b1b3752","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-eefb756-1599330130341.tgz","fileCount":26,"integrity":"sha512-nyv6oV8PxIQ0kSV3u6Xpn6mQn0hYMHN/+YsQ5PcZvpW+DSVvES/wh+hd0ZU4eOZgZLZTvN7McAYBX25tgAnitQ==","signatures":[{"sig":"MEYCIQDfFCT7Af+9yqZCQ6Ti1FLkhAZ5seXvHDCr7sjfGNMlbwIhAOaD6bUyAIxwkemERQB7UoIsf6oh0WEQG6gDD9g8REXe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU9eXCRA9TVsSAnZWagAACckP/jCcFfPv3a4D/QIRznsV\n5JLpdO/Ugpuy9HKBJVYIqfy+rpOJ52AkgICx/k7nKDD3RzD8NjqBWibG+xN4\nIcPCojyK88OJNfHck/rZ1d734XnkKyAHEwjeWxDkvIRcTkXYsb6k4Nyy3e+z\n+9p35UHB+eMD8OnPpj6nEEiEBMqdGNZEMZt/Hoh2QNuplJ0kS3FuJRnIxwum\n3bGltP+iOntMkGih/pJYfD/oZXCwV3B1qH1rXL+GZTZ2bEUL1O4HCeX4yc9v\nLxT0vcFRx5OSc7250/k89rnSKApc5wnOefwcYnZQuJJ3rQUmADmr41l6UxE1\nx/OOKdmfrV+iuOyPFB6xaZ/ChskIVrSd2oqG0YkYujhhlLOwMBG8rgM18/4s\nZyyFY7rmpx032Y4Us02vOsFcQf5Nli0oTDFvYQSIaERUnG/9J9h8eqtozyoW\nyevjDxLuj8YLxfJCPhFmzecWnLThtrCxtJCuawifV0B2LimXR8C6FvtS8CEj\nsyaNJt3Gc12lq2ncw9B6jjcwiqnxnIkN3D04v76pLATRHQ5E4ygkucax8pq0\nWe7NQK6vx5fxisIxMCJRRXZpV1ZDM05VgomZrkvUvBJL9EwPOc3epsXXC1UM\nyCPE6JGJS6j0ta6KriDqjDLH3dgKxGNfqOzXkfAzNAoUm3oisr+6bfjSnwev\nBFSD\r\n=2yaN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"cdeebd817a10b4edffcbef60768005f2fcb14efa","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-eefb756-1599330130341_1599330199481_0.16512408514392996","host":"s3://npm-registry-packages"}},"2.2.0-canary-5816317-1599339862432":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5816317-1599339862432","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5816317-1599339862432","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"38fc2f514cf33282792f9db6575c9a5395f9e444","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5816317-1599339862432.tgz","fileCount":26,"integrity":"sha512-HGKYc5YjkpR2W9f2lTsLUG1yq5pXlnn80hSopjWCm5S1YgLLCawibPfKjugfSBt120L4lMKHTHEEgeLqPV5uxg==","signatures":[{"sig":"MEUCIQCEsp+pGZnwIVcMRAQ6M7EtCwe8AabRCsn9nHpbJUyyswIgRsYIBtEK53mb5+aEenNqf6c0aYNH8V1LLvsmBg5kF/Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU/2XCRA9TVsSAnZWagAATPcP/3KERB1RjvbUqDwBhAw4\nLxqIoevxWZLz5C1FbkywIQiqHqbzDaRLuEo4597mUBaSB3YNesv3J9HOWq/c\nW1gUG71OIFou2IsJgrqBYZjfstRdKxcJRpyf9b6VnO2ZgVYq+D39aYGkhETR\nstzrfMhV920KtGmIWTRLRdpjEAdg7TB5H1yU4ZEokFqcTQjOnMe0diADA0Lw\nSgORpbjSq4+3XFBsSM8dAPQlpmzW4ATtOqJb4wtUFtVx9inoE3n08TvofGBN\nVxaeS7vojWpNajpW+r6AjoRv8p0srRZKqw+BDiP1z2a8uzyU6YmfuIYBV2jy\n2tisqMWDJLWRe/B/qc6gp82townnCkCqYasecW+/aEOfKLbkMXIqHX5rdS1G\n0gHiLED7afZiArP2z1N6nmGOGK5oeAhRu/vCDorXwpndJvpwfid0yC3DQ57b\nmcmahqJIcGB0Y35dRo9fMKXa+rjrGAMr0gKPN9XR8Md5djgt9GSx/COSrh2z\nGNehBdlwzoMyJFx9pGQuBs8GIS0r6iV8qfSUV3Uy2EREiHK6qLqfGvlGlyKA\nTdImL87Pq3WL2NFhmgRCMQbrS/arLWsuJhpofWbyz0tN9CNeC5IWwengTbgT\nPBXznkjeXwkDu5HQLC66yqF9NqphQ6T/iC03nLFbrQobpsBXKSu/V2/pemkm\nUJTO\r\n=U3KI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b53f70e8de929c36ed5c93eacc9cf404860ac391","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5816317-1599339862432_1599339926940_0.5532805702039683","host":"s3://npm-registry-packages"}},"2.2.0-canary-d5361a6-1599936618101":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d5361a6-1599936618101","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d5361a6-1599936618101","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"14c3af3a5a79ea951979f7a57d57df0d3dd905b7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d5361a6-1599936618101.tgz","fileCount":26,"integrity":"sha512-dk6xVhrvv0FBaTcdvstntIk+qkl+j6lphDru2+6Fb90YpAA8Ga8YIwaG4Xgxba5DPJtgnksGK1ohKuvdCKaIkQ==","signatures":[{"sig":"MEYCIQDNioo276QEl2p2QxtIezc0NJ8Pqpjw6y+lJFpsrJF1DQIhAPPke0YM2HLQ+pkUWZ1O9tHFf6Dq+HrFBZbNTvFFcvVE","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXRivCRA9TVsSAnZWagAAxOoP/iFm97R+yIUo1bvu3gOC\neQPKx353sw8vouxyiM0O2GNX8tpv5OCb1hdr2BjWLrepIv0fpOdANPOXKuUK\nThKntSSsvjrDwpi6XaJpq18o7hFXEHrJ5yrjimaId0jtc7ZgArbZEWoiluin\nDjzTqhdKU/jTkGbbIMkjeJwVGlI44bwzgv6/gFjSGwSNaDb9YpziyY55eM2l\n/J0HKJOOR2ziAYgRLTg5ZnSU4WwfYoMU/01IHyJs685NH9ajWkYOAfci+CdO\nZP7R7X9CuNAC2xbuXEPPaqT3uNQERxWKnOUa6ay5COymIxuy7q3TdVKCKRqv\nfhpzTCnC/AcT7Ef/ps9QJDZUDMoSTIn2U4JvWLAzV+NaDDyKboxK9jJ7htd4\nAsZfVDIjKyMotVaaSg5K41CFcHEAvaxcpgRaQxnGszgKSDbZhfdhqp4liPLb\n+JiMjvguJmAonL0QQhrXHNf5bo8tXWd0vYQhivJw/MsxKjJlfkGYgip+G3kK\n15m9zVXtCG/TlTcdd47G13oK3OgWXBLusreMyHc/ntPbDH11FaW6f0LwhjMi\nV/AWsm89qfu9mUnQN+QFiBXyGBbIRr27i0EOaHwebTpe93xHQYl7x+na8ueK\ni4iJbHyMdaVWDlxEz4ZGYwErtyFCv5DQlc/i+CJX6bt6xvswFXYnghVhdNjn\n9ZHQ\r\n=iMxm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"43290707e9f50f14d05b52a9c278f6021d285b9d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d5361a6-1599936618101_1599936686753_0.9822584153069278","host":"s3://npm-registry-packages"}},"2.2.0-canary-9a34bdc-1600350606914":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-9a34bdc-1600350606914","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-9a34bdc-1600350606914","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f6b84a34aee6c04e7d95b0ce961451cac06de234","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-9a34bdc-1600350606914.tgz","fileCount":26,"integrity":"sha512-it2Zz4jcF2DEPFxI3po2hud2nEciPtFKZuj7EMwJ5IQVkVcBx6nMkPRxu4Hxpi37i4zyEN2ET6SPYVLOkvVEFw==","signatures":[{"sig":"MEYCIQCaRYG83NgUEKNzx5i0smz9IkRjQtPZyW+FeYowfykVQAIhALQ4pTYkns+6GnvgSCM95SpMqPE2BvFAuh40qaTFOqVj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfY2nOCRA9TVsSAnZWagAAdpMP/i3aae/PpOqUoMnxjMrv\n1ASufnJDxzleExQX9y2Z8VhLEHBCPGt8DyV9Xboe1EcfiP+gbeajqexorT0r\n9eH2Zk77V9oMuPJFInB1+v5HtyFnMJBqK2tdz2IN79BZxID9z8iB+St+fz6d\nnScRedSCoakMcy2zdFxSgv6LRFUm5crLlBXD9NwicRRol602aOhlKc3eavI9\nK5xs1WGL5pSfXoUjULPPsH3ayLkDloRysDBkDfYlzUW+csDVO9qBRfnA9e85\nrFdCkHvF6r/MnxBHKm5gHC8yw2fI1pcydMwXUYBnBf8/ylDMJNaQEiaOnznw\nDGPA4WjNqstYd1ueJvcMcxtchPzMMWY5ecd0oe7EkpN3DoMjWN8Pii+5lT3r\nCArBuxFmnzHnc3kaExj+2lIeGQ7XeGRaHQEkbVtxxR2XBkOsIadKLrKQQ0Hj\nLndPohQ8r4kFX881mBbUhE+RWNcGMjJbVmePZcVQwxXHZKlhH/KfzeK/1twJ\ndJLwVk4aROq454cl5AEoQFSa0dA9LIfVqldI9e/i8qP8s8Yb24MQG+bNa10E\nuZuab92FSXvh1ELLRaycjNCBu0PR9PGpcMP+FangxN3PQymZWrbvDYNq4AHM\nD6qtmo0WEEnKul5z5j4URXp0qZYJ/+x6/Sgfr+CZ129sKJ0pRKDYceflmLys\n0dhN\r\n=wVew\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e6d5addf163872996934e32429375d84537489e1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-9a34bdc-1600350606914_1600350669613_0.3725842886357478","host":"s3://npm-registry-packages"}},"2.2.0-canary-cead4c5-1600527308695":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-cead4c5-1600527308695","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-cead4c5-1600527308695","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0b5498a3993dd03d3cb8ae9cf577ff254718ae01","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-cead4c5-1600527308695.tgz","fileCount":26,"integrity":"sha512-arybgRE2Gi3z7xBd/mQahyqW05lRVzNc79eJKvwYfzgskXYotfYGpEcZ4cf4KZlE95mvjzQYQUwPtEnOUEb+VQ==","signatures":[{"sig":"MEYCIQCm9SEVSeOFRiLBbmSekdeL6KP1XyzlZS9p78swpJ6+pwIhAOq2nHfY8tW8SgcWFmsrGlqcrXynBR3mdsgF8Y0HqZNn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZhwPCRA9TVsSAnZWagAA6KkP/1q6e/ZAVCzDzs4Hwc5u\nT1dWcZih/loWS66hNHLLzX/0jf4slDUP3tgnZqak7yfjTNn5g9fOT3u3mRlb\ngXAUszyZaheRcY6rmWv5G8sIEyNJ8ECH5Cwi9KZ8SP+AdY+vHTx3kpseK2kO\nt+nbxKOvgGEOZWaEgjTfvN/mIceS4r21QAEYR/PE9qRD442PMkTdY9dY4Fcb\nsxPOgk1xnNd1ucvaGkTkzB2AWUN2kajpNAy0Ja4pfvtoPXXUem4b56ZmajBa\nL4l42ERc8IK7a6OzJB+M5ZlLBB51XSB4eyFnYvOgK5/tzGJRj0QAdJGwxsgr\np8XKu0rLSQvrO0wPt670rFtQESuJvarqjW2vNGyu7wkeMnOQSKYCMGhHRkUZ\n5x0vMX19+gXBOdyJOP6GmxRJQLSl2IOK+du6QopNjniYs++PP0oeJr6kPXgU\npJ9uACtJbSqSIaQuY7ME+K9biHtOXVat+8/tijycJk/vR4J5AVnxDVtgiOuJ\n1dK3xfQBMzuPiaN7xMeoPGSWDJwkWePI4J3uhKN64rQs0mOu37/jvFXDosEd\nRBrb52Uc/Atsh6lE0xbCaAb55zs4rIHAT2KMTaLA6BYocWMhd+33627L0XQg\noPWUSO4sc4HgPIYx4uh2tLBgG9e2KreI7/tIio4EdnPqm01PKQynymRxh5EP\noJNj\r\n=8D1m\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"501d0fa236062e1feb5b18e151ebe2936201c1b2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-cead4c5-1600527308695_1600527374698_0.8949143686674448","host":"s3://npm-registry-packages"}},"2.2.0-canary-75545ba-1600599376904":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-75545ba-1600599376904","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-75545ba-1600599376904","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"68d7dc6e6a175ba63952c82951e8d9936224a756","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-75545ba-1600599376904.tgz","fileCount":26,"integrity":"sha512-gfDdulvOuRnHtyXR4ljadFAqjGpCcqawQETuMYd3Ct5tmGd3gHzeaZdHU5azmG2BmFc7pnqTe17v2alutjuK7A==","signatures":[{"sig":"MEUCIQCWFjfTQ8pZ8sus+NJGQC6Q6L6urc1rfYPdaG74iC2PDQIgQvGL2SgScD8Y5huzU9+n1Q16FBtLjiV+pYAygrr0U0g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZzWTCRA9TVsSAnZWagAAkS0P/09VuDfKx9V8r5EsXBKI\njVp40icvGKv33bgvRLhfWbQc80/w74cSEV0PqYtlJwu16hENB9vDCR+mmpl5\nufYdHZq/dCm2jaNfNRjn/5J7LVpGc/vOHj4ZHoxLt1OY8FTefsTlkHLTPFz+\njpYMATm0vgIQwrP8McdsELCkvuwyX6gBJDl02eJoIaPri8PZUWbXlSU8e+zQ\nl4xD7iJeJLybGLzzDa+pEFx6XzZKUH2edzKdy2izss3vdO+VdcQdUG8UoyxG\n4XOfuYGk1xpvYF900TVUY/t8CdTfjrdFg4qPBTO4YTAK251OJqA3Dp8sSbgx\nGUICOemGuxgOKZiTEwWHUqP0UiI3mhWtseN07IuvPQ5kNNu11/Vokfob2F40\nCjvq8veOS/X6bsxu/oQJ6lyYsDV6oLgYGRLQg+MwpBg2yRCRhpoU50e2qf/G\n08uM9nlFLsEZGnyi5UOiQIY+v13kqpe3R7VrVap9W6K4WRuj6eV2y/ZnyHs4\n2ETmedYJcQiJHckmHEtd2cqe6SaIS8SnFgmqu5STJ4VIjMxfk1PSJwirgV1u\ncuiW4YzHQ+iK3UmeVnLGUAM8C66Kmd5+UoqK6JryLlDbNJYltyIQMJ5yq53D\n+VCF+lxffw49Um2k+qYdfwLM0s0i+2VKQ1QxvAPP47C2kxe3lofoThiP7JC4\n3hFS\r\n=K1wP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7983ea41f699cec292c42d2408c629b934624f42","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-75545ba-1600599376904_1600599443362_0.6530738405670331","host":"s3://npm-registry-packages"}},"2.2.0-canary-e0ccf02-1600653945860":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e0ccf02-1600653945860","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e0ccf02-1600653945860","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b74da9b99423f8bfc424fed75558b81380cffc01","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e0ccf02-1600653945860.tgz","fileCount":26,"integrity":"sha512-YVj+QNfITp7IxRW0bI7kxJpRMDHTQYhW6eW9aguLOA57MdWpidHEoHcLcxJBCOY0ehMMv0YMJOQnEPbWJro5rA==","signatures":[{"sig":"MEQCIBRpgxZla/FAGCF4eO5EJS/aiRDeu9AOgafSD7RF21auAiBWfuwDyj0ZMUGAID06LrQXr8rWe+fIMy68YG418yFGYQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaAq/CRA9TVsSAnZWagAAYr4P/1Sjo6zrfdpvEQyizuTk\nRs9OPA3WR5FZdieyA7LCfZK3XZYLrrbeZ51k7wzkZ7nJYl2JCXAS22ddfcMR\nNs7oeqGYEgwOUjNrwp1OXPqrIW7LFuMDZMspITS8zCjMqZUHTuBuOACDqDek\nBehoUnogXs//7cJx9ThindJp7DFsngOayGFjGjLV7eTve98nPP5E2ZaZhlEz\nbN8OejxYF/qXwpCrCjgmFfIYEbMC1nKvMNKtT1jILGG/r1KQLhgnTeqHHwn0\nztjQRWQysVpYRf8xjyxoaOGikjHtEtl1YlrSqkF7FepqdAH9yhndRmXm/v23\nxlqLOW6yYYB7d0LjWP5t3PtDYq/7pVj8/I+cl9dAwcaZSN2OGGCFX6mf4DMG\nkOgsFxDE2UxUStVfMriKCC94j4mwpXR0m0NonCUpej88MdUqoSkRC/ywbG9y\nI38QCS4RydkUjsKonjVA4C2fhHlibAcGBSvu6LReFG5T8PjjRzEwv0eo1ngi\nUw5y9lld+YOGQ/2BTfOp7lXjwNB4Uoz/ywAcQy5RgYncxB/IcPlw1y4T3g5J\n/a1pHAjqjum3M0jpjaBg+4LYtF9BkJEtIpOxhpg6fpHMIcYsmVTHVRNagmc3\nXRLpRiXfL4uZCLc8Kk4fp5KP3eswzON72IzXKm+uh+b1QV3rDZsgNwu38tfI\nAW2P\r\n=hlGN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2e9dcf520c2d142ab1fe79c24f2c6df62fc092e9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e0ccf02-1600653945860_1600654015335_0.6619270171837166","host":"s3://npm-registry-packages"}},"2.2.0-canary-9906e4b-1600676418407":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-9906e4b-1600676418407","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-9906e4b-1600676418407","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"26cfdfe1f5b7a2b4853aa4d09cefbe3c75a8ecbf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-9906e4b-1600676418407.tgz","fileCount":26,"integrity":"sha512-7MmOEFdBs70S9wnFhjNcNU1KernKkiFgadwQj7rEpbIYdWZd2qvLAcyWzWQR8qhKT7Vj2QNz9CeExcyf9YXm4g==","signatures":[{"sig":"MEUCIQCQyiD9UGZAkRwrprx4qT/i54aO9twopfV+Qbje5mUSwAIgYtbzAKM5KAkjOm3qQMbtzRjwxGem2SUgY1BihmNJVkE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaGJ/CRA9TVsSAnZWagAAwf4QAIIjtEvvGLmz6brJpsJe\nIAGLVHj115X6z4K0cDBSKTA2bAY0P5zamn5q36DoV+aHuVHBNNPweymXL346\nCtc9PkcAQoIPEaYA/vPgaB8i5ocEYugHprd0X4SG6adbza6dYI4/Z4G2qRQt\nYAXjF0OYG62UCR08/ZoN56xEwhpP0bnmYqtXSveWEYM8Z/2abXuVUJ6fvxtL\nPH4aEnbo8oo0SzgsvKo5hBNz67dnnbsl1/CW+oUGV9oHDQw0ey+eN33pDwsg\nmjfZQYOjyJo8J6o8LSP128qpFp5xBpk/EciyaZkNA777IH0zATDOz+SBmhqm\nGeqUEfBcaHu6R2wtClHWdkG9UFnj8FCvVTFT40kQnzLCzFM1mPWHaSIiKi8y\nsOXZ8cyc2w8Ol8suPsifkvV7JhgaQNd1dklWT3jxZl5APIsm4J0m601D8Zph\n/xo3wJgnlSJYpjDsXvMbsRw41bY1F04Z0V8dTRQJVoQdPZpKAI0IaI057tmt\niRQnJ5I8zG6kiO88Q6//91uZRS/OHftINSw2ZxcAidikdsAvxxBS5UYzGZc+\nWQ7mZNE59XaV2mSR33YNZlpBzBcm4cV4JjdKtrMzAHAl9b9iW+rCO6baxYwY\n8FXvBOyWkv/HtK7ksrryiTCS/T1HH17moTf1IQu1hRbRCww9Gj/QlcfaP2On\nXKOa\r\n=s/a8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2bd3682f602015d004ec7c231cd9479fbf947d1c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-9906e4b-1600676418407_1600676479349_0.7766065109627944","host":"s3://npm-registry-packages"}},"2.2.0-canary-8082b00-1600851515768":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8082b00-1600851515768","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8082b00-1600851515768","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"784e9266c1aebdd828e2f513d70e34187e4def5c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8082b00-1600851515768.tgz","fileCount":26,"integrity":"sha512-gwdOWVWlkE9cyrBdxRkNoaA5/u2cZ/wNpYK/kp+rcRMpwMfPk2nrgjg9yIQp2WAmy08jK5kMBMG7kTQE1Oxr6A==","signatures":[{"sig":"MEQCIEZhDO19VQon/1bL9qukd0NI0zUxVLLl4Do2ycV7uzBkAiAJmh5vSmcOVAWmRit40JXmSevXupVqxFIOvuP5OdUbSA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaw6HCRA9TVsSAnZWagAA7zYP/3the710+CVaortbht8G\nkoSB9Lm6R5+aZiQX3nkKjkpScwEgEnck4JwL6S5caeTySqMf1vrq40pcH+oY\nCPr/LZNtuqG9lnTNzTXeTGyzLlbxLek3t/mJTSHZIzcaSHDS8JMfTrHi3ybQ\na0Y4scW8jQJJZmGM9964D8pHIZiEc8okh9LOfo4sb+JLQuHGKOHAXy/9xmtX\nhzK/RXiPq8rvaebFYrjs8kGe/BSrweAegs6hNg/wpAvk69k347qbSOHBuNwz\nFg9xI/7G54Fz/Fl5VvIYALZ8/RFoEetk5Buli+RS7QhwRUWCLPTpz1aL3DEg\nTdUq/u46Hvgz9V0RLNawAfkwQ4A4eEdb8956Dzrhs/9MxMUgMFYvnxLjYMQk\niFT7i/BqsJ43SArgVGfalHksrrfssEzksm5/ISaltGpft/6EJ3s2Pl9Yhw9H\nrPtSAD6D0sB8QUC8QZkMn/ca7xO9XU6i0FYaWAHarzPGvoq0AGZ0DUzbMw+a\nf4t+GDXIIoskJKoRkpVGPVM4YhqgvX5w4mJ7eYlc/GT8YjIZ8peqsYQYht+Q\njFSqvms1EhUvh+yg4v+5cr1sun7q+YEZ/WS96T4ED76Z3wr0G9rhRAq+kdLl\njWCWFr96SfafmVbClV0ITD1KI8+DY5W/9K3lu8AbYHKkLILeZZQErICvCGJS\niSh3\r\n=Tt0m\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ac075a50482ed95823f8648bef9681143249057e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8082b00-1600851515768_1600851590785_0.34399306844092115","host":"s3://npm-registry-packages"}},"2.2.0-canary-64988b0-1601097049923":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-64988b0-1601097049923","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-64988b0-1601097049923","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dac88b8add2830811739fbc3b92d03451527ad1e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-64988b0-1601097049923.tgz","fileCount":26,"integrity":"sha512-ciWO3U0NImUeaq2Els/S/KTVkWPrvGhkdvzvAd2DVdGf4zkusetrMMQ3vx0ak0nIlBO2Lk8ZOlhTTRpSfjp0uQ==","signatures":[{"sig":"MEUCIHM4XkgVmXDOJe9hWNzDUN7CaUPZcjl9Ho51CEq3tihxAiEA6MTumrqaB4SNcaTr/BryGK9G90iOkcpcIwBmFyt9SB0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20364,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbs2cCRA9TVsSAnZWagAAvNYP/3bLGGhFUkBlzyAW66eh\nch2jj/TFP9AuEVkSlh/c+ZsucKKFrXXY8v5/u37qisleJ8zUqQxNvpk6VjBW\nEA7qnsSXbvwyz9tqs6q0AW10KLNtZJmNGV2s1/lKCR9S8xS7OK34UrrhcSGA\nu5pLxdBX082qh1esFWN7cR82eIo8HslIa1DfPZuXRviMHMToxl0jw9sTmvBH\nI084oX3D456w50deUYEM1lPw6iXoALD/lh+9M65kB3zYfE8gb7mWAnlcYlKF\nMYKjFFt5c7HBo6iv3jTrr4e4tzTF/SoALaD9rrg5/ZJd7no46JjrE8Vp6VcI\nzgz+fKKa98k/xS2PFH4Alqwz85UlXE1RkXQJJ95y4hkx/x0wVNb0yQvS6IvA\nbw36gFf5AMKoncNQR0BaHr2HQ2XO6NU7037g6O6xKCuOWuEZssjl/HAqoo5V\nW0cywkC+UCsOJ8a0CBF5T5TKsMzsZ2Px1QVi1XoMYvhh2v7xavnQwZyGA6Qa\nxGdtljnVFg9E1W3S88nINX0k2tXmg/DXUUfvM/N8iHhl/1nL3cyrBYn8wvTI\nfF0end1Xp3WSVfaCX86Xc6SmY3txwmArpgvOm2/a28ywQc6MgiJlDqpCX80M\nyD+iIpBq7Ao29RMtGQLcHf0+EtyvNXl0Sa2PPFh9QKyIUiMrcOFxxWXXHKsL\nGkC3\r\n=NZWS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c13987b25de08272138989206b28a006b41f201e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-64988b0-1601097049923_1601097116102_0.0799692141404853","host":"s3://npm-registry-packages"}},"2.2.0-canary-1357c1c-1601158597097":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-1357c1c-1601158597097","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-1357c1c-1601158597097","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ff45c152537d15533700a8754c3d72d5f2643ce5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-1357c1c-1601158597097.tgz","fileCount":26,"integrity":"sha512-6b2ywajwbI9O/uCW2HoQNA2gWXbwaqNW7Sw6d0JCKyUj90nRaWZQwG+JZpQ1XDBgtXaEcc+WWoRM/dOiX0Ok4g==","signatures":[{"sig":"MEUCIHhIkbXLqJ1MJvuNfeoY6MH6m9zSDgJdZOjuIBuRvhdaAiEAyN4EBzd0y2SZcGFgob4O2XggFmLxlXYfDMSoZwviK38=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfb74MCRA9TVsSAnZWagAA0SAP/ipfEdhFmnMpiHqssFW5\n5Vyb4yCkb9itv2ltzZLTwOnphtbX0sukVITL8KuPOqqQy3ebiUJKctrX428Y\nAEhwp5qMwwkACncdK0difnwHUGiko5VWvjh1mdkk6qS9FqMynn5PlZOBmmB6\naQ0hm1T2GrJk/lyEBvnbCIS2OnwybBkgEfwkdZaCCc+6BmeFgajie2NlYyAL\ncvbDYkhucD/0x4TqgnRAXGinlHEXEGxho/K0PKy2fs5JYQGc/zIfGwU4ooYL\nmuex1R/bB81GvmNS2JL/uzSh37al92mNrXFwuJBag9V0VOpyomXy8zDeVqJ1\nsx2V//a45VB9jXw0nHsyViyAIsRv+annVNJEUbrG2kLH+aoDqd1a0Afp5jKH\n6NyTgMRnTNNq5lbhVjuXLDr5f1UFvPLcN/QmjFud/t9TK4zX7lApW9K3JtE3\nogl5JkOrmFMNq2Rsd0wByEZaqQXA0KedoejDa/54ECw/AJEeIE2lTlYV3GdT\nNBXX63EnkJAuCA1d0x9SZRhEkEawcByNqOI0VHGMzvDfUCAtbrddeOiQqQ9d\npOKzcaL7W87ru5tibVkjrjArNoUTBVR8W/+Em+3ReegemeauQ93ljqd/y78f\nxp/GoH2TMvH8SwRnLTj0kTHtLengK46lcGkVOiwARs1vO06F/hHJ9Tx5h3g/\nKxA5\r\n=fE+0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e621f04b7593076bb60a7a955d7d12fc10263fbc","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-1357c1c-1601158597097_1601158667945_0.8775732130020504","host":"s3://npm-registry-packages"}},"2.2.0-canary-424b205-1601460320654":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-424b205-1601460320654","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-424b205-1601460320654","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"61a3d03a6019b9fca205797f9d3dacd14f561620","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-424b205-1601460320654.tgz","fileCount":26,"integrity":"sha512-ykW1Qvgu7BRaSnZGvoCzfmFehizSw8zYJEP1SyCAXGsKjdc/xT/mWljVRqTonlPdzVSjVuFFa3gy4Y5ssN25tA==","signatures":[{"sig":"MEUCIQC/6hECafuKIQ5cb0fIMLK6ZYJQuj1a0+HvM703Bvm1qAIgKHCVYcEUOjVx4J0IUMXEWtwE4pA/UPF5dczmoTiUkqE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfdFizCRA9TVsSAnZWagAA6A4P/2t6iF1utpq+0q6tjIMe\n6EoEVkKXDDNPpO5FBz7ocSHcAXr16W87EopJQKhD9GLNpdrvRZVZ3sLNRs4v\nr+1AoHz7Qs1DlNFreL/qBujykNNseG8TEazoX9SQ4zvsxY83MDLTo+Vhwgcm\nlprDv4fpzZw3pPcrA8U5cyi75Eq1QDViAS6+cz6QXHXsIe9VVvbMSFEBmPx0\nIDt1yLzvfAVFwfrteLn3TKgIYfX3ebTgQcAfMlQJMZCaJuTF88A0HYUpGWD4\n1bL5F9Z8E9WXXpE37fmdq8tMOQAiBd3TYiJujyYpRbX9NxOVmwPwshkId6Qx\nAJQMNaQ+ANUxVBNLg9ZO0sjrHz7kOR8De2URW6dBmp39+YHhKkyGwgyTGL0T\n+Ld51uX2QQQjIm/qIkOgbWGE2JA1XstBwOHq4Ofnxnegxl7zDDynPOSVH8Br\nleh9PzfGD2CdIHyiABowXh82CC/rlRij0DnWwjRemClV5KSOXW14NRh+OgaK\nD3QDEKNY4mkdvzopjuhag6ZFrenw3eYdpkk+WF2iRNGuFeCnpiETn8d4l3s8\nF+eGn2vX6Lmhpl4zIS9jj5jd+qkzSeC3ToV83puF162NCDeThhAJDJLyyux2\nUds8eHw5uMbEQvw/1AfJvNTOQYRawI5fDZevhxCeL/DrRfF+9zbtGvInDAr5\nQftI\r\n=vHoT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"734289455e2139a5d1a90e8cd79e8ba678d21d31","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-424b205-1601460320654_1601460403141_0.4138856615238107","host":"s3://npm-registry-packages"}},"2.2.0-canary-3a77e9b-1601949813195":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3a77e9b-1601949813195","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3a77e9b-1601949813195","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8ed0803482e687a4d4d56f3bade0c00bdfb16e28","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3a77e9b-1601949813195.tgz","fileCount":26,"integrity":"sha512-dSj6tAznP0JM8Z47nA7oJ1K8SVE328sl57d4Bd0AqcSbDz83Ore7PJlY7a4YttuUiGskwvSGl3Cpkhnr2+PJsw==","signatures":[{"sig":"MEQCIDtsVNaoFSSpG8nnU1XtS43PykLhw3ZaP4pET3ufgFMPAiBcj70bPBuUkjgNYQw+0/+uZPMu4sOZ+XQaqal1jv/4aw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfe9C5CRA9TVsSAnZWagAABQsP/2x5WGpbfxfwDvXOreNt\n4NgG1LVQukNk6P2a8bDnJeQYSiwYPD6cvGBxIupg4X4WM+PtpG8jML4LrHAn\naVDUoLoG6uVB1TqfaGmtGvxKQrJ81amnf1tRIw1retLErKgDbxnU6bwd5P1F\nEFkGNSeLr1ov4I/DN7QxVa1K1+lX1JnWR1EMeu3FYKwdihYmVc6yaFzkcp7q\noLJGj4l3Ea7brNuHfiSiQo0sCK9E4UAnh/7s2pAdwzhli2WKcrUdEuOjliTf\n/6EZbrJr5Nzq8VBranPwDfXkDl8kYbb5DIZwP0wi0W1fzKeFulFtfFBXz+Yf\nSkrGIJDEOWnEvP89KkoeksTVlb3jvMuEGN8TRc/0KrUb/Wufcy8Gwt0BrLT+\n9pYzcGHzYCYIytc+IcbTs3c3cXGckurJt3Rb9Yh9hV0RXh90Nio9fQfOw/b3\n5P5EbvfZ7bFLxUyvmEL+O0/dYRh7Mq6N67FfF8srCftMA+oRGI1SQtGc5qRS\nwgIV0m326zKikFWE3tTnotZq5aaZQlQNAANGIF8WndG57Wl1NehmwgneN197\nHqtKP8IA4wS34ROy8Cx9jPlLoPJ20erPFpgeUn3p/9jbKJDpzuB1URwLxP+s\n73edxrFMGkz8GniybR0odN43cScufv5I8Iy3vwRCNt1SfGEY9IDTw8EoRvfo\nhZNG\r\n=PgC7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7ed3767946963895bb2d8c64cf98dff739a352c0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3a77e9b-1601949813195_1601949881464_0.5504410749587632","host":"s3://npm-registry-packages"}},"2.2.0-canary-ff02a2a-1602085084447":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ff02a2a-1602085084447","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ff02a2a-1602085084447","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d0c4e2f16001c2557324451556835903332e5595","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ff02a2a-1602085084447.tgz","fileCount":26,"integrity":"sha512-Jq0vrt0clrI6dY7eY6WQSqPKAeg3D5nhY1l30CVr6NtXH6Yiy6qnnnD2N92qZ+ZGotYvHloKFgdrRHrbEzk3xw==","signatures":[{"sig":"MEQCIGWAN/iSIABfYodH6ZD3XA0jgqb8nWZMis2mLg4XjsBSAiAU39aGpEtw/+qfCbhw8FYwIt/Hu0VyY9wIx0x9bB1fWw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffeFeCRA9TVsSAnZWagAAjfkP/iORRPZYF8RLa2k3o0uk\nOtHu51b//1g7Ok9yJChBCfgr5h6n2RNwGsFkYDFozB22jp23Qr3YUy3CLkuX\nXa+WLdann4aZ9UsCS+7xFfIhvfVvLIU5m26oCJK0sqrHpu8hVkWqTfelkmnv\nZPUODOiRaskZNhFqVTwRCdEwXxFSwCqalLlynB/KarUV8bqOsXuqFySxcW/D\n9WPmGzYdNr/4Hxg77Gdqy93EU5z1mJ05zksCAyGSeWJeAiOhENBXQVB4nNm+\nUSIJctGsBCMcgqynqIftcscAxyrSfc6HZ+vxCkhvpYj7WE20c5xmaBLeKbkZ\ns/SPaI3j99HMzeeCGDWmXfEPE8CzN/y2qy21tv8ytDoYoBILUBFjXtxaVyPh\n/qj/yRtzByRioL28obnN1RJ5OTKxTBTFRbDbqQSc/MQohe/3sc/YNehDorXG\n2qvjSL2fqmVNPU0fm8U9es/Eh3dFissCYL0j5uWY59y9kvTKkVHLswsKjj0e\nHHpI4k1RnA7HZ2LeRYc7HADNJmh/d1R3D6oBB7qrdRtrXY5PaXz6n3+hNJzk\njR/cGW2IfyoVMOLOBXP8PfvZDuHcX7mdEFZ2gAMTe9jjVPmtODEmFa8Lol24\nnbjiwun0UaO8kme7eTP9JunxP3cpqAriTSdf9y69K2HliejYrp1J3bSbWjqM\nMDU6\r\n=nerW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8104330a53005fa9e9cec0757dbb586821339773","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ff02a2a-1602085084447_1602085214066_0.41857407832780535","host":"s3://npm-registry-packages"}},"2.2.0-canary-0d89f0a-1602101056776":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0d89f0a-1602101056776","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0d89f0a-1602101056776","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f3cb68324cfd43d225018d26ec5ac172357ea1b7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0d89f0a-1602101056776.tgz","fileCount":26,"integrity":"sha512-EE+7XvCYjEZnW2mieYPdKus5oO0DONq6BxwRHXvmyVTDSxwDZF9dQiYlBUsUBLy5EcTOvJiVpBM4iB8XIgFQgQ==","signatures":[{"sig":"MEUCIQDyO7ZxS+qRgvLIX958jz10hYnLfsWUXeiH9mor/awI1QIgWHp+NhqyAeHkci/Zvi+KWZIt/KIu9fFiUlk4ejMkXd8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffh+GCRA9TVsSAnZWagAAFY8P/2z7ZzCsWpMfEwHxRdCh\nuIRmEpZ3MY0svqxNHEigF9CsoMMYVUNCZONnt1WYbhloDvm8TYfOdsHekHSL\n15WdILzAA2kJ52UTMLdWokVUf+URDF5dPEyZ/gHRGf50lxcUnS4PF+kEqA6+\n9u7IUHWWhMpU7IoPlFCGVOQtuyFlm3EveVE6hbTx2jOCVrSrApJYSZl3PyuR\nWsoo04Q5KmOZ43lZmwTJxqJw1mxsDkXl9vrma3boY32oYh8dd8Oyl6C8tlcW\n5jHzepotaqcir9A/pqJ88dLERUz9tsZbrWTTjlV4uoUQG4TbKl+aq2KH44YK\nyrJ0KOAcOeHe7OThYyJi9sH9N9d7KW4RuN/DAqhCwJXjctTaC+s0btLVLa7C\nHiiPqj2ZYlf1mR61Qp2+nYnMbTNyaA56+xnF5j+4hh4EgSwBU+JuRroiaq0j\nBgknh80qhbDi06ldFxW6l+c5IkloA/SHiomRVRoMQVIixj26qdTVh0HFymyD\nt1l5d05gaLs4vFEoBD5ahIxW68IX5qWalAef9QRIPo2CZF+2QxyDJD/x7Zvv\nFM3EUlpx2wh2kxKvtSYP6HO+pbZ59uLuEhWBHVNK03lTHBUfumNBamc4E6HW\nJeEk9yT1rqt2QxsdN1iD6kPQ4UcZJD5y954u71OueKj8RSOPDUc/gcm2GxaU\nVcBR\r\n=Osuy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"17fba765841274ffa080482be7f87ddb73c2f503","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0d89f0a-1602101056776_1602101126148_0.029820802307018557","host":"s3://npm-registry-packages"}},"2.2.0-canary-8ab439f-1602243060040":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8ab439f-1602243060040","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8ab439f-1602243060040","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"dd8a3f27eeddd1b4030f7a549fa75da918ce34b3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8ab439f-1602243060040.tgz","fileCount":26,"integrity":"sha512-NcrV1lbV7tb8Rqzx3LuCVbMLown0wvGJnvRv6woBkowHFZ7hkc40SC4JFCxrbBAeKISBj6J8PZl1Oiuvozn+OA==","signatures":[{"sig":"MEUCIQC+gV2Bh6eXF8fQk6D/7C4srpI0LGLm17hgOGwPiidvHgIgNiSS72qPWL4ktB7A4WUURBPS+HZL1cBEqQciDXV3GX8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgEpDCRA9TVsSAnZWagAAp38P/0/vbr3ZhYvLlE73dNn3\n5rcvrWAiMqws+DwYmBGmpYwdQU7BOUwx/C9Tl63q/cO5NjfsBy1c52BS/4VA\n2+xtWWPkX0l1O6WnHPPLuIs02xzg6Vwjpb5KYRSv0hbEMyhRkhHd9f93P7ZM\ntJOSST5qfsXt2Fd/qf3fU9hpOR10VtcFr0EyqhQaZ7+YphvN/10KG13KepzZ\nE7hAebJUeMEuh7en9BFgogk2XRBLCIaiw9ecHCGuHlJFhzqT79f+DNwL3E4b\nFKdBJyLd1X7hjpJQt59UXCUQpcyFBTXsujqTDOUEPqhgrgRcfiP5ECxZewpF\nigsk6sX2vfsSKLIemke+uthS2qBls6SVTCPqM1wPhWwccqs5peS1HM2R5BWB\nKwTZeurk3z7yIMJ6eJc/ya6L0c9v/jlkXCdNV0AmsfmCOqW7cj7/5G8KXDBn\neEIOgCMTn44ZsmJvBDEjUVSRZDu5qM4zSbkjx9BIfaJQ8gTzcuBaDDZbZOMT\ny1UHlWu3bR+UAbV8jGjvQZM4PuxvKtWoVx0gtbwS2utBmcD7hH2E0B6HPng1\nV5zfOAq8QGoEzw8vtSCik2TNzHZRCk5+9MmX3dx2O9A0QZz3zi97kOYDwa7Z\nejELfhTAa9A/yacGX/NOxqik04E2av4cMgjYpX/K+7kYLGLNDzzkLqeFc4Bi\nkLWV\r\n=RPQH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2cef44f840faeb90abdf918cb6a18c1ed39ef1c4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8ab439f-1602243060040_1602243138536_0.8197945107524343","host":"s3://npm-registry-packages"}},"2.2.0-canary-ba2d476-1602418459382":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ba2d476-1602418459382","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ba2d476-1602418459382","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cc8c66b3b528cc56f796710432db3b38e6fd2b6a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ba2d476-1602418459382.tgz","fileCount":26,"integrity":"sha512-SbpzCzgvE1c8YzMfQoQgpB57Un/VXEWAidpM5EUOlPbPDmIvjK0z8Lg/44zcsTo3L6igB2lYEfeiX0M3DcQJvg==","signatures":[{"sig":"MEUCIQCZHaQk/vtHh5fqYG7siXdODi3nsyBgOa6p5qo3PTNQUQIgMZBsttLxGZh5dRWfWTCj6jyebyTzh0kPp1MTduHJTcY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgvdrCRA9TVsSAnZWagAAGG0P/07wcMsYbCyj/lOBiTL0\ngx59XPG9U6I0fpbwPWN5H63F98KRDMGyHm6EhYjfW5ahiA14NhWB1hRm0mIs\nw0qiJcCuKZI4G62Noh5hlnSwQvCre5X1jTgRHodVhgfGF9KkkQ1yyZeDZ//b\n1q+MaQI0ylA5L0Qf/ycNbjZ4GbCIasRBONtEPUPlhH8dDoFXFY8qYHLdYOwl\ndo3hrY7jaanClZXq69hDIt0udmHyY36zMUdA/vUmOaFCaE++HYcLCY8cxhcu\nWHwvGNPqKxy7WGlOKP8hhXHtETB79D1GvtEqrYHHGxofuLZxQJsSf2mIZVeH\nNlsChcqgytlXF/8nkccF9VVwc+YyFl+sQ78FW381kDG8eYZkg9YBSRcgDDcY\nwbnCeYTcXq7xlWh5UrIPQZNp9UThQWanNS4Dee9oAd+bz1LcXTbbquuKPiPn\nhyJlBSlghWncMADK6DNEPuo4jWCiFa6wIn+uMevAQlI75iJw1j7hNX5Icb2D\naSwcIFt8PA1V13bQQWVL65GAsYvJhK3bQWqcvjR+qLK/AUvASr8XuOjbcNIS\nCOsa7oTmNGyWhsRWQjyKuaPSFDD/f/bybSwq90PvW/zn6a9kf15boCUOrdrt\nze/m++jbxfbqaDWwW5UX15cVs8qLoMErfZ7BiVsvT5NT84ARxjOEfFZJr95b\nlHVg\r\n=2FxY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d6e5827226e6db0161018cd96e8d7632bb4482b4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ba2d476-1602418459382_1602418538844_0.06400771670985583","host":"s3://npm-registry-packages"}},"2.2.0-canary-c641b9a-1602422666051":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c641b9a-1602422666051","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c641b9a-1602422666051","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"889547e53a146066b3b800d87514ca1e8d5ab718","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c641b9a-1602422666051.tgz","fileCount":26,"integrity":"sha512-AL4G5cZjbUBUY8RwAPV2tb3spl587FIVqQu0eZ6MpZ4PjH1Xk8g+ZLcG01drMlO1PDcIz3D3vTAQBc7de8QAjA==","signatures":[{"sig":"MEQCIAb4vPovBt/u32e+Nc83J0l5p8lWbfcNQjnPAupQI0JmAiAlBjlVb8bNoKwSkIpgDzYj0PPGWNBTnGYqUYOfWKpHIA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgwfNCRA9TVsSAnZWagAAXxIP/3rUsI6RP1Xq/DebzxrH\nJ28WdOPG7n+x9Dcox2vdHdxcGGIgWJ51xLZDmFT50uzAopQXrosSaEUFUTca\nNyNmwkG8YLJR07t7LJkNcKiFHdrAEThQy9IpV0E8LepV9Zg+nfuHq8gIA6T/\nOTPhmO2GDihqq3efXpNN2yP8q1n5Tjgj4xgwhARNyTBvDeSfh8gItaKTwvsq\nDk+lgbGM9WySctatRtPUmm+pF71tnufOSL5UYedUG2D+M/C66kpn/2sNeAON\n/mY+MaLsJWZvRcy/f+Nvt5IptA6NT0p6HBChMmAF9oAvzu0+gLuNxfKTuOYz\nxrb6Xl03HeuxE1ZqPeqhJsFwdeTX/HiIVgUlHSrChdW1tl9IIOWHvfDaMuA3\nFBOkr4tZKzp+SGAxiVoZzDx4w6noSk1y3laLvaWjuRwMUXYovapsIclWuKw9\nhIusIUQzc+yh0wakaR58OQI6SBMMO1cJTNwpsAQAmX00VLusB5F6B/6J1kc8\nFCaChoF054EoDj4T1BR1kgFFyPSwdjk9VbEY1CZxRxf1iPBiUm+OjcBY3QBT\nAxhGsxSvf5suE21SNJlD08ittSb/ZnRFRhmXCu+fClzFxsUgFvDEwZtDgPy9\ndyrgBy+yfBlUj8npKeNahiRQVV7cyq87/srsoFJMf/dAoFXM6NflKBcyHsxh\nQMNf\r\n=ylVM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"57fed947e4535f68c93064b322ccbefd8fb602bc","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c641b9a-1602422666051_1602422733180_0.5319423441168487","host":"s3://npm-registry-packages"}},"2.2.0-canary-b871c48-1602439602982":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b871c48-1602439602982","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b871c48-1602439602982","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"51dbfa3bc89a028e9f5d1b5f45ed4f7412ca2b7b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b871c48-1602439602982.tgz","fileCount":26,"integrity":"sha512-AAOOPKs9uD815j8xQFs3ZDoMcdmZRa5Y0NXDonxBMmDlq2isYxYPWN28er5zK0c4tmqmgbhE3+hNFpyt7jOD1A==","signatures":[{"sig":"MEYCIQDU6q7GLEglTpGKivH7ko6PGTuCY/XCmUBjtMX2f45ocAIhALE/YW7YlDl0rrS5+QhzN4gSUE46pRnznio6qC8LTbSn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg0puCRA9TVsSAnZWagAAb7gP/0MW2h2omYSL+pBFaZoK\ntVT2FaTf7PZUym5I2iD9LYcsQxa4dX2RdQZ1ei2LyPPWKosh+AdeGkfQC8Aq\nYVKwko9tuIw8/xgHD1UShpyE/lKHCGjGUPbzX0j4xLV41+FAxC7oMtOTaYiZ\nFo9CRLxbdWcv6m/arZ82iEFN5nd5a3N86BH7m6WK0D3CsCVrsgsNRfwUxkZo\nKc0jvd4u7vccBdy/OXnLqEdAlekRnjVho3teu5oFUwU/XYJgo3r4ltdHk5KA\n2GypqCgRMukKUjSgWfUvCM5g3XPO0x4WkZgfLKnE5dB6vPG2OPt1bnAkkYqg\nMuMxyKtvQvyeimVGLLgB+ND+kX73Szy+UYrNtFemld38DP06hyYC1F3SzJnb\nETt1v+vxPY2it6gF41tc7x/XK6IyeHzthyGhYucKCkS9Jn/7JKb1UB1SWRhl\nl1SptWruoqStTO3ogrjYNCaeRp7PayxENPvcjD2uN7nqNSYJFdxfWF/Oog1z\nJDEjKKcPsj362rg1XFr8iAX2qs1iCft7tliT2eYNuE6YznZ5gtPOVTHX6Se9\nwUCWUfYR2rpxREBjrZY9mBIvXaEXtayt749Iv15BJDZ1iWc1YaUzIqTWdcuy\nebG3O42W55Lyax7tswRkeypJArHeoS0roxb2y5asnizldTiqEO9kbBWtx81M\nfb1w\r\n=H16j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2432717084da38d6af315d34ec3ca71d19f687be","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b871c48-1602439602982_1602439790359_0.3219663895389182","host":"s3://npm-registry-packages"}},"2.2.0-canary-ca298cd-1602573899954":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ca298cd-1602573899954","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ca298cd-1602573899954","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5ff824aa62ec9d092d5ed1f098474728f469859d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ca298cd-1602573899954.tgz","fileCount":26,"integrity":"sha512-kuuThCdQRQzqyyGQQNxC5UE85NR39Fn5D5aE9J6BTCTmUbatY0bS4BvaLCqREXSDCyG0MNnK2xXddN6pgOagzg==","signatures":[{"sig":"MEQCIAV7DS+uKVLFURD6jdfyYE+jUmQKIkJ1NPT1t8sigtewAiBN8QE+0oyPYFl3mm0NYevEjtWKzckIzVCNms6xFeeSaA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhVacCRA9TVsSAnZWagAAF7YQAIf8DdQBhsdlQje3rIGN\nJkKphHY5zKBuH8OdugnpU9r/P7AJz4Zx0ce4peN1r5KILc1NUDr/V2n+u6qO\nyF92yPQz3Ez/toXYf4hRauJDXUpsWlv9zUGccRACBqXH+4cRIGMQgv1LQTfc\ncDlC27P8jlzg05K6FGO94jclwE71VOC4A2WcRbdFwQexFqyhvSEcDX3FnM7F\nAoO8Q4jAsoiuc3JcAVaPHXBtjaNXhRaxwXYMQMWIn2Np1FI3Gxu2LAgbXGWs\nXgO/bzPGqd37u7ywOym6v5liUVyM68VWKsK7CxCm6ylRFNXB8nJkHb/WTkwd\nBfIb4XVTnCWD0WuDsNuqdinlgAF/hH8bB9tyuHIpcp5uyXRlIc9f/B/XqyFv\nZGhxZqnDEOCVly9g3FxfxVhH4HEL9bRbooaDQwaHUXGIVLD3H4sL9V5KxyLA\nAhg3pyhEyH8xjhQAkFsEwN1S5wTt6k4r5tBThY9cHm43c3NsZrhwSu5qlSGC\ngxkzF5Lzr7ZOjzUcGWXGAJOAympSg5e1yIFysgzrtgioxLQajSXtlAvwfFb6\nN3/tj0U9R9JdsHyksgJPo4F964TXLsth8B8bxJ8EVrTKsuTAfbiQMRMIoYlb\nXiZ6c0kYdSvDdU638Wsgmx8psKvqdfNAqI89STKLLkmDwE1L7z9tdi/9WT7P\n4Jed\r\n=9nTW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d235fa94114e3311c9f80555bdae9340c2d63a63","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ca298cd-1602573899954_1602573979870_0.13000153495482336","host":"s3://npm-registry-packages"}},"2.2.0-canary-6a364c4-1602694630568":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6a364c4-1602694630568","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6a364c4-1602694630568","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"64c25dd9dda9dc6b122c512cb842da88162a9ead","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6a364c4-1602694630568.tgz","fileCount":26,"integrity":"sha512-EoDVDTntN4RLjpscsM58/Dlazyc7cehgZZv+/tPsOEI0f9iOyXTyaZ12BorBnaxkqYxN8i76KdHXpjgiOvTCfg==","signatures":[{"sig":"MEQCIHHjawXaIwwbRhwSU0CCPTrf/cPdfbPkyB/qdIA/NrsCAiBVGoPp2tqqDw+mEdZK+3BFwaUmOA2mJGbRa0lQLaZWJQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhy44CRA9TVsSAnZWagAAZ5IP/ir8gRbpATMKUWX4QPw8\naMrfkycOeUiJbx9Epok3n91rU+wNXmG5h9k9vhrdW89Dkok6fltrrwWam58Q\ndM/2KWRCpQ4bVe+lMz/CLrS27j4yoA7EDZDTOOH/tEHx8CFzDYnUWyQ8DQkh\nTaibJT9UEyFiD9z4VLAohvv18VNgesYlCFFVkANzc5+DE7h+8iWIURAjqQ7E\nFrVxxfLuU/kqN7JCuwvzopnXwPM64YPfxqH2wYSVpycoDoTB6Yrj8Ahc0K1g\nz0nKpAP5cb3rX+U5UdEQqoDBg7BA+jwf2Z0dTER+2giiVNJarhoWMqsPZwDe\nyBIK9r+HjrClLGZnAUpRXohl2mMmQe9kCcnkpKsrBeMYVjToc6+6m/hzZtlG\ni8Ifj/e0CzWjVCkL3/vSC0oAjqxkzuBjMj73DVkZNvP0Yp5xl9OqM6p8SnLr\n2mqevuNLOmoRvNut3RZs6qCR4AzBu7Mz2MvSAqhR4flCdearrcGyOAR8PPXh\nAeXsNDRtVZrepXBNS8nmeiSTUVaVO8xLZO4T6jBciBFRT8OwrRGbC4sVN51L\nOldg+aRDUhJKiqlFv1E13KBMJfh1vD6Q+u7LPYJn+JPtEKsQtfMA6TDvHI+N\nIOfQ3dU7vOUCeuDLyG9kc7DANn+/o4cp72DfvgJVvhqLC1SZXbHLwrfiZqZI\n/tst\r\n=PqGl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"641c89adc8f2957c45b43c475f6b227fd55697eb","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6a364c4-1602694630568_1602694711484_0.2183533373910871","host":"s3://npm-registry-packages"}},"2.2.0-canary-7c44693-1602796810890":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7c44693-1602796810890","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7c44693-1602796810890","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"34aaf88968c1e2ddfa3ca1335c8156b03f8e4e80","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7c44693-1602796810890.tgz","fileCount":26,"integrity":"sha512-PRaiPG8F0SJrAfKdC+YO9UYQBzV5BbpSD01wPg1vTVd6m04mV1DNvkx2qsLr7CLcqehHYHHJsaFDRMG/qzeV/g==","signatures":[{"sig":"MEYCIQDGwL9D1rve7YPxGzZRN45hpvWnTjlnIy/tXzVK/GB/JQIhAKtYsdJEpbBjsJiwy9iKsN0b38lo5AHxws14WHXtqHWX","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiL1TCRA9TVsSAnZWagAAaEUP/ihK55O5ijRqGF3//37r\nTt5zYPBchI0BXLvbKWG4dv0iVfshJh3X7fMfyivXiR4qwGjbbmsI6P9voqAE\nMEdKRruQSKHPmRLSYsv9szvKxjjtWGqlKDNgelDiQNe3AuEkj6W9RFxuyxrQ\n4kFq00DlxsxA2rITfQIbicIF5LM/3jBim3Fx3woakzp7MvlaFFr/bRtQQEO/\nr9o5yU2dj2oZwpEjTOElUZofnsesf5ok19TlvxH78R0Y36qxkukal+CGSztd\nWIm0lu+KGgOVXUrkN9LXo2vH8h5WKcir6N8I1DXUz7MEu7Kdgrx9nUry7RgE\nEZkAyxPM/kYEuX8DsJcSrqlVIgIxPryBSvyuv70jQRlW+k5zSqQCLMpZhmxh\nKHr5JfgEo1+C2T1TOR13KXqWWfTRauHC0FdX4HvEH9ICpk63VAStEsywELng\nbuLluAgMC0dzJg9Th26IpxXwtr5ZUqtn7HPdxx/juy6VkZVoF+4i1NXLZ3y2\nEbTrzr2AWB2krPfiyGZh5O5vMz68CzoAD/HXoKxVQuJX5l4UvD5iss3QCQ5R\ng8LKvhHIwvQt0SjTyHCIt95ZSYDOM4F1Ww7HpSm3v+e4x7a7FmQmp7A+MxlE\nIlAhrFJ4on2i0rzkcryHQArkR67nHjkExT7wWTIMZLMiqyhW21XnWn+shwJ7\nBtDE\r\n=zDxn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9c839973d33171202be527876a08026a38ea96af","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7c44693-1602796810890_1602796883359_0.020755589024303633","host":"s3://npm-registry-packages"}},"2.2.0-canary-5c73c9b-1602797935260":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5c73c9b-1602797935260","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5c73c9b-1602797935260","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0736b53642dc65fab633bec17b283dc1c779dfa3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5c73c9b-1602797935260.tgz","fileCount":26,"integrity":"sha512-FDhUFNB3cKhwl7BIe9pYBSMAOItzum3kIb53a5GuWOMiI6COPyOZvB8+A7DaKmxksoE9iSuv0PwLD1ZKz6P41Q==","signatures":[{"sig":"MEUCIQCgloVOW/TOmOKip/FF4ZMzIu6A5njqAmdhsb2/ZGdqvAIgfFuPXbjvthtzQ/MNkIRIXG9oAN6RZIsEJdvVrsP/JI4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20365,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiMG0CRA9TVsSAnZWagAAfWgP/35v83SamZmayCVEowzR\nwL0wKq2bSAd8swNfGorIOkLbOhJBk3LtIEkA0d5qJGvzcAFrQ5hdAbC39C75\nbb+gjp3c71puUTdaQFmp7nOBkPh5+A2x5gNRs+pc64agPiv0wqqu/ovr8XQC\nbHnCRwIXvYO7uWwGgLQhh6CX+X3blCpXflxqPLGKc02xrOgYO3HboXg7SaJl\n3zIwuIrZBBVJ5nj82uoZrZjOoptVZOaJvzxzNTtG5I0fHptYFtyyReR1cCfT\nhlOYqxIIxNXwoK+Qk68XRLIXs4TWa2i7PB92lIFN+T+EjkmLWpDvk6pRQj3s\nasHi+axpoOqZ4oUYQA2+oqJ6x4BYz2j7Kle8xbRMHsemgnjQqp+jsprrOH9A\n3m9TzWNmmZo2VlOdaynarqwaYJ0Zsea21CpIIdrEG+m1McI+DbUR8TC10bKs\nugknKfk1PO1rvOXF5PRQ74nqG6XUxrVwzJcVoN/O1AcQNTbsWXkXOPTNwaEj\nII0zU6L4IhcRTqaR8Lu4frtf1uO/l7RhxdG1Bd2H3dfSXC03iw7aRo7WSv8d\nCRKIcFZF369VYbagHO7WVnYYtWLmDoG70ObKcBN/5x8evDqDerBQAKn3XZe8\ncgA/tFeqq2OigUGj9MvyOrh8Jd3qWZGYgqAX4D9ZxGFbv5ExBBch6wKxfDOX\nf9oN\r\n=aM4b\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"36dbe870640bf45ca90930c057215dafd4102b1d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5c73c9b-1602797935260_1602798003778_0.8445439142717599","host":"s3://npm-registry-packages"}},"2.2.0-canary-5e852ff-1602829398077":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5e852ff-1602829398077","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5e852ff-1602829398077","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b2396b4c9700b3bc4c30421baff57190a71aad4a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5e852ff-1602829398077.tgz","fileCount":26,"integrity":"sha512-P9hJL4+ZHvSl4qTvAQ8PpW51x24PXdoBh79X23jNG7L5bfT15wxyB/2paU/LcthjbLuOtxdBdeHU4munPolcWA==","signatures":[{"sig":"MEQCIC1kUyzfpWbK5hqf6IAjBcnDTxXNpRwZJlPfV8A7/KEaAiBgJwD5fJNASvx4fo8FzFfM432b46rnuP1QG0YkV+ce7w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiTy/CRA9TVsSAnZWagAAhpMP+wWHv91NUEwjuIVAWhme\nuPkGWDvsFd5ARZhpR/8jjYgybkeVSGGcvVbUuH7aY7qUW9+lw3IuYZTlUr7X\nfMFc1vFKc/R0BXDqkTFq33/7HTb/N5deIUMRGdCjFvSeFlz3z4R2JIMOj6Vg\n5M0yaElGIXkoKMrpEupb3t4Rz76JFsY7hOcClnI50jLFCcMn0yJXoITGC51X\naGSKJifRWiXkLl9InjzecnSsD3SQk9Q0mYQA68EYgAm9aRhzGAZobct1gNkb\njtOMVpjarEXKeehJ8eg1gSDsr3FYa+4QR1cMRMdp5BsLj89wi2ESYddXlS8y\nJp2Ace6USkz6k5/kuNEEHhC1NTdZx8F4oBlKy6ZwTHQZnuh9uYVTci1QAQt5\nbFMlE6G4Ypo7XHUQw0It9L1NB+NY1sHZNsvNtdTGmE61WZ8ZHQQ8pZLfn7Dv\nKH5ntab1kBJYBNcGhRAAc9MQzkwNHnBsrptx2Ne7tHOfSJOom/gE8IJ26Daq\n+0ucreZdByq88QXQ+YxE4f6O1P97oHhvy66VXQ0RaD1SGUfDzdH9wnwsEPaP\nQf04GuIRtWfdC+tinNfsuQAXl7RTcJ8NG2hkkrkKyFLftKytZ1f/NPMkvA8Q\nszJ0eGeQpG6VWmt/w6Euuoi6EjS3dhMQEF+F8gMGj3se9CJtnwMai/KrbQxI\ncxnU\r\n=03o5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c9fe353526bf769024cb6cd8f9410e8f224fc477","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5e852ff-1602829398077_1602829502721_0.4500920133867279","host":"s3://npm-registry-packages"}},"2.2.0-canary-712304a-1602919186783":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-712304a-1602919186783","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-712304a-1602919186783","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eb0a7af3c277989be35ff95db4502f7ecc27a5e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-712304a-1602919186783.tgz","fileCount":26,"integrity":"sha512-T4ogLGPznMUDYgL9u3JJd4Dy0I1/WezEdwq3PeJkJP6Psk97Pf7TcuHqGcDQP3kVhc70OtSc6YQmJj4MFX5KWQ==","signatures":[{"sig":"MEUCIAg6f0FN88e/CvjUAVmT6K4Bv9orqUwMzxIhaegihEUjAiEA/nSRYlLtELkxIIc634LTLRStodQoAOlRW6wdeDbuul0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiptOCRA9TVsSAnZWagAAK0kP/Rrvjsh3qm187/6o8kPK\nKpaL5go0BuNWK1NKetkNvZHnWFg9ayeNAKPZUtwXWa+OuMJQEKRid/1HdLt4\nXGRWNcwPj4zjbQNhCzP7XGJT3Dz6qZZ/+ZsDXv/yeWSxf/LW9ycOc342vflJ\nAiCPr2/RAcVJ9lY98d/l93gxnbYC1zSiAkF1/IQ+HavFiL0yxEO6o83J3WS1\n6h+mmyTmkqAn3AXzjaedUiRM2qtzGt7MNu+kFJS23/NB5WAgDaP0M2j+NSA4\nJHUEs1F+0NHYp2/kkK430t/h4vQEJ67CBwwGs17p5kyIzLGP4aKr2giSUQbg\nDNrVpdf7RHq3N+8H4FYdiwzqof9xqJgF9C7Uhr6dY+MqO6CGBcksgWk06UAb\nFuJVjkReTqGwjDC0JvYXHOJyq8ZDsW3gtatsQjMFI6uXlSte8AzX92lpiZyG\ntiMaviA3Bz0DDhRk7OzIBAVa/cidK7XgvZLnUz0MS/4uKStj/uHpnYzqDVq7\nb518lDRGlf+lbt/ZdznajU2Pt2rgUyQG8QrIqiVytlEwhsd6tCI/GbPLBwWK\n+bRue2t0VqhyGxuliv250Rt28j9cXgfUf49vwD9eS2lEdhGnJ06Ov1rYjbFI\nDM7MWYscDfPk3Ryn+sReG7vTJj7XC9Y9Hzal+oH445XOS7n+1HL2iPecjp+k\nRX5D\r\n=8hWs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"800647cc694d2fe50c8678010b26f9ed443147d8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-712304a-1602919186783_1602919246053_0.6486797721951634","host":"s3://npm-registry-packages"}},"2.2.0-canary-0aac144-1603030968316":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0aac144-1603030968316","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0aac144-1603030968316","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9e2ce106a2851423cb5d66517f1a963c031210c2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0aac144-1603030968316.tgz","fileCount":26,"integrity":"sha512-YcRIEjmgBXBSHb/G+uRbBrLZTTBk/d+snfpfi+9wfDHpcx64OZCjl9IrvwEBa3IR0Ku4QIZrqiSafi1B3W1TAQ==","signatures":[{"sig":"MEYCIQCDKhDLyk1KmcLdS8lByST4gBFU1NHSQdtydTdYgDZPAQIhAN7+PXJktlPyGkJKIT8v7MkZYobY26yIxWa4kxZutY+/","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjFAFCRA9TVsSAnZWagAArDsP/AsJEVISUmJEvxBEwSOD\n5rSuW860yZxOWFqyHeodVx5DHrxjFUUT2X00CTPBfuBkU2/rE3caoYCu/8A2\n5tUTNPQpSi4Cnq3TMo7Pxkqg5iIMJYL8PgaPlaE/DTt+wSp6ws8eJpha5PFu\ntz4aQaVFrzG/0xfyTOpuESvb0P5CS5bctSxB2wgTRMWPdG4XHj8YLkjYHVIQ\nOyZARSaT2bIxaSO7/SHfQMyzIpFLwudrpIGmKsG9hvc4OpAmHaCnMZezS6Eu\naeL/+3p5y0DBALrPwhmcB+GXc+9qx+ekCb+YTsyY4+gvMftUrdUNrLbzIM0B\nvkaQpSkbBjeggFLhp1A6cGtyoPzPtQ66TwRrM4b1xpjtLi9ZNfpVaMGH2V8d\nrwxCOJg/0GxyQ/WSUYg4XzjGqKkap2P6NapdM1T3TDKOmEDth34wnvbGLTOx\nPQqW8yWF3uCMtzR3qHnLz/OdyE7tydxAC83eXH0L5Tk56yYx3kQs5eDicTB+\nCC5p1tkT/jpeE1HJyXSt6GtZ+kp3HbrOdzsxNxirw56EjT4Hx1vPTLhEQlrp\nNb2TKeDz4/aFON8k4dxoHMlQDQY1sEf3VC8TD9ulBXWTTrLm+GM0wR9zxM26\nlrR0L9QiQi6/nyP45/wNyRDLQWE4lmOytATvu8SwJH2RfFJiBihz+I/Pus0B\nUUDq\r\n=U9gd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"93caa7b122dbe884f0b3a81a39f5790811591a34","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0aac144-1603030968316_1603031044665_0.7124958523182081","host":"s3://npm-registry-packages"}},"2.2.0-canary-4a36791-1603178101982":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4a36791-1603178101982","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4a36791-1603178101982","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"35fb81b7d2d7e38298957713e63cb46eaaab5b6e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4a36791-1603178101982.tgz","fileCount":26,"integrity":"sha512-igf1rzmDwT2skvdcqb7PRHgixDNPKG0agnVWcop6pa944+4FfqIapMcW1WTmCWPPxXNyHY33I5TsZU/eGh2ZZQ==","signatures":[{"sig":"MEUCIG6UmvwaAZPIJCqwRazs39Qn/H82fI43v3zZHvY8990ZAiEA2veOrh1ofPrVnTaPFTjRYfsSY/pJ+i5WMij+MdS9XiE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjo66CRA9TVsSAnZWagAAqNUP/21M4d0ZqPsYei/TVGHf\n8BgHqbyhFX5u0ZIkl+sBseDuq8olnChQVjZMRQVIXJgqSM8jpc93NnpMA5vs\nEVy6er3s4BHouQOt8XOatLEVOHluIGM5qUOUWNVJqSp/n9Bh1+bI42hpm06s\n0nZPYs7Ueiplsckwgi9fVrzLKnZaCfmGBoVALeT5iXxtW2XxjxbqKDURkIuE\nOdXjbwQSqWbvc3eHGj6f+gxF63Csfg7+oDn0invUuiMEg5NdSFHj3NgPu0H0\nxRnL8IWTM/P/LWrkhTLWxkJlup32dM0Vye57AGtVfQPqsf2gscStTxo356Fq\neDd4bq3mEY+zqdehQ9JD/bkYjNZeq2+FHhgswq94sZTiF3eF5wkd3YUu7d+w\nvCHl0f0gFiv2LLpFkO+dPtI6VSWEYgHkWEndaUXbQSLKa9kWN2wf6fMrHCNA\nYkljrVJku6OF/cLDtTFdS9dwMvlAh27jlEA0J9GXWQuUs/TUkTc7+Q4cJs+X\nAghWBHnlJtvEdteWzEg/7TagYOuJ2Tw0YNZvUaVl9P21sCaONu2GKgeJUlNY\nBHnxMziz76pou/uDGDBDq3JcWxBCAHK//sCwZKvdnhO6S137lrVzbqwxa8Nd\nbH3cO6h2cP2CkuSQ6Y4CfZSb4puAejK2BUrdMOFnDRRVEK+icgOhVE+a2yne\nEonK\r\n=wlDj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8492dbd772b0697e7ad67878b55d58ce94daa169","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4a36791-1603178101982_1603178169457_0.0704366403784058","host":"s3://npm-registry-packages"}},"2.2.0-canary-7aca84e-1603293979478":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7aca84e-1603293979478","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7aca84e-1603293979478","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"df5ca963ae099c60d7fe6cb783f751abac263273","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7aca84e-1603293979478.tgz","fileCount":26,"integrity":"sha512-Lz6chiL/F5bIv2XXxFFP9a+v/Mln66tBVkgsf2g+NY9i0z8+V2p7dadWrf0d8qTybs7px7h79LgU1OqvAoDBfg==","signatures":[{"sig":"MEUCIQD1Ilx77/POxUgUR9Y1nu3Lk+IC+0hGd6N+LSNeos+N7QIgUBe7O+lqnGWfxG5cmaJ8vMavBkXNMLvdpw+8HDeV1g0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkFN6CRA9TVsSAnZWagAAM8MP/RvPFajcKMIsqrYenJeg\nKhbVBmQifSxC29gAblQR2QxGUXqOCICUQFpOTQz/MCIgmQ5alBtZlGuPtvqJ\nZHlRRdz/RtwtCU/Gt3D0gqlHuF9vTEo6/Ka4Kl7a7pSM//wA50hRaL2wDSTA\ny/VrjrPShIn4EqOGsd/NGMEs7Eg3ItdrNznUeaNtY+5QKIxpMSrzQgjydCU5\nTBv+rTzE9XVujEvqKtj7f88QtU9ukvGl5lOHCz3IUrY5iSPXpIeOYBqogtIk\njf0YihZi3w2pXI3zec+VyrRIgpSGz+cjDA7eAj74lFdhesrnyI9TQaN3Grac\nI1runzV5UwzLFtrw2izTI/EpXmPXd/uuF718fbG73p2NTp3COY45/Dhe8uj8\nbdMendisFxcara6Of7A3W0NBaJf/pLHTcU6XjkwcQdNknuULY/YbOpTUcc0a\nj1xsVqTavYAS3suaied6T22RRtNJoSYaEt1/eQ2CVEy+2/cvCTDbtiqjd2uh\n8Kxc/BqfkY44XT6ZFC3jUjCkJhcPjlZJfBdcB4SDP0IWLVxrEAUOG8KdVQ4B\nMvyAiMDiSVSkP7bWULg1TAC2U6NfRfc2E0nm6C5SxAo/pMAVXFzGOZGRiTLD\nn7+oXR/O6D3Gv1N+PA3ebEzNtEOTl6o8icV8dgOcc7EEGBF7VTNyZs7YYGLX\nlVk2\r\n=dOYa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"789d5d59de7622ec0b5d9ca00682ff8659cb29f6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7aca84e-1603293979478_1603294074043_0.519612138824562","host":"s3://npm-registry-packages"}},"2.2.0-canary-f99fa2c-1603355675240":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f99fa2c-1603355675240","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f99fa2c-1603355675240","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eb136394635282a2361e91a3cd7cbd931732175e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f99fa2c-1603355675240.tgz","fileCount":26,"integrity":"sha512-Ct630yf3dR1+66sR9siyFdC1AB6p6IJSTDuV3B1oyl/hH0Z4mtyzhGkXkVGf2fMzo7FdiY3fyug3qh7lC2bBKA==","signatures":[{"sig":"MEQCIAjOfLsALweCyoaj2jgX5xrCnbnG6dIf16Rzeq8sQp7TAiAbNYNgvsoTxD9dKrwXhnvuPTmaWie4Axc7puEA6T+dCQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkURnCRA9TVsSAnZWagAAv1IQAJ8rG7Ri7i9slGFYJXAm\n2RvvpTLDitKI99KYc8sZVSHXYkBMiWJW49laDxMM0Cu7zNjOqGlrwr856ZXl\nFJN/5r3MHa8ixKCY3OcWM6e699iP5EHO0bqbJxVzxlTfDWEmwTLZSq3hZtRc\nTUx5NHywGU4ph5Lj5uQunm0ASBgza0zTEA9OUGb0e84VEzfTiFflxtonpFpl\nZuYYzVE1NX9/KtjGGanwpI1MSLmgMD5as0fOC5rkjHZpY4kLcssiXGTdVBkQ\ni9RlmUkPt43m5jahTUgt3jEI+hoa7nUo+msTWXYuomKeS4LEuQROrSU7epy0\ngFziyAiO8rIgSwpMnJ6rYsAiO71fQRYelyJZshRR3lIoF0zdE5laMMrV9xx8\nHFvCcNN6LVabJTolkpxDu4FF35WUHPRKQkq/rCMOm+lt/3REhhngq+bCkerl\nz/QLJRT8JdrhP2NvDAi+E1uXGiUkN1BBYVVR/qION36WVu3ooNRYlUwa3izd\nYyUlYdBFKxo+vIJpTw65Lg2rTl2yegvX4Z/fZWlzR7h8gat01w8SQkejsIS/\nfEkTBKo1pnn8ZVk1/du3WnF+7F5NCe2MFLpNK8+D+ZAa1PbYP2uadT0fwaE2\n6OON5zseR/kDY6u01jcwlUa1Np1H00RmeI2ZBbi1TE7/aKfZdXyV4KZApVe8\nfS0G\r\n=NMNG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"33f4dea525635703894da86a081f4cb8916ff8fa","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f99fa2c-1603355675240_1603355751467_0.38818361994070094","host":"s3://npm-registry-packages"}},"2.2.0-canary-987965b-1603546411932":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-987965b-1603546411932","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-987965b-1603546411932","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5cb28cfda2908e1385e62b808935e6576fc21e62","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-987965b-1603546411932.tgz","fileCount":26,"integrity":"sha512-/fwN6bDH11KuQuihOIrs+BJQZS0/udIWDE2+FiS9McQGhg5ASUNGrxAd2odji45y3RNaq+9WXY+cxKPjE0up+A==","signatures":[{"sig":"MEUCIDtW0N3jTV3bdpdIW2mCFN7xfT2k6PK0x6TZVZ+F7xElAiEAiBiyvl503WgUD5kD47q5tbKoH9wB8m32jMI8AYOqFcM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflC1zCRA9TVsSAnZWagAAJQ8QAIVClZf6MdDuys+zUOzR\nhJYufYRDxD+suXRvoiUchdoKfzKVZ8gUy3ixtbNdSGVIk6vboMDcJ7+DiM7w\nXf9lqVyyeQ1Jlg/hqT2VyS6UphWIfRYdZa9d6iDJxEEkOOh4N+J+j3JX+MPR\nLjxhvWeAV+6h7p6fOxTwrnfJFU3CzEl9RZtnrBId4t/cZYYO5mNc7SIfHpZB\nknIZcfpi5dJZ+k0zUr88qPkncx3+dcCwJ0cEfMjES6C5MeVPKHjb/WjUtf+3\nB5RKWyNRVlNX4HJurxyK33M9bSE6cLsamrrM8RKhuAE2FJ75uWZ8nKggOPkq\n/sJA+uKll/DSwO8gKHkKi5zQzTdQi34ozgmjp22qNTqEaPqkH8q1mVIZJtWL\ny+6hue+c+/8Ij/wEazZB7CXcmYq01Qp0VYc667+Qq+bEZCrGfnGJS3TaUIIs\nToDKWFuky3npoBwZ+cL3V8suJRTfvKSD5fT9H/i4geS2c0Sz4SNSyUV3LKxA\nBy8vAwDImqM+/dnBp4KVpPuwY/WFhhAI5K89OpkWq+cdN8Fr4KLv7hh7j+M+\n7z+ZdjTRPVsye3w/itWW5OVmp90lSM/3oF60cYJkxuVjf5ZVwGC8q0vnLO3H\nviBXTBnyhwFMtL5tuG3J03kU6FCGWs9qVShfjIwZQEE3WcHF/bXWHkOJWZeG\nyJJt\r\n=Vum9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ceb18981ec4b800506b0f7a290b6a36083a28c5a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-987965b-1603546411932_1603546483140_0.43870331528014317","host":"s3://npm-registry-packages"}},"2.2.0-canary-ca8e2ff-1603616437859":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ca8e2ff-1603616437859","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ca8e2ff-1603616437859","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"70a7d92811218e91b3182f3199f1d5e0edb51d17","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ca8e2ff-1603616437859.tgz","fileCount":26,"integrity":"sha512-tRDsrnY3keUPLFCffG06xUxyJER/+brL4MrCPOd4c+tOImkVteGofY4jWCo67nLwWCws9gCORiMkpXV/rrY29A==","signatures":[{"sig":"MEUCID3CA/cQCnj5zdDh+qzoQqRgr9LxAwI9aax3kr58EdEOAiEA9KmvtOuRU1vHvLEj31sw/mKegSPJeORaUYcJvbmLjH4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflT8BCRA9TVsSAnZWagAAxUUQAJRhbr5QEnqdZgR7E2IO\npE1MlrsD0z1vv3xg+5GJKSORgtlRZaNr2CKNdRTEn8M90YN1+rSDTh1YawkI\nnyNbFf8BUIxyZNa2F1ePUYRj6pXq2u6dlR5oTRkOAcEeBl5lst0AeplB6+Er\nDKQLlBSQIMyajjj/GlFe45yzP2AX99K3T/lGlXKw9QMNNIhgkdGVsW5OvmUd\nxtLxQhvXjCV+CODN4CBmG4rq60Y4pdGc5RtcvDJe91L+QGZS1kXECgyk7l5w\ng3nZjk0oCLa79nFVcBeG+klmZ7/YnbVzaaOiT68F60S61sSd1RtklyDhF7gN\nGkGrbDwBpfSZg9fina3FvxFflKRxhX1I/IFz2ac2b/dqcKJ5TKVHfm6NTT79\nJTBJp/EXeLm6oxb+bc/yON4ZGUBDEG8IaI1qHnpqwocV7K1XbxhwQA7leRcj\nuCGGoTKzl8sptbEamguvKIhaDd4FMxLIKfnOoyOM1XcVnI/ecINEGK2ups8k\n6LZLD/a9TjXfnfftEPWhZhG+iw1Wz6iEFbPn2lN5lXLGEh89r43+aD/4MhkG\nsgKCbkLfzbvLsNQbkyDkBwoMuBnJiN+JJ96eMpQDQipPsTGqp+gZ14JSIIMP\nIZERaPAbOmVgBXk4jrd+jFCtbrzJkWA/jWZmwG7pweWZbC7SCtnXMw4+RwDT\n43ww\r\n=Ntur\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8ccacafaab0748d4d9562e7788e66806fd69078c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ca8e2ff-1603616437859_1603616512882_0.12878415574876634","host":"s3://npm-registry-packages"}},"2.2.0-canary-90428c0-1603634447421":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-90428c0-1603634447421","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-90428c0-1603634447421","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"51ccecae60d99f3411fcb4156f040c1edd730fc4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-90428c0-1603634447421.tgz","fileCount":26,"integrity":"sha512-43wgD6z+8QjRiKfKHDmTJ0dgwbHC7/eKO6v+zK3phu7qgA+TaOfjwxAvG9E5JMj6FvfvFAZ2IDjqq/plT1OuPw==","signatures":[{"sig":"MEYCIQCAq5kUkjP+6Unb5TwsogDw9sQZXXWrDT0lYUEG22iTzAIhANi6MeFdDCF/EcBBhAxgC6bkjzc4atLDfywJ+K/HOOZf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflYVsCRA9TVsSAnZWagAAc9oP/1oUYMirx3fZ25G1k/d9\neDTTcpvxhKHZO8zZHUqjhajyi0t5HjkWhyuRsdAFu4AXLwYbbWG+392g5zES\nb+nPwZDgBoZIzYqGtaVNWmWATLKO+jpdzi4oVp3f0DxN/TBv4dLcUjyD7jcF\nGe/MQFmZ2BCbsVefQORNlaM5KEe4bjFgD+fJuPDkonpwKPSQEPFwesX7MaqN\nwrN4VHKNrPmyBLiE7CbL5e7OyW+BC5IMBqZSzjShTPd+T47I6a5/coEpO3C8\n/lLI29x6vRQxzrjB+7Vc9BOo6ghh/RwmfYcHKlqihuPvppmDVUCuMwJ3BWk8\nMvopPCOY8lRHweDjj1CmZ8e+V3GhFfbC8zqtv1+iZqGQfqDQLL/soAJaMYnS\nBPvEchUPeYfxpbm9WQzZIADfoCZbwayS8TDI3oM7dxx2VaFNbo092l4gCcNO\n9F/v2OJAzuK1cGjnwZW5z8Bjx8QO6r0Vtpw7D4+YUgFvW7A3xIXWH0G4sTvo\nfiHNvSYnMcCOPkvZBogaSE97+rgQr5EruHlEjICS82FhprWk45sRkMjXp6sV\nHaOdeqD7hghDWy+e9LN44lvlZO1/CsbrqWoRq+a2fGWFcHjVaCy6yhmBRTjS\nzIvl/2u5TQYGA3HjMYmsSPwO9KzQup2ijbV1IBWvbcZhFeG5z7MkGMKVgL62\nWn14\r\n=1ZQq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d6b9e023c34a4cff679dfdefc60244e7dd6dfcca","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-90428c0-1603634447421_1603634539815_0.7872467064243851","host":"s3://npm-registry-packages"}},"2.2.0-canary-0cef614-1603647150372":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0cef614-1603647150372","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0cef614-1603647150372","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"00d25f4a5e4e9ffce5faf976b0ddd83e345422bf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0cef614-1603647150372.tgz","fileCount":26,"integrity":"sha512-CkulB2YqX6mWRUggvFKdMe7aLiXxr8aALf7nHpNuNvgBWAEspoml8RLvzOhHy8BrvOTMmTZy5kstg21kXQiRVA==","signatures":[{"sig":"MEUCIQClSepiOS0EYG0psV0xXLe401aH+NKfIMzlnVY7k82yfgIgPIEZZPlCRgWWeharGa+EddOlKu0n/UZBDePiAjcasqg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflbbwCRA9TVsSAnZWagAAUkAQAIqhMe1oAo/+p9+eGcsg\nRF5K65un8VoMMYprixAmubQmVj699AGcTVZALCDp5+P4CuGT64uli99CxY94\nGbGJx8plPe6hmA49KSY6SBPIbDrgdcR54EIdew+RoOupP7jbxnkDgyAWiWov\nhnAB/bo8hSiQv7RFHpuo1NajTqrj7O/yuXOsRMnFthrTgEA+hqOOaohy+v6G\nauF7pr8COOR6GNte9lrrAAUPtkfkHczffj8VWcuG1DBFwJFjwkj155HwDGKF\nNhtjCmDiE/AhUfuR2PEFBHFL+zQIiT/o4e4C258jhw7ha1Ke7fIOTz2hjn5Q\njCxknUwSI9NjMsBJD6p+R7GKqDX4RvBA++Z2r5IpZfZqVxV7MUEDzIMCHe50\n0FAsAIrBpg8Spn0LzO63rdl8jh96Ne2GKxR7BxIr594nurlESzNwiql8Yx/U\nEkF17tr+dJ1MtvGihR5loZK/ToWalYkuNmC5yFtNFxAxd/xpHvcAHbsknlyt\nDBexpotrbrQ2YcBvMLnLTnb4+2b/dm3nbVSBkpYXNrNyTORFbD5pJPxrsG1k\n7YN7ZHbjTxDLaTjoAbmdkJlPrYOlGrtmGLRHyktWJgnYSWi/Vp3vedtgK+44\ntkHeTG69693IhP6NIUCeKfZRakv7Q2PUecYieTk3MAen6/cxOdbXXnMi3laR\n+eAh\r\n=6w91\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"24ab800131dc0487e51c1f1609ed3af2325f800e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","jest":"^26.6.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0cef614-1603647150372_1603647215980_0.7636171356286214","host":"s3://npm-registry-packages"}},"2.2.0-canary-e50bf87-1603829485955":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e50bf87-1603829485955","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e50bf87-1603829485955","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c92adcf8fd4b58017f8505e9d4f1fce545e10889","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e50bf87-1603829485955.tgz","fileCount":26,"integrity":"sha512-zGfrCsmnbh9BxIi/bvuP7NK9wyp/TgkNold82fapGn13OzbCjdd/wSXAAg9TukJT35ufnKleP6piIK9iR6SPCg==","signatures":[{"sig":"MEUCIFNgPqQxrCsa/3ItzR5Sa33Ev4bRd2vVLYRz6+ibgh7iAiEAq3LE5D767KChjmaAnM4igpmUWryDrOpKJBbbq73g48A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmH8rCRA9TVsSAnZWagAAwBoP+QB+3509sB6s8L3lweW+\nPX0zvdgP4ZptJpb8CBp6KHpYTn/5uIEh47ObrgCdCF7x7mfuAlPBTFtFZbBW\ne4s+D4hvci5kk0osHRcFn8dxkY2Sz86tuEFZ3JSTz1CYg46J8s9mTov5bK24\nbExUQgK2SUb/CzM/4rdXTPXj3B7z89ByLuY1o28LikmTcQ5mVrAx/3GnjhY2\n9aBn6wJXtIsxMjYLLZp9/vzGAIKjZy4WxFYZlDbeS8pIUAnIWWhnpqEYPGIO\nbpNjmkUQvHQK2fXaW3oHS92WkT3EAaEGJY3PnsY8SSH6HFPYATLODXSR328w\n44KqNF0WWHI0Rc4WxkROuF53gq7eoLqfeeC2mA08RbCOeDlqAJ7psmcV3Ofr\n2PnVlOhMi8/NeEtk/PyVt+ZEjjhYk6Fs1toc5SUrB3JYPx11btgJOK+wELP4\n1k3K+LIEfFWuGQPAOdS0k05g6eisd14tUwR31AfJW1+jTn54GrVxxTgxZitf\n/uITa34aOMIqeQY/LynzSQgZUEtRGqcp25mxXztu1N9+fWHZtcA3nFaolJnD\nv/Cum0UKvh4/u2wBzf6/28EWLEl452WIGeln9gFYxdYFZ4i3QCD3OEg66Lmy\nbu9zpMRnmjbvoBx8Ynm3HS5odnAr1BDjy5RIXGi5LAp3nnvPFEzGNx5RWt/N\nyTAi\r\n=yRrn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"05a9808df7b0032a6bcbf58aae9ba1a01bda18cd","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e50bf87-1603829485955_1603829547304_0.6477222779621217","host":"s3://npm-registry-packages"}},"2.2.0-canary-fb9d200-1603838891344":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fb9d200-1603838891344","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fb9d200-1603838891344","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2e411c48f5085230a16d00a108afa3d2ed49b574","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fb9d200-1603838891344.tgz","fileCount":26,"integrity":"sha512-NvmIerKcHXyF4hWhaNlNmZ9x/nA5UuE9Hhyqj8YamIwyelh7A0o1Nmh8LVdXF0GWLF2N9EqkSj5Sr4k0Fg7/EQ==","signatures":[{"sig":"MEYCIQDCyon48XuUGeDwkNJUeNKUOCmY07OQqyyU3UsEPO5QRgIhAOdYkjrCMXPpEeykQ9v0N8cDwiwLyjuCh5F/DisaZyor","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmKP1CRA9TVsSAnZWagAAwgEQAKQc+Lm89IhOG7easPua\nYFfOE7evauK/V9ejYWmRO4t2RzCrFRKG+AyJDXGjk+M791rhioCwA2RMalYA\nYoBVe/LYa6Hlx09xXAbwzzCC0xYYxOuU85VCUvApRmC0NG6g3a3n36ViQkhB\nrlhW5vFVQQGuQs/sRqGBXmEujlMVMfjxYgNXsfHIHnsfpPvDCWZAAi1EPms3\ndNOg3t4zdqP4AVjnqHOKbRhFaTuZFcDNN+BDJRLYXafsw8rQWwNzBamFsxHQ\nD9CPQt+WSgpsPaNvTEKtVNY14J4fIC93gq4JSz3UFUcHrV4WjgH2YjpT8hlO\nYP0ojgwN5x0yEOBdz7+NnFjCSt5dXyAbeWGWqmnF1c8Sag0687XsBHRpy9wH\n5J3I3OdZ9XqV9tVZ0w3vYrqtYvGwDfiANPyFs/AoHRtnkFouaSP0HGrdGTUg\nLYjwEcWoRZFVSw5lesZP4VB0DWw9gaswqbiaZWtfIQ2pCLEH9HbP581X5q9q\nh7N12TgLVG9t8SIxDdfDZVqGuBKdM0afw/yH83h1d/+44wwCvEsQEyO3tE6l\nxsFZ9upKhw0MbU57aJezqig69UdOdRNz0p5XWGeSrxUrfV5NJyCxl1OSodD9\nihZy1JCO/8GC12iiSA+gO6eq4uYuKSbAqbSR2xYg2hL+gQtksGzDzLbj9Bhs\n/BFD\r\n=94to\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3f2cb1f1220f895043b7a3cd0645a6ed5fb2fb2c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fb9d200-1603838891344_1603838965177_0.8203620557931859","host":"s3://npm-registry-packages"}},"2.2.0-canary-88c573b-1603845450423":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-88c573b-1603845450423","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-88c573b-1603845450423","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ff77c6865d6f9e22950c8627d29d31b331ab1d89","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-88c573b-1603845450423.tgz","fileCount":26,"integrity":"sha512-1WBxqXFNSfh1lFb+6jb8R6uXWrbN2Fq7vSZIL1xulT9Oe6s+xUN7uqqpJeyNOcT3mB/tfI9HakuGM/JK+ST7JA==","signatures":[{"sig":"MEUCIDPXWHWtNH4YFwJ9RtHTa0TApchU7gwyo35L7qYjTemtAiEA20zc/d6OY9f1HMygUz87c4fbwKTmvbrviU24p8Dz3Ho=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmL3KCRA9TVsSAnZWagAAyccP/0pwxVJn6qU0rp3gaU9s\neqJjxvrYWD+PnR3TVxHOwDENQ2SJ8nE3VAw+4R9DETzL/Nv32iN09+bRkCDC\n6UqFEo8+3t7KgJjm6nKZXUt3+l2wpaKhGzfXmBdi/QrePgxc80mRJpcHh4i4\n8DP2ipEbO9scivt4n7bOe0m3fYToBiWiybGmY/gg5MFq4txEHF5lKvXQ0lxT\nOkXdT+Nf3y1J6zyW2hwYQeiFIWkmS9x+DRIy4CmKQum3IKGti9EB6a06e8sA\nQVl/qqp3tFYNVGdCRLYm5gm+87BslmHJffY/gTLGGbGpKkmCrnpBxDfsJJsT\nwSJdqIpM/MEnNnHvwLl2H6vyZUXMfR/oinSOPhxdgs0qs0UIfbGoCKvXyv1e\nqgAkLm04cs8HyYJWcgnJ5GZA2tg4leeangS3koBqP/f522Lryg1QnmsxSrEn\niewc6D6uW3eJU/aVd4LxauLHW00CzI7SvyS6P0cfCA0DQwWxAvVfdK8CSvFg\nLzv+kmr+3CUBXpPkrosctDmEMuSz7Pf62uVQQVci4AeN2ykMBjR/ZHT5sqjE\nPCzkRhrYTsKgesbmaqSBDMNYB59jkHRldUdqSufgpuLIjq4rlAt8pg/65i54\njuGOeVIOcI2MvEkX3GIrSZo8Xikyqa6K05zW6fh0rmDsQdAouM1dxSC+qGth\nAT6a\r\n=3GKm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"074743a2ccfbc1e341ce70bfc9cf506bba3bbac8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-88c573b-1603845450423_1603845577967_0.8686343389501712","host":"s3://npm-registry-packages"}},"2.2.0-canary-0bd52c1-1603846782502":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0bd52c1-1603846782502","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0bd52c1-1603846782502","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8fadff9f5e42fb3c316af62fc075e7f029f7cb6d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0bd52c1-1603846782502.tgz","fileCount":26,"integrity":"sha512-7WMSCz3L0SYHsFIpz4nA0GajKWaBDi/PAxGH/BRNNC9pVjQne12INMYOXzDn4gSq8ivUwd/QLHI4/2vRomw+tQ==","signatures":[{"sig":"MEUCIQCrBvOF/MAPnszyc7OXL0MyJnwgOh3RDZUeu5lhPxebLQIgImsQ8yB8yAuywRmjl3djVVnUJQM9zMj41x+2KSKuHvc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmMLRCRA9TVsSAnZWagAAsMgQAIBLmUqObnzUQ/1oESFT\nFeKdQF2xKYGEjZ5+WmvlnA7cUwAOJzA1jdgKGfRxVFz59xVNLDkvTvb+X90k\nEFMy3Urm0IMEd8iwVfarQs0J5/jz5aq3hbAaOAiHbIqNFzmLzexmLrMIqhW3\nuUDjxBmPJSxJg2SM/0lWAKsDX2HwqxIpzSYSFcVUj6PbT/invdeiIRoXTuB2\n11TyBc9+gHfYH5vdvMmHM4As1EXjcycFPDy0kTESTP9MSXlUA8NPSYJQWNJ2\n3WzyyJFWsJdgcVNJsoi12xDijAX641GQ00cP0AHIby4EbbiMDEll/SBasuAK\neQ+CER7z1Akj7iiLE5OiqiiSh0trcIQHDghlIQzt2F5lrVPKtzJ89AtH53gE\ntNbAE+lo2AKvrXnrj5zCnZbFFrWgirUsUtfkXPYweN3Pu23uKcscJVpA5wOj\nhE8OEM9s2cuUswoKfak9L6CH/2j9DGSnxFPCIf2SOAXWmCOZReMA0y96CHmt\nnAobioKCbeTcCWqwUZ5DRDruDMnf5lyqw7inI5zjZElYJp9JECvUOQtp/N6D\nAYQ3ayqg2TlRcJp0nlt0CqHzgXgyCL1TjCT/kMYm7kao5biLTIqo9w6jFHjn\nMJIni/VNdzMrVk/EkRIe6QPbbwn+6dtaUPjqv/+12mD3zH7bMy0cuVkql32R\nLQED\r\n=iFOj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"392e24d1b1bc74752da67f9c239fdcd2165ca911","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0bd52c1-1603846782502_1603846864917_0.7147026455765468","host":"s3://npm-registry-packages"}},"2.2.0-canary-fc11def-1603850667900":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fc11def-1603850667900","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fc11def-1603850667900","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"172318f649c4899bb3b92c4e5d80abd800c97688","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fc11def-1603850667900.tgz","fileCount":26,"integrity":"sha512-JgnJ1hMrBaxR/qpj45HlwI4yRZCCt61sHHZv1svNkhfYhZtfKwn4WS4mAlD/023m/b59wfS4vIaVu8y1Bk2x3Q==","signatures":[{"sig":"MEYCIQDiFSznTwCFm673RDAoGPFSVGqZJpMHjCkD7PKwtI3lEQIhAMqPtC4JA4/mmiOA4O9ipYGOIpqRYCwgC9XW2A1M3F5y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20377,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmNH+CRA9TVsSAnZWagAAGWIQAIGF97g1G8U9QQBAhGKh\nK7Vc4rMzkduEH0ewE/WAx42Nd/vIK/SWT8BAqoOoTePOb0h3R8/h7QNYkpzc\nzSgmB6ZqewfdCovqtdlVvNp8RqjO7nhLJghRH0ywx8SF4leKS1BN/KKeTUnP\nXSE+983afPwzg1luVkEACvVD8SVpx505wLr2I8TWCqWEN5tkQN+oounsHDXX\nKqlQYTUV8wCSM9jbWY9zHZMdMKgHZIYYCsiduYax1K7NNRaBY1LR1rTpSCZx\nnx/Saq2nryr3bU2GYjUuDkVjukh5yVG9suviP6frWrozbvC8Pn3wOeuQrWyN\nfNZ4RJiZu3r0X51x46XZD8pM80xKo2PAHDWKXO3XUnN1tzjfeJYPOeBW+hkW\nSzX2j+O4O1y2lWS9oZ1ArKdzKX6V+PRQdUtB0PBJtFgklN9sfE5AaTQJscT0\nJV8dVY3tWhi/TxAzRgT/VzR537Egv1HQVJScfd461qVrCGCBO0rzSDgL3/Vf\nm3iK16Ukj+xGcd/sfPy8c+uymqQU72vGt8kvwI8gH3dtiLeVVNF7UkhjfV6A\nmsOXd4+6wgf3iU0cqZ3CyrXSUSfMk98fAA/pRnmS+gY/0kVvlcRh9mRj3FWx\nI8VZH/uH94JQtD68m1Ql9VGJoaFnbV7Y6eqdFO+GetEtrSaiWGfjEkcOa6D5\nWugt\r\n=WRfJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1138479094b7cfb8e1a8163c8d94bb6df3dc1aec","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^9.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fc11def-1603850667900_1603850750181_0.07485972269039487","host":"s3://npm-registry-packages"}},"2.2.0-canary-ac56684-1603992700868":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ac56684-1603992700868","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ac56684-1603992700868","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cf54d1564eb0ca78232e7e79e8e597c0af917145","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ac56684-1603992700868.tgz","fileCount":26,"integrity":"sha512-IMu+oh/naJ08wFyZHX9FzsezXqF04MhU/hLhizIDv8ilkWZnnYQcNmwKu4E5v+bGmgSarYxM82Pm0CRJORUqnA==","signatures":[{"sig":"MEUCIB+L0r/EjBgdv8W7bHJSldKzr+u16SOtOQKy+ypYxb2xAiEA3jZCoVXHsNphsT6dtkd8P9zInj+T819dEBjqq5IJqiQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmvzDCRA9TVsSAnZWagAAl+EQAJa0PUgYVucx/BSW8u36\nBLamb+L2UBFvRcY0wBtrKmIQVItDcctAreLEdmmOcoHXav/2FCS/ga+efAjT\nsUk6/Xa5HzG9Nonp0qUQgY+DNYQwSdHC7ia1CLjt/wsNlX2seXZxqWEQTimK\n4NLktxUIGmaCn5KHPk0SL/j/GCI6onC1oHeRmHfg1Uo+cit/TNCB9Fo4cKaa\nsxqvP4ZUZN6ZCpXhhGdhZKyiWWd8C3hpfWGz0NItQOGhqmAualm9veuwzS34\nGPp6wFPiBZhebHo8MUpo5cMo6XakbAFONVYdJZZQnA3tImPPlXkjFhULNpf9\nr/PAi6IyZcsHGXV/PS2Ljkiw9M71hqUpbEKJWogVo7jKBpUWdtJ805KfgrYD\nvUl/9gki2wbIPfJRKcUUTmz8y62CgKSkOB3pt4AMWkhmVK0CVYe7Qr/F4tmR\noxE9ZOxJ5DtJhsQBpX7oh5o5jU7Dnwe1WexQ2I39YiYVt+zn01xFtsE/5vvs\nF+V88Gh43OLpHQokMl58nXAMbNCUSK5yTo6ztP+mpPmDiguk5X0iaTSq0U1s\n+xkKZ30L7xO/Lx2CrGUS+XDZhF00kUhFDpnfsn80fG2Xqab1Bk5mzWc8XgN9\njkDgRN8eO4ZfEsdRHFlhpPbhMBUsQx1q8+nI52Y+oecULnuzdrZOWMi6WYsy\nbxWn\r\n=5fwk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"031f043d8cc014bc3c89e5e0c37c5ee786b122e4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ac56684-1603992700868_1603992771177_0.5671753987258723","host":"s3://npm-registry-packages"}},"2.2.0-canary-38cc6bc-1603996977589":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-38cc6bc-1603996977589","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-38cc6bc-1603996977589","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"755c3d1f939b309355ab80a8a72991ca920d1fd7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-38cc6bc-1603996977589.tgz","fileCount":26,"integrity":"sha512-7UjzS6oZIxUjJcVaSA0Hi9juOEMhNBuGNOr5IytHos92A78jDVv7ib/eqeTpCi8Uy6whTTW7tVRfGovG4NX2bA==","signatures":[{"sig":"MEUCIDtyYUF5SOoM56pHOY+jkORNduzTlD90KsAhwC7IEWKgAiEA9ujMXYqgcZ+Ro4AF0HNfZjRfTCyCgZDmETKA7E+/iKg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmw3HCRA9TVsSAnZWagAAt28QAJf5SPO9dyzFUHyRqMoS\nW/IsTSLVoy+IawzSB3Gqok8XoXoVlU509GqI083vt77NBuGVK5HhYzWDZab5\n5uPzU+rqorpU0STVAuYnDVvwrP/INJ17M2lRzpvqvfZqRE136rmOxB4yH6NG\n5qJhU+op86gL/5ZgLXw/K3IgPZf10a0wv9/RExM+K0PE7AJq2XRb5hASlQOZ\nt3oa4RL0YIiKvJzmDa0NMvtVShS7eE1a4YH4aUIChL+uQ78d7dDNtb8ViaOq\n5vJu4EEOsRVLI+P8SEN2OdD9c5f9x/IXntCt0f4zKCrxj1mo3eHCaQSgq4uh\nXoQujbp70+aBDwRTVgYAJGJfFJyhkPgw6iRUUrSBVPYAFFEgj88j/bOFtzcQ\nuRoHNdrNr0P1JwCHeagJn5aeVxcdLs8v9cEJCr6JZARno/OFfOINaxKccvYb\nJt5Fl0QqL880ux0VrkuK+rBou5VSmyPgIx7gvenGA6uoaMucfMFXAF51liX1\nyGO5uRkcgZD/8lantGLPXzymWmkETrSe2MQWkbM+FAcj/vzhOI2scPxQmkdp\ngEma1m2chCGlCOUBMJ6cLt+8yjaLd3iQUpy9eS74Pc3MqYgt9eVEmrKgCQzv\ncps8q3UdmUFKCvtVlxz7uR4Tx2FaIBuBq+qPDxIA5RdUDGqN601ass4cAJZW\nnkPc\r\n=krBJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"90fecd49265a83870163481c523f2df8da82e31c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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":"^16.0.0","rollup-plugin-multi-input":"^1.1.1","rollup-plugin-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-38cc6bc-1603996977589_1603997126999_0.13155818624032367","host":"s3://npm-registry-packages"}},"2.2.0-canary-0bac20a-1604048513431":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0bac20a-1604048513431","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0bac20a-1604048513431","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e5893d9049be0a7f5f5eec3d2b27d1e9f41ab4da","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0bac20a-1604048513431.tgz","fileCount":26,"integrity":"sha512-NY2rq36fbKxR74HMwDXFTNT2i2zI0jxtMhZwwP+zknygPG2ATifr/hi5cdOLYRnS2sDDCA8BI6X48Y7CMrNqXA==","signatures":[{"sig":"MEQCIEx67kpoGkmAG7sdOdhBl/vB12yjFBDY1OkqiuxVHGvAAiBL3W8XYMCdsHQQxnf0Xz9G8r+iaEguB0bVBecl+JDgJQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfm9bJCRA9TVsSAnZWagAA5b8P/1WQGy69MYF2ivslTQlw\nY5MaNSwxKsxPZDePg80EPCW2qJLQ9Q3j9EBQ2fS65jLXGxrhStDhBpISVcnF\nt/qu+Nw3nmSuJuVXpgBORx9zkTjk0YdlyTaemgB3Dsy8EES4dV5+pRt1OVW5\nX6sC0p3K4c4NQRTH+DoFuUzYvOSvCbaIpHf4dJFpSpumcTJitQWhwnfE/Xrx\nhAGqXoQHgdcpAfHHHhCVXE4pB/dxbLJZ0i65oqvxfmeNiFrnQ72r1o90PGkz\nSAe+dqXv4Jtg4N24rOHBlCnlo3ch7+z/RCGyKojIFQCBXos+L7OkvGBsJxhu\nUNLzrNry+jpV0AplJJT1eq8N+Cm3Zg2TPQ1HqGrxbojKlBsNIGDewVDCj7Z0\nucCv5tvQbSUc2BoTu8oMocJK4Tu8tmW5WuC2ZuF+uT+OIWV198UasVozd36e\nfS2YaqOmVCxNcENDaTAQKkkvFXB6GkLi8LyLGq8ed599iA4tuw+U81z94TI1\nN1Ev0cKcY8ykhLCA7ihZiSCIdXAhDjpkqcc/YqI6POgDX3jE+t9uWywdtKMU\n+mpuJmAnT5Rn019LI3DhD+jRwjBCrgKbxlHh5Y2MYUASncyu3F8rAzVMXRGG\n+Hq684G6VwbUWKAolWGJ2fydzHfkM4WLAGqWnBaS5/IA/AtIeJjrx6g2Xwd7\njtDN\r\n=WSNy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2e72b74bc1b6683a7cfcd85562976f1e9cb88f16","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0bac20a-1604048513431_1604048585265_0.34267471727025045","host":"s3://npm-registry-packages"}},"2.2.0-canary-e1dbfe8-1604107228691":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e1dbfe8-1604107228691","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e1dbfe8-1604107228691","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e2ac1de79f4cdeef70ca02d5b05e249e49791525","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e1dbfe8-1604107228691.tgz","fileCount":26,"integrity":"sha512-bsUByD3H36rTIRMn6t7f5h9dK3C4NrRsOQRoWYl1R4WaMF0G/LGOssrNED2gXE9LcW8a6YQrFPZHJzM0o7OhUA==","signatures":[{"sig":"MEUCIQDWCBF588cGuJNLv3C0cHgVyNA6t/AaiXvbHrETi3gVpgIgL0nE1yNJEMYAgx0F8j/QvHrOPQfAN/6t1ZQjvSRwsSk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnLwdCRA9TVsSAnZWagAAAtgP/iVodUwPu7ii4drBLgVA\n8Dx+7hYF5qYp85iBouFKV3hXwmGGZUsI4/joX9x8luVum0YrCSMoU4BWCwvz\nnNVmg0u3QAb8SMTICXKdSmhsiRR1Svz4N/D50ntDi5MvJ83LRJQumLPjcyD3\nFyhoiJmjT+AAwn5NGpovkPc4/XrZGiJSB872vkmHUjYgOGlRU7FC+pHozji5\npSEsBEuu29UIUjI0DbOsJYWKZev2ifyUJ45CIHvumSGT0A1qdPp5mbp3W2an\nIx3AdfIc5DCpy/fMrkcw4p0yW7Y121SNBLtX/uARdi7C7cWRZ2PlFONVN9u4\no1g8LxVOQUQptmZr/kVzt8Lc0qiLTpuZJu0W0S8T9Y3Qy3q3oqQ25Sw8m4Rj\nCzcvMbhJfulxKxI8HHidt+BREwATC751yjpOWTADbT+P+PK8/ostm6TImJ95\nYNO47r+4/SgFo379BgfVP0Xx2I3mVZ/CPAvdlnyXgW2b7Y+hnOW92XGV8kor\nOElixx1BXc++74Zp3564OzVdfU23k9yeRe60lxk3K7y2mCv7Dc0Ya7RrTp+5\n1kG3IXd0gevo81puP24DIaF4CryjMAY4n/XHskgK59ToYVlcjDq8pATL4h/+\nMk07KjyGzAyvBlFA8q3dFb7co2znyf7ZMLsfam7OzCGv5BkxvY+R3i/E+ws4\nLO63\r\n=5XJA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"733cbd33b2b7997ee9eff5ce2f85069371554a3c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e1dbfe8-1604107228691_1604107292890_0.4354871239031384","host":"s3://npm-registry-packages"}},"2.2.0-canary-b5be44e-1604213897553":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b5be44e-1604213897553","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b5be44e-1604213897553","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4a338af1771b4f1169264d7b2d7f11fd1a3374cd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b5be44e-1604213897553.tgz","fileCount":26,"integrity":"sha512-brCJSRcnYP/OQ+kcPzcUIeJlUFsemvrvsP5OPerPVScKlW/oRlV3ldH5u3+Wnw3IE8LWmdoAShYhoXoo4bkgKw==","signatures":[{"sig":"MEUCIHWSoDBdFSgPvoFtcwb0FCOPFYTjsG8S23hJQSs/iMCCAiEAxhRfygO2FfjAxEUC+GJ4XXHhb3cyW3TDF8Y0baU0QL4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnlzbCRA9TVsSAnZWagAAbtAP/iocQeFskkZVtLrSzJiy\nXQ9kEAH6q4JlcVRKiVb1b+I3E0OnVvV6+dh5Vma5BtkClhF2lN8LZCGbr6dU\neWl7Py0y9YfnTPNY778+W+RmWsmUC446G7lnh1fcu+R08vSAicsbe8br56hD\nMhv9gWkXVX5H5KUxaFGIH+nLGEhwa11nZC9yYbm27uEhfr9g55R0t/LxJ58r\nU0UjgTKtqYM63G77N8ztXE6Cf37/ZBtsVgeZzeWtYe6q2fqc6XufV5YgNnZz\nQ5hFjUYkK/HADnzlI2QrVANOthLUZAIjA6dsslkkgulquZ0smsAisbtCGbfp\nORzJ4EM7H7ofVAQWy0CLCqWs0LpOEgJBnS+eBXVCc54uCnhJHWlopoEW3KzJ\nYoErvckKUT+YbKLKmsW1V4yBV4nSXL+CtMYZ3QkoIxlxrYtCUTIp3ZYX8qkD\nCMETcfKbs2axNppf2KcSsIkDMPxED8b/KV5LQRq18W7qu89BFGZZMmcajHP8\ndaeWhM43zMuhCcYnrm+1MHTdfWG2LztAJaK/Nf1MpZqKwvfZstG4rkU1GilW\nEwN5pkL9P3vRZR6js16P/IcIeuxP8gBNXWTgA3hx/9nhsFXsd/0XggBYoJz8\nX3wqV7jHLFwSSOo2L9MfY/fE122T+MT0Ymm5JJAeRRDS4r66QoxBTkJGC2xV\nsX2r\r\n=e4U6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"172d7285a9d82410feb419b554df2923e36e7181","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b5be44e-1604213897553_1604213978676_0.3703505558116047","host":"s3://npm-registry-packages"}},"2.2.0-canary-9e2a0f3-1604272980265":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-9e2a0f3-1604272980265","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-9e2a0f3-1604272980265","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"511120b5554ff57f90aae24aee3d8a22a4e1f507","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-9e2a0f3-1604272980265.tgz","fileCount":26,"integrity":"sha512-62RjSgFAJU2y+5tYHZVRT2Qkv2zemCqDEINY221IPgzjUvfKjjyFCsVOrj5rRJjug+FWDvufKpKVnQucvqMHRA==","signatures":[{"sig":"MEUCICBrPvWgJngyL0Jj93Lo8yeEAWUSOwtZgKBOMHyrG2q5AiEA95VSTWwHFeME8MNIxDxcnqjp/5e2s8X5GBS1dJe1S/8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn0OpCRA9TVsSAnZWagAABXoP/RVFwunnMaPyvl+CxIBW\nIWRavrLbNsaQBWLuFHq2RDzkqi4xOgQq+Mor5g1qUR06LjZHvl1FEp4OF1HA\nPm3t5Pft2ccbqNtqdI5TM+LyEtxOBoqp4PrtWR+/WaZyz/mYC1dYvmIZYJFi\nBe0mcLcm96tq7b+ME8DvgSz24QwtXSBxHK2mPO0HyiBh/ovY1CkwqwNrrFP7\nlL6+07C/x4Ggpnld1+U5xnc8U4Nz6Qyh0VUAaC50axy1ZNjGSopla+/CGv9v\nKhOwy3b1xtuNvtRD8HyrEn/sF3cTTSl2JTJRneEtfuRfAzWU2TSbvy40Vqlp\nS5zC0LeRJGzVZ97UquRA3lkMy7gZcX7y83MRdDiiTC0fwJkh3Cs3+Kwz2Uq6\n31kPUG96Wxwyj5FJZVL5WNpZ60IFbsvkkQUUBAnGxxXrkKbwtKWsiWN/31yz\n/epoaurng8fEQcvRA0ca76i/pMJ2VT55qLYqIPvHWmnEdyYL5q8BUewc+BXF\n3pJDPrcZoT23axpAlBJIlh4Orr3ZphKipL4aGbwFFAPI1SgYyRjqrkg8d703\nAcBWFGRCqOcOxlGvmVyhrtE6kRt7l23Uwl/QNa/wLLMK6f+uFYFN+uH4tazr\n1KWWYuD8wPtVBhAbx6jeUjHm5uvEuIqCe4ipSwV5bHHZ8D+8u4mkFbtExXpg\nDpz/\r\n=8vjK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b3c8d8f5885bbafd4397691340ab1358cf92bf1e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","jest":"^26.6.1","tslib":"^2.0.3","eslint":"^7.12.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-9e2a0f3-1604272980265_1604273064692_0.16227716539785986","host":"s3://npm-registry-packages"}},"2.2.0-canary-09e0d3f-1604309936781":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-09e0d3f-1604309936781","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-09e0d3f-1604309936781","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"feaf0d35037dc8a6cfc0f3f8c2b0d0436032387b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-09e0d3f-1604309936781.tgz","fileCount":26,"integrity":"sha512-p2aTsmyTO76Uko4ruh4Ez/yLtbksMLU8IhSJtspjHOxbUX4PXI279BXKXVrdLjmEhmUQ3Pti3oTUtHEbt//Zrg==","signatures":[{"sig":"MEYCIQDFyvSAnzj6SkrX14oL9cSPj3cYHG/fGqeqP0tbcb1pigIhAL3xDgm6TapQCiU6ENqlnO31LQttO5BLnIHpQL7tHiI0","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9T6CRA9TVsSAnZWagAA480P/2KBUGtMlRHBpLFFPTSM\ngfV3gZLPmfhOORxuXu32FQU9u54Lgh7+Bo+W/Bibj9syvdGGrUz1NgvGpnBY\nXr672mz6C04e9snRAS9VIY79KWhloeOPQ3vPGGLcUlm3RrTrSwB3HKEP6wuy\n32m+lwAa8Pm/qPdw8dlFV5XDdhbkpRShqVg/j1nfMvbLqMkkKUHC+MN2XQfY\nogJRbm7hiwVvmoiOUez3/i1Spm9HvUoEm427jYH78EY0FEYIKX7R1k4tZpj1\n5z8xH55as6VBsnPPvru4yvtATOiGdwcTGjw21mD17R06gX4Yva+q3gw+GDqa\nzunJf36cruBRjaKbOJs9fMh+SSVVqK61JrADxFmAFVIt111MbPwrG0v4A+8M\nLnS+7MfWxL7ZddzcjoNKL3AafTGUOqgoWUE/uaQvn1VOCYpSHk3zOJOETK+t\n3tsC15vA+55PDaN1qC5aNRVmKzJNNHtFAqp9xKC+tr2hjhKKahXEyUy2Uuk1\nZwV6b2tHzVjCXDdKFUoUPXpr+BD7JUlEhl8oXP95G22sTsbcy3VchSdKwrrm\nDH/DCt9I2ULssA+qatyikYr8EjBNvJrH6IVXC624Ye27wrJCfxATK4N1RjQg\n/4qS4/RDp843Te6V3/eoRTTuFqLzKDwsegT4OG/0OSg30xuI/kmeJyEBpqZa\nHioB\r\n=KJow\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1415b8c31ee1d6e31369094df2f0f60b0cbc6249","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-09e0d3f-1604309936781_1604310266198_0.2226124630567805","host":"s3://npm-registry-packages"}},"2.2.0-canary-34e1ff9-1604310758182":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-34e1ff9-1604310758182","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-34e1ff9-1604310758182","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"001e3ecb551746332c9900912d64cc8fd35457d6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-34e1ff9-1604310758182.tgz","fileCount":26,"integrity":"sha512-OSTbsHpu5udMC7UM4n9FrnCONgswo8XHxTY4s8G+8ioHaUt+1u+m8aeiyLURlf3NqGDjY6W60l7ZUbGbu0gHcQ==","signatures":[{"sig":"MEUCIQC5rF3zO+q3QxCxOwCYR/e74zSF+QN/8RvfV//s1M8wagIgI1foJ+7iB5kwNDq2sowC0dCkqopBD/whdoaSAAry124=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9crCRA9TVsSAnZWagAA32oP+QFn4WlgYjeGlKGNAato\nTTyA3ha34D7S9+NTVQ5KD1NMOrlN2tCqJkJPB76zCDOqhX8+nd4flrRQ+l6d\noGu6YX2GB8y/2/gd57AfkeWXNuBVPzNgFyolieFtab+EydOCpUWvbVcdf1ie\n1os6Qor8fXXG1KrtWrcBjWKmTXxzyxUh1Ohe0LDYOhfnl/rXCgKpHJAyhYXI\nHnV+BpE2RwZbRpMquTiypNWSbrlbdVH9cC2VncaPlQfzljdp0VA2KAjJR7EG\nP7kGQCaxWTlSP0hlxsygyYwnUkP3ti1IFwUHJDOVHYFs2KxNUiO2k2pB0rO4\ni75pIsqTK+sKMRTZ2WR1/pQFkw6d7/iyTma4GuVT5eS+q1k3u9tcMd3k1k/F\nZVR0rKwYn2QjtzH/+3gxyG3ysISD3SG2W+9augOBdOPjaeZq4iL2JTt9dImY\nLioM7L+E/eHKOEmvvtNVaIvlDAOTAGO6UYpnYhQyrKmtrWoFJFn4boIOC+kz\n8sMyWW2IamVA3ZjnElSRmslz01tyavApJqFgP8HcTy3NXUqbmTlWdlRd8qF5\nzAs9UCs5T8MO+lbi3/1qb4MHikNA89M7MxWkZnBZuShg9ZvNx3Ao/9qV5k2C\n3yKuXExd9EdoiwHDBeCcKY37e+ZFZfc3Q7fzST9tGp4Aybjnr8Qvrly64J3o\np2QB\r\n=xEBc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5ae999c36391dffd4bebdfb9c94263b2eaea5584","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-34e1ff9-1604310758182_1604310826777_0.7493809555558661","host":"s3://npm-registry-packages"}},"2.2.0-canary-d001d8c-1604312736123":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d001d8c-1604312736123","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d001d8c-1604312736123","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"755b0208704df46f35f7315eaa63a00d23ffe1e2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d001d8c-1604312736123.tgz","fileCount":26,"integrity":"sha512-pEp4mfeZ1txUqWW7fmSk+mIjn10pbl6RllfBnt7X6br5kL+mT6+eJR5DKcevOQZ2TU0W91NThD2vRpgW1fSUPw==","signatures":[{"sig":"MEUCIQCZm+LZidyT1RNQ9N/NJaummYy53cG8fGiJMOGFknTh8gIgOSo4eV+TQFTK7n5KfEIDwLMYKME/yl5etwtqOe2dkGU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn973CRA9TVsSAnZWagAA07QP/3bZhpzzKQycupPaeYw/\n2w7c01dS3fMtrdoLbqAOmBxuzhF1Kg70ombwDAZoBk2FKQpRp2763PPJUA+A\nbxlZsmIVm5bgL9U3bCofFFatf5bygVJdNVQXPvYqZHh/NlktgrCmbo+BGL1X\n5++NQnj8Cxvi1shVoLua3M0CK4ECuAA70WsaUczuO8WVEIgAwK5VOnNmopWM\ncOb6PTWLB5RYqXkDJmpZRw01Od8OowDlQosriyJcDv/MK8PCngkbbxQ/IYBD\nnYb8L5khXKwsw+BOnMF+hUMDTRnCcZNebNq9yuCX6sPPE9HEpgDu/3dDiIIB\nBB6BGGzdVut8r7L9JwoVlYk4/Ed2vXofnAPd2IDLS4sWfM2ZJ10Xze1IZb56\n3Z1OtQ72sGNrrGDnBPGpnhwEq6Utw4g9gbEuUdjzxWXdOZMEZyWKZEAfDjQZ\nDbzEmTpAj1z8Xpa5GLzCzSWxXZ0PiXLX37S6n3doxpugzAEyJapuYSJLWl4s\nrAI0Ld9xMyEenvWzDgrvQAzJ2WkSzzdMIYpQD60HhjAy5bB7dHfLK8P7t5vi\nuf1kMNpACji4W4VgRuVYSA5UzKO/Q0V4PZjmoiOJMnGflct8bv3jTL2wbcyP\n8R/W/7BGmLifIur/MkY7XUaNHYlVy5daE0lwxnZ+3A1AIrJ56j7RzTXidEAI\nFZwz\r\n=dz8v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e95dcbc74dc6a957f07e88dade37df7ecaae1fc5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d001d8c-1604312736123_1604312822892_0.32233323047034346","host":"s3://npm-registry-packages"}},"2.2.0-canary-fa065f6-1604315359592":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fa065f6-1604315359592","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fa065f6-1604315359592","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d517f96c274b8cedfa11289323d27a83c18d1fa1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fa065f6-1604315359592.tgz","fileCount":26,"integrity":"sha512-lbo64ZW0QUFqzX7t5ECtkCMILT7l2OG3i28b9mQ2EyyxXiSLMastHRyjDNUm0xR2+UtiuFSbT3NdYtSyckULWQ==","signatures":[{"sig":"MEUCIQCHsNjHSPL+lA605T3tUI3UHylN6mS/7UDEMOtYhdW7LwIgOvVjhK3Y2ydXrHLaC+dNQf2lo/CdjJ3iAN7G0cJt7hM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+koCRA9TVsSAnZWagAAqcoQAIIjkQ2rPfcjXJj+O8re\n+8U1Tlw1bz2+o5+W+o6hjsyJuEzlJCmBMX0ZlalMNhcb8mNugs02yYnh3pTs\nf7LTMmQ09Vyg1ExQQsgb1W/LWSdsddl6l6RDeICGDnC0oPqyiJx8Umvwu1It\n0xYanwbpzzpapo02Dh43V6VOO964jbzmtaxgTIuDpfqKMq2NZJlNzcCKbuvb\ngwYqnkJLsR3u/r+Njeo+5ssGmqZ54nBNgViWmBwDraxoEukk6uIPPU9WJ5T5\nNFLTkvSEtZVw1TOl8+ge67jmgkubCN+jM4wDEpL8c+e2DP8nhvAbcVHzdVrK\nu5Ls8GMYw+oVC10P5J4xoQKsYvaLQacSJQpwahuyzH9utKmFZ0inEWqF2wP4\nH4TiXi6yDAi0grpchsa8zh8KsZN5RJsuecCTcMf69IZy8f8QG8k9DyXH++qB\nkB69RHxXR/Sx1l89sz2r3MADmuk6jd1MSoKBGEx+cFVL0M6inDNpOi/O3l8a\nG+Ma+WHjV4uj6KTDKeL2FfymksyX5mFNKsNsDYvW3lMWyLurqxS/j2CTe6jo\ngT5B69NC7BfGYQYPLJwBM2gGwc8u1XzBX88uwL9G1tB05Enl1sa89aT/pV+0\nCUTsyWvJmprIQmH4eDa1QQ5vsFXfm2TKjZczPIZAgCCoGn0kroSxEtXwrIMv\nXOTr\r\n=QqMO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8b8704a06db980d4dacee90806c966b9037904d4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fa065f6-1604315359592_1604315432236_0.8782808255688077","host":"s3://npm-registry-packages"}},"2.2.0-canary-602762c-1604322508665":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-602762c-1604322508665","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-602762c-1604322508665","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"00b8a24c3395733cfb77cc6aa52c71bb1ced7978","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-602762c-1604322508665.tgz","fileCount":26,"integrity":"sha512-t7c2ApwesqUkJBIFO4LQBl1j/tzZbstepxTXOqN36VEs3HaxgTsGH1nBaumrB/PwcWw2WX0ypHIcYKrsYqBQSA==","signatures":[{"sig":"MEQCIDjUUb3hy/vs0R2IiwEJZF6uhX/zTF1G0uMJysH5tMMaAiA/JbRQVWCtGg2FGEmqs6/H/nA9zr8W4S3mxTgrxD/08g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoAUpCRA9TVsSAnZWagAAkTgQAIzUt4TIHsRRs9qsv/++\nDm16Ti6ty0xMt7gJ8EPWeChPnYalTWq8RrQRZaO5XJZcNrNZHBh/rabkXH6C\nvNrXH1P0TXRA1UqhoIYm7RpvOO7C98yCR06gzLSZv8mpSrdzMN2OQhvMM9Sc\naHLidGzC/8rGAC/mSOMcZagGKMv4KS9cOU6JyJX7ss3NydopovkdOPIQ1fhN\n5fkuUr8rLQ/v+Ddf+lMLnSYm7bldWE599uWP+Xuni9WrsEGd/ez68+GWyN/i\n0agv5ba0DGA6DEDxvLGXnx9Jv73k9R5Wdb5Svz1kwr3tj/4IcQTb0JMK07n3\nfGITT6In1aYUdmSLMj9YppUCR0oua5iaVjHpmeOwAMRlc2sT3CnphQXXONw+\nSJWudajz2YBxlyzAbneNzlQpkd/prALkpJinxKB5Cs1l1js5bdhhaunqxKqL\ntQF98uAMHflb8QPj7hWnHtQse0bjdXWjUs0Gv+XWrZMCRQLuW+PoE65KBOVL\n0zmBZYhVDKppO8VXtbZyZABRcG138Tx1wvQAVZK3t+A1aLXG+T4rLgwknvI2\nNDUsASq/BZokGUANsmlFFprDy5g5igNwUcJRNAyaq1wlcrnUhse5em5x8YjJ\nL5E1HKQAiG8SKMVZp9U0KtaVoqAiic4v5xV/dQO3pDKONNSWnlNSRj6rWmfc\nUjRI\r\n=Pyd/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0e5a4578312f1029085082afc4040c06e90964f7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-602762c-1604322508665_1604322601460_0.8892502583654203","host":"s3://npm-registry-packages"}},"2.2.0-canary-b820ed2-1604480543519":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b820ed2-1604480543519","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b820ed2-1604480543519","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"73ab9bed5d81a5d5659e48985f8f434a085ecb88","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b820ed2-1604480543519.tgz","fileCount":26,"integrity":"sha512-Uo0tVhKiBoWbMVeUMc3LKr3C/gqUSJ8a0JfuNXtjNiWgCR/2BTQjD1p1Vg6+Q7qZY/KiS1Q/O+5VohPL6ECmhw==","signatures":[{"sig":"MEUCIGeUo10lGP38RM1W5CI/My63Kmw6cB7ZC6WWtjnznTfwAiEAl4XS/lc+tI+12b7foKfjS0lam1AK8NCSjQVQfZcoHT8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfom56CRA9TVsSAnZWagAA50kP/38q9eAHQ1eO9YgyW17a\n1wThajUmiKkDQsGI8zsFyuMM+1e2KqXm1pIWhmAH2vLjeRo07adpbMskbcof\nMQvZubUWlyA60NSLrqSu42bYedf/bLfCQKdJ5YMaqkNnXtscZti60eCSSXAB\n16TDKQ9/6UITcJM88TKQWFt3fu4EyW/NftNznnEjfC8NQCDvcIh1NDfSF1pP\nitp7v5cXLFGkPcCpIqbXXX4NeGoolR83upcSj2uoUqb1SrMbyh+wMfbuiV3I\nXO1+eTsiLFKE7F7PVfvRG/3Jvuz3JhtVIDYbwQhQoSdmabk4NcwTOM5tW5TB\nzhEUnVd1f5AqAhzQ3sHCmPQFGdb/4yDzROohVBrsYLYe3Eo/QGIyyUs9z6Mn\ndniQRm4y+G+74rKsTQs7LIFP5D6vBr22yC2MsX0lbWBnrJrKDqRMZ1EyE9rf\nfRDBSgRKMJ5p58V6NyMicmCeFqxmbfbbW+wOqGq5GeCzGcuYw1gHyqWyQqgO\nBAPBQcVakvlC8MnadaCa3RNiNTki6ggpDuD27KHtKWI78LA9+11l24u1hqmP\n5TBarahQ9C5EEG25cJYuPVzgB6Ufz1HvI3hH1HwNgKEuhtjbAyljn6ZlSd0h\nDd9omqJ2KhYfAzQl5yYqIHXVo7lMdXPyVpVEQ2xojwJjdoAGseyCN+VKVyUy\neY2J\r\n=z8U+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e8a61242c39ea1165c3f986267c5c4e2c14ca827","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b820ed2-1604480543519_1604480633892_0.03785408197180029","host":"s3://npm-registry-packages"}},"2.2.0-canary-91e1d78-1604714937620":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-91e1d78-1604714937620","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-91e1d78-1604714937620","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f208bdcd15c9a1ac85078a15c5e5d4d90571a614","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-91e1d78-1604714937620.tgz","fileCount":26,"integrity":"sha512-LvU8qrqZiOjLjO5uoO6pHN7S+NGofyYdfHHXbjm7hIfK6CDdG4+RJM4OZCqIhbqcy9BFHrpKU9fHETP3Ir8w7A==","signatures":[{"sig":"MEQCIAwM44mKK8iEeNwDbmW8fmLhudVruzDmJW8F2SVlNbl7AiBdoi9sG+x70jjr812xx0+MGAS4GwbSaTqfkLGYRRcBrg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpgH4CRA9TVsSAnZWagAABX4P/REQUKrXMPdLqNwca0em\n1372cE3ZQYD06vJu9BBQhWmZDjdirXZb7N0owLHxR5845htmlsSlcSXBmQQT\nMazkMqqqwgoY9MnGdt8r81uY5HsGKLYVGFBlw9QrjtfUA4bp2yntN0OMGnH1\nd8B0W93IYlun0eOFJYxs21BqTgSEcujXm4pFW5xvbP3w2G225r+eTPlIcjSI\nEyHhrFgFzZhSjPD5QOJSomhgOt5PmW5CaeKN3MKE24OqXq0Ss0XwvkOAIRYT\nEhNs3Al/Sn8PH8rBl0S4PmE1pqWjDURQdmlVmsG2C7uxkiPobNtomtelUAEz\nQwiORnPYNjFvT7QgraKY8sf5AAiqZCCziGFLCegcPiuX2cSbAnoGkX7XQtPN\nUvUx3WUfIu4ep7Txf45ECsoTfqbCGdhvzbbISqArwJVqQ2yJM5KHyX06hFe0\nIhhJ5cdfx1cMeSOSRKK8yqb9+s2gyGUvGyRh2Sa5cNk7RY084BpKH/qBZ7n4\nCwsIz3M5VNhhJ5tJ/Sv6E62hPNh/nKEhR9lCmqwBYFgDSz9MrcX3vfcAK9aV\nA18xXPgSgItlr6VD0+2C1hF29nc0N2Zl8ecmfNWxyf5Ac5yBTHN5cGhefLGc\nxpO80mOth0Zjihj8sV+oxuaXMqHjy16GQGFq8DoMMWZdhOnzpfsc4CKYEYcW\nndhp\r\n=jgdT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5fd8029fb97adfcd3ecaaef6cb5cf8d248a9252e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-91e1d78-1604714937620_1604714999947_0.8930297829608065","host":"s3://npm-registry-packages"}},"2.2.0-canary-4c0ec6e-1604847720075":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4c0ec6e-1604847720075","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4c0ec6e-1604847720075","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2f9202518184bc31c82ddd3a9ce7769bed61a540","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4c0ec6e-1604847720075.tgz","fileCount":26,"integrity":"sha512-IquXlEKybzoxXyUHwttMoi8DFyatBVwk+4SXf12eUul0Rw5KdEgf8Gv212HT2GtcWhn3HWczoUWYemBOPavxfQ==","signatures":[{"sig":"MEUCIQCa+4TAJrjWlo8+TlCM3GHonVs1gdGPVjltAemQuvInGQIgeRHvgelvGHm7+/bVsDsUd/1AXqVNr/EUOO4MEbp9+Ck=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfqAjHCRA9TVsSAnZWagAAGfgP/RX8LkEtNvMheEreMpq8\nHMYhd5LCSLTUj7EVHJtscPvh9VE+W8m+kJ40jyLwv2c3ncGAj2AIVMIj3Myx\nTwis0P/xSWnuGtHw1edLLv7zuCIEHI60dLVjn9/eMSTRlENC/a0sQs+6aIf/\n7kNEQsFP3yAA2c80nC4rRvPfbkJQXmvSU+fEv56Yx85QW97y0IO1DMwP5MwQ\ncEBpS/bVzuE/sEgqax5XfpsM6ZvkrPMk6HzSK6CT6yfSHNys4wCitc7wzRO/\n1gNh4IlsSpU9CDhnTY989fHdkqk1E8Kx3GNkIoYgnUGnVfrmOEoHgRq6sOL9\nPGrcE6mynaK3OrGItCTUI01FAJLUYLljGGOAazGg5+lnpiBnhrYkw7CqQqTT\nomQzHzJyAaYD/fPP9BQeYWfMmmYIE6SkpF3245NRxIOEbNYFSrTFUT9FlpGM\n9sNLPBYyqZs05etDfa8MI3LGvg5JWiMrOxtP1qUH1lx2aq9n+MmKiAfvRP0N\nIXm6H8q43wxwZ58kpGdGSortmlMQfl4F9iM9z5toIgsvc7Ek0zulPEKc0vRz\ny9UBoGRz7lnjRQfzct9arVfxWS9i5MgzKcDVzD45tEUPs7PJl5LQ6K0bqdhH\nYdrXDAxFI/pXGWxNvG9uqEDlebE8Lju8zvbtrv9bx/yzKqMRNgrSdB/Bgz/1\nVx2v\r\n=t311\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a4839a2c81df08cf71cb07a1bbd7d8bfc25cbb21","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4c0ec6e-1604847720075_1604847814826_0.1242462905590791","host":"s3://npm-registry-packages"}},"2.2.0-canary-649f92a-1605296697390":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-649f92a-1605296697390","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-649f92a-1605296697390","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"30cfaacf2997b4d7d6ff148f499601ec8ce8cab1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-649f92a-1605296697390.tgz","fileCount":26,"integrity":"sha512-4+s7QF7x/MlcPzfwdqJri7sxBssw6sgw9VUJYZ3uZU0G+YXyv0zJHrVdS5ydyODjXR4k5RXOHxAAj4xo8G5VtQ==","signatures":[{"sig":"MEYCIQDR1LSIqB4oRAH8F06irFgW3deAcPkjsg2qr0hsOHjIowIhAIIflh2IdGj1CZoQXCy+0PSR3QNE6XVYmYQyiGgGxz6f","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfruKCCRA9TVsSAnZWagAAjU4P/itWru7LXr9Wnr0QVdrV\nW6B/tUzOCY1xWCmmdBGDE3rHtjmhs4YZEI2WhNIW8K5ziGpN/ygZu4BeZKax\nFChCNgxMrASIkABMMHj4kegtpGgJ9ikqx1tN2xY74X7tS+4DnpqpI9BW+5fT\nl3EkGI7IhbHp0jI7t6N5nCZho8XrO5LhBLBbkDD8d0iyGfVHUu77/4JlOhXU\ntKGbiNcIPyLhadbqPCtcIbStT7I6T2FwPUv7180Yf1x0P/SYwswVK1bWCg3t\npO8kOhY/RsH2OyDRmUW2j6EOX33pLzSmXjN12cpnQx29V4SD78hOKhGseXlr\n6P7So4gOm5CNTV/heXsEHnffhhjy7uvTk6+GYc1hyeD/jeW8Fz3V1PbrbgIZ\nPGakQk44bKQJvI2sGEOpeax9JyR1Zt3Y/gmc7DeDWSx/OX1J9VDiqsnTynVK\nrzwroTJjrtBjOkCtYXQZd3hEF5gYj5cyWSVtifyi4z2M1ThrD8tN6+upKvBd\n0mJOPXypIph6IZ8XSKNh49vch/Fr6eobgwimBKfQjdAy2JK6WUrgA4B/XWQB\nXs8z5x/xYx68K5nKuavMupzM19rVrTuNagOSgQCqGd7yvNRwcG0jIkAeukEi\n3NAvftzZveWeampFH3JwAP1Hw4COTDL+05iUQFdkccpAHGiLfpoAG4PbMLbj\nQayz\r\n=/4fK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5a3b1be8d50c24c768903d7a6a812cf47b4f444c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-649f92a-1605296697390_1605296769527_0.4270287036160969","host":"s3://npm-registry-packages"}},"2.2.0-canary-0269d70-1605363907248":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0269d70-1605363907248","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0269d70-1605363907248","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"10dbfa6588cd43e54f4a1286da9efd733ca54c31","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0269d70-1605363907248.tgz","fileCount":26,"integrity":"sha512-9Z4Kw/e7ASOVRx38WKZImljA/ptvI6Ai16bmJSSSjJwTDm+fe+zZqiiSApFWNj+uEj82y2g9zLPho76+3oeYAg==","signatures":[{"sig":"MEUCIApkuUu7nahOe3J4XIXpQbFzD9URERvaHve2LEU8my2yAiEAu88FC9mcUgKmoq9rJD9Vgy5sQnYuqIfJgG52jQf7Ymk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfr+kLCRA9TVsSAnZWagAAClAP/2IivSB/GCf4q7xXmT0y\nSo3G8NQqjnZX3Fg8Vn8p7DX0YRynCfJPyRfNsakTzyVaSlhrTaBaG0//HNsk\nCDLIfPo+4A+GbCLWGPo8MzlLcoUg3LXIN1GUHheZTz0q1T8ambNhLpk+q2yj\nywDr/mZO+f7+fDOFiDpxSjlV77Ou5BOmDmm4r8sC1JybpLsmScVbDAlcmEia\nl3UNPi70KqGM4JguLH3Q06jjVrdHO95Nj29nCQlMdHjer1eax0eAQNS4zXlv\nMd4okvPx5oWZNQfjDBkuQ3PRDJ3OsrJkq2Lv2QtZCPhbVR61fm+2OQ1ZYGSt\nKAsHmJTrrU/oX2gKXAfBzK7adJnS2o+fuLsr3+GAfRwv7NUD1CBO3YZr4wmE\nMD09Cmv8ircJYKwZs4r9CPtLmFomA2CwjlibmMe+nsLmHTd7Mnkean4+gy3j\n7PQALFuk7LXPCABXAU0S6q0YJqd3fihw9P5ofv02ywBuyxDPZPRPd/xkV74F\ny41DBkTUCZX/TGjTYpLHsDZWUww6wYETm21aZ15mCnR3Vs7YS4L+2QioB2/r\nsirLuJueVhuf7p8N1ySHISZKCtoFnikI8UM+xt7tPdSazTXZ4nZpUOKBJwWb\nQh1cmE4UY3WmksncY2HdwdDpXQbRimIFGQYN6w9S0SHpycxyN9DCle5MugL/\ncQxG\r\n=bpc6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d98ce74be64f069585491cd2dbd495c84770a21a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0269d70-1605363907248_1605363979195_0.8093040212911238","host":"s3://npm-registry-packages"}},"2.2.0-canary-3a58960-1605689035938":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3a58960-1605689035938","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3a58960-1605689035938","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7c6d1017b474a427cf236da511e7c10063503e2b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3a58960-1605689035938.tgz","fileCount":26,"integrity":"sha512-H6amcaniQ+zIA09WtMqY5U+4MZNcwJgvIo43L1QBRIHv9cNQ3h+SkIG06Wad1XISHE5w4A8cDPuuG/9Jf6ARpg==","signatures":[{"sig":"MEQCIBa+dGFSeQ03UM8ynzB3o6Z7JkFyl3TybBP89xBreZgvAiADSJIMr8RbK9iBIYJs4NHT5CR8dvRmS881IgjLSgmoUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftN8VCRA9TVsSAnZWagAAA7MQAJE7d/C9whB5Y7dSWVsk\nB1nGQJ4oj699jTXz6ksxbil9Zadkl5/mahaPw2v2jQUhrxpgkP2+AGbz7RyN\nE9ujlH9l/AeUoQm52UGXpt5+UNtfK2ry6+xHEGbhJNPYOoHT5axfqyJd7gCd\niIhnjggwZtsTV3P1hsQEc1LgzAzHb+3umQf6yo6tNcNXjkKLo4aJoEx+/JGH\nqUCqOkuj3hR5cwzljby2JcfdkCF1my9D9E/MEe4jBdMDL3XTy81iohScdZSL\nwuy5gN4Jya2lTuKtBh0tFuy71J1BFSsgxx1WEhnD59SbywDIrOVGH0HIePGR\njomTpQVOJNBwifl4k6lJkZyWxZue0tqtJ1hL8rOEA4+didmh3Ncu+TUi/1Zu\naSx2oL0Bx7Xekm7fRHdv3A2dZWaZ6VT6qPBOFrynOFtornrUQpN/oLiNPJrp\nXKNC/UMVMbAEhGjyAEfo1N9fAFhIUc3ntxkpdUOA70P2XbdZEvB6hi0MvQRg\nCxA8ppQX6A3ry4SrndxDdZBX3GyCPsiS6EiNSyyLu7sjEs9T4HC8nRDBjPJR\nXQWBB99SorE5zz/2Q6++Ficcn2YzD7Qbcqu3x/RVS6iO+ghrokdS61UmE8mO\ncHFd+LFSG3DSusvvOflpaXCKs6v7Np5fx/2csz4J9JciCQJONvjvxuHQWFyj\nAW1w\r\n=1Yug\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"66a63da278f4eaa673dbd0e3e6bde2e9ee27de65","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3a58960-1605689035938_1605689108923_0.8411465642900915","host":"s3://npm-registry-packages"}},"2.2.0-canary-2818c27-1605912879450":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-2818c27-1605912879450","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-2818c27-1605912879450","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b682a004c2a38469d3960e60018c42ad1e247f7f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-2818c27-1605912879450.tgz","fileCount":26,"integrity":"sha512-/xo3YC6zFcoH3V/KDRDi3qNx8WxZVjLtS939d/VPhrl9kSfOTN4RU+VO9SuJp5PuIb1k0CLgfkJ5tKSg79bOAg==","signatures":[{"sig":"MEUCIQCaLYKvN8WldWTc1k0cErCNwWLpsLGIpPFOyLA0JjF/RgIgchgMkvYBhkMyihLY1PJ1K4aaTsJyt3EIlQ9IWX48Kn0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuElrCRA9TVsSAnZWagAAkZYP/AmVP4BhWhXwh6qPeO3T\npqxLkh5smYFXmDyLi8lyaB5T9ZdtMgAtwMQq5U8wq3j0qX3mP6cnLN7BB7oL\n6KxChdx/cZ8U1CDbUfQT/3nHTGgqMG64gUSTJYa7KHy+Dypqvav0wnVyHSTh\n3gRz4mNqy4mey+qKGv8A8Q1VVisQvS/rFQkQe+kWO4AKJ0pnLJmlxYbqijR+\nsMg3eAGrsDlMHEkYarMRKXRwGCsW/Lvi5BTkKCMIcZDbPRu9YeUpWPtluQlr\nYafIOzCLtRRoDXXvTQER5Q4S2TqcbQ2/LzU9ANBMmduQq80kzX7J54FviEEy\njCdtXTMNWKhVyRdRGiNdGxgXwR+xr1VaGY6LoRHxXG9MoebkUu03T3hSJN2/\nvk/3m962Rt8DiWvbClVGzfb5DAu6dkyIbAbIn7U026BjS+3eGc887HhOAned\nslnb3nTbJfvIf6HnH9XcK3I1FIxeGTxPw4JfgX/j8PMp986//uRJDyV4Ltk5\nQSBufmL7lVHpuCKgY2GmIUqt72f+Z77U7kBBtKLqSHV/mCRmavub5ldqhfZi\nWc0vxgh88e9JvarQreT54Q40dgxQkitNacvB96SXHW5cu2rzbkcc5SXidaN9\nsWHIm4a51O51Dq9fSDwsIV3B4L7H9jSyq5KS9DwqpJz9d6JP6eQeFn9WcQ2f\nNKZp\r\n=WDhw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"35920c0e90bc61b310900f0812d874ed0a693cab","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.8.6"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-2818c27-1605912879450_1605912938550_0.5748359728060575","host":"s3://npm-registry-packages"}},"2.2.0-canary-abf1fd1-1606127243448":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-abf1fd1-1606127243448","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-abf1fd1-1606127243448","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"09a026611a0d648ae7c41cc52f1730737f9229b8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-abf1fd1-1606127243448.tgz","fileCount":26,"integrity":"sha512-A0C+Slgdvk4IwgzAKDsvlLKNHE97zyv7m8+2mjWeoQgfheSU8/G3UE1KjgdADGS7s8hsBJouvzo+kLQZ+SR2AQ==","signatures":[{"sig":"MEYCIQCede7DcPRUitJYPry9i5zxFjdCoXR6g7EmyraF5M18DAIhAN9nDC0o1W6ICOPT3pY55Z2tf0EW9P6v/z11f/E1Lyo6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfu47hCRA9TVsSAnZWagAATaUP/AhCL/dC/nd+iKt2/DoS\nAQN5Ju4pBamGRwJi5v+Iu39FpKyy3N/kgGSfU7mNJqRVm6hlbtuZkhxkg9W/\nXgOEEZJD2fYuCyDBAfjqrYFpNbmKsMTyG1s5V8T8krtUsSe9XvwDVDr+HdCD\nC7PXZ68zQLdYBZy6wpz0rjoubzPH9TguHB6Lw4Dbs7RXDm+3GIBGVVGEFjzS\niF0z2GVyFzNJ83/rIUofmBOUTmiEYDHrkDS5SYx6eTbliHuURj1GIIXQrXMG\nRppjca8yLn3Uvye6MPn9iV5bZOfTgXYF/l0qgvn8TlOEpakWuqzboTPANzmg\nCiHgzDi+YMX8dKLzehPE2B+IUCrvYdEm/OSDZiqcR21oqLU1KimnghT60QZ1\nNhaLOCwDK56BDH4bu92dWFq142YTHgH5RN2jJJkYDFB76L9z+i03WwB+qEav\nHtbG0GsSkbNSKn4je4xeXedMBpj6KsdBFGR/huk60YUgoItBa4N1my0FWKS8\nWVJWJo5pAaOlwbWpwBXWO5k7BOrK0ojQpo2rhJ4OuqAhJMtA3M2dvNxv8tfU\n8Kz8gZcPdpfJcFbhuBXMkio3soHSxIkrVSXcwggCggDT4nkXc3k6OuL27ejB\ntIMBs7l58V5l53n807qLIqri41NfxPsDbXS+ycTymgnOGCBsJ4X8y3TfEx5U\nUWRy\r\n=D+ZS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d18fc827203816ba0714ae3b9afe306c6a62430d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-abf1fd1-1606127243448_1606127328663_0.2596753288238691","host":"s3://npm-registry-packages"}},"2.2.0-canary-e5f8a49-1606630334463":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e5f8a49-1606630334463","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e5f8a49-1606630334463","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"270e9d2a3894d92173a40150b517f43a7e313c8f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e5f8a49-1606630334463.tgz","fileCount":26,"integrity":"sha512-BlXZI4P+xVFcDHxnr7H3D6IT4Ge1pahicqXFPUgj4SJ9cWpnxFipAlQqyC20uYOlTpMBk7lPoUSmQlSE0rCYrA==","signatures":[{"sig":"MEYCIQDSoxougnhWMQ9AycCT65HefV5bsvzklHMX+I9psT+KuwIhAK4Ry3+d4wW52EJkf7CziJyGwJb7uC4FGagdom842WkO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfwzwBCRA9TVsSAnZWagAAUoMP/iTw4rqCMqkpNqlCUmX+\n636vxj/Ytq7FELWUZxZdBwCql8v4axsGpjNh3ZReelWkwEv+GIBt3VxhHBX/\nNgdWa5ZjLvtrHsgWoTf8jRuPCsIwKb9MeMDwzaUR4gZnoDW3wCmUT0ekn+jC\nSNIrEtoJuxu8yiPqeclTs+KuDCO3f3jFuxEbCp3Eadoc49af2Fz+cVYWEIFT\ngNycnEwWEtQJC1/mVNbmr5cZ9TOnJgm2/FLAxD1GaMoaQ5g9Nl1yhYFhKw/b\n9C1MB4JOA3Pe1iW+jbmaGBQGHj3nqO13iN5UOtBaOfZ6f2wTFtHcOVWGf2Uc\nA3jiIaK8csGEtBdKp5FCq7VjAutXFXG3kpBtpyhOR0BWAArqNppa72RHWDpg\nI1Vyd15EvYiJc/EfUpaiq5rYNxfaaGuYzBy3wEz9kBlskhPUGmlmOzyDJM+e\n+skoqPSUkWYo6HyzKltIEuwJwskCkHKVkIE5SPgGO5BinMI7K7A5SOD0gg9O\nahTfhXwN7PVTaVasCTtyUOG6fvp5lpCetT56WAHmqQ7aRjieek2KttV5oxTn\nGNr90XdHJWqsrUuUFjooECqEyDJLvCc9rRxolcC+MoblxI6sQOZZ5h3YCyd1\n71V7eVA3Hbl7owEc9AFDy5LwM6eVQCD1W6TW4iC63Y5q3ejyjhhosaoPMQN+\nQ8UF\r\n=wtPm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"4edba58871fe8973596029e5fe60e5ab6e668c37","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e5f8a49-1606630334463_1606630401158_0.4412508478638568","host":"s3://npm-registry-packages"}},"2.2.0-canary-1a19017-1606761742477":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-1a19017-1606761742477","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-1a19017-1606761742477","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2bc7938634b30227b169c6630bf58d39cdf02708","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-1a19017-1606761742477.tgz","fileCount":26,"integrity":"sha512-0gk0EaXBRbOsZw76HISqHYx+ZvvVcB83SoFEuKHJO+yAcWUvp8X9L4XoqatCNomADsLCe0IPJTp+eerRgT3Hwg==","signatures":[{"sig":"MEYCIQC3ldgnxt+QK9pXsVrxPprHwbcZDM8neDWCBMIYeriZoAIhAKtRNLCs+MFCk5vcy+sLjdbGQuXFdOqXuTzjmt9jgrvP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxT1VCRA9TVsSAnZWagAAj3cP/2IvkrOg+rbwIPFMg7lc\nH+hIU7WGxI290OvWS8unhcJdqn6I5tfzQjDgwQXyvqZf3RFMBbsfngFNe2Xc\niT6Gyx/CHxUFsvx3qs6lyqWMxV16REbyrkGX9k2zBQc9eNUxaCkzEYMcHz0W\nkDOaTqgJYQwRM73PyplTuD/1xG+RpIi3mDFHXkhPFYur04vHwmVkiIwb+jmG\nuJL1irNMO9EoqzR+7S08aoV59K6lOloZAp1pj6NHBuUfwptuSDGdN1SEUQKr\nzDDdoXgbqrdcmLkcXeF6vmDfNJcoOi7BE5soCFIyjPy9cirlk/UAF0V7nYYM\n2bqJ9M7bSOwTinAUxK2YXsA5MM7BcxudbkVBK4KApbmapuSpmOAIteUfOt0R\nZpYbTE14uMEM7tugyoIfo7dfiORcw3tH6XOeQSWmiBJHUhTHJkNVRIlU0yf8\n7fvddo0vRa3vThUEb3ZMlYZuf2RCfLGsoZ7gWP//mIb9cX/q6yJOar6wmS65\nX5BhXXesLooYRAvkV0FVF6Vf5cH5ZVMH6WxYHSLZO1nAFS2Rm5iSNQ7nwZeH\ns2zP6r3Ct0CKZoSVJa8pkp7TqMpS1hynRHFK/PPhM3Ob3UmcPezBmmNFtC8e\n1SenIqMDGNxqm2JNLM8rhoF3Mn4I5FNGzY4/eq6MTIm8CjGkiuCWVndWfbp0\nnicq\r\n=X6LF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9735771ce368f146b7eec0d0617fabf3f39babd8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-1a19017-1606761742477_1606761812592_0.3394329862993255","host":"s3://npm-registry-packages"}},"2.2.0-canary-03ae7cb-1606761947043":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-03ae7cb-1606761947043","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-03ae7cb-1606761947043","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6ca6ea1f5a3ab3d0fb3000e88916f5b0a7a5edb2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-03ae7cb-1606761947043.tgz","fileCount":26,"integrity":"sha512-WCFz8lU/Ip9uvGF/qkwill8fHy6eyw7I3jQSLeFU922gVDhMEP+qTXlLZurvgesskTORi4FOwHzJ3xcIgm0rXA==","signatures":[{"sig":"MEUCIAK8G4oaPpdsoC0xjpR+NlKYNuPPk94HOOuCo/XNIuMhAiEAtETUfVvAVSLAKCawwiHImXWRlJhTVbPsdwdrkNYhbSg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxT4pCRA9TVsSAnZWagAA8IEP/2Ri2ONyHPbL36Gf1fnV\nK/7GeUwOQFOLISMd++m3E6ZPSXMsRHvpX8bLEeF+yOA4ygG3BjUOAkVOeGg8\nCG54OZxTheyscLInX5E7jrIedxmhhmQltnHsd2juJZUQWmhINU9Ia9SEQfyf\n7eM913ejJfddka3Zd5YGOOZgNgXiFGg8NI7RA0j78AoofctwWCL0hk+FQoXW\nSni9HXW7FSE9WhQ5ofJRHJTBCluju9vgaBRU0SoXVwqwKMUHoUSkXaigj5ZA\nR+dZbsVsUVe7ZbATuADQ1Vpu60VzkT/r9DvyloKOfV+W1jigFTR3WrKMX094\nvuEfd4hzWl/b2T8mG83XMgWOxecS96ed3Fn7CMzENDvKRKb1wNJSsELVFsgx\ncHsLLOuzzmQuPnC1/dlz6XgI4sTDoYBsJ0sXBD95wRTFu9DeMIwFa0RFZ8qz\nhK9VxqkCfzTlpjGcK12w7LRVdMCfnZ4CUhSKcohsTu8GWeOX92Ecv5PM8nkF\nKh8AW4cjWcQ2Oyup3yPca/hoKAFLFaYGhcaIakU/FavKpCYwIDrQOPhplePM\ntvxwIpy9z6KWMHozn0EV2FipeiHzmggQoYyHgJnjOgjYAp0rDSSkdqS2XkfA\nuEQVL5APETaOXOOgU0pmGEzO27yZcBk1jFaAkn4YbUzAo2VCpoa55x+ZCMgo\n4z8i\r\n=k7fW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e8e8497c2df2d3c894d406142b9864595697b1d7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^10.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-03ae7cb-1606761947043_1606762025310_0.4436506756705565","host":"s3://npm-registry-packages"}},"2.2.0-canary-a4ef415-1606808719187":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a4ef415-1606808719187","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a4ef415-1606808719187","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bcb34319bff569b9a698f792f180801ab110d45a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a4ef415-1606808719187.tgz","fileCount":26,"integrity":"sha512-O1/L6aX6Y6ItM/F8rjhKqdBotSw5QbzydpN4D0mQ+9EwxbhLQZPkIG1UZ21/PCcbHZZVzvmhNmrKIvVjfqrkaQ==","signatures":[{"sig":"MEYCIQCi/J0XKC+Ss2xsF62FvUhj85xr60TO1Apb2PIc3PCcrQIhAOqESYV+OBH40cf9RNh6fbI4HbpbOQvSLGNBiIE63Co8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxfTRCRA9TVsSAnZWagAAOEIQAIMOUvO2nIq5O+lxIMUP\nEHp9ecEiQzYokv6Ov429FOXmgKFvRFwocH06UoIEQfzirAV222kcwCKqVsGj\n3F6pIrFh84Qt8eJol6u1S2kYYcDE3rVJpRemxc1b7kOZv4MoDSAW0uHgjhLr\n4RZw1vvij5kgTjGt/tvrIJciv5+g3R2ztks9/P+6+rogUYyxrdt8PIKVQzTH\nf854TOyNul21ZNOg1C4fe3qlRhTDnO/KE0O+IWBT+lTnpTGgZv/mtrOwjOI8\nrfKQytFfCst4GO4dtDvg51x4D3lNzJrQMpQtcaIvsH1HvzVvEoAAYbmqWq08\nQO+8hIoRps2xJGSiLPtSKmh8bHts8nRKZTcrbca/2LeJVPn11lmkVd/R89EE\naqNqzPufO0/QbRD4B8hITp2Dl40gCNyfWw+TZC14LeHN/bsBGTUxe7dow3aR\nMFQMCqpknznJ3yUx0Vsld60csAtLno4yLELLuaksiKlZgPQ09jVs1P7qLgot\nkwjUdEK5VoI0ptGpDmL2LZADHxTtCBdubpSn6GiYvLA+4d0dZrTE10h4bWnR\nwpui4rjnzyI9w8eCzpZ2A/ZAMxXYqJnmvFg0jOU8ZIms/4jPDPP64hCguC1J\nZUZPlZNJEDTIz+hlyOBDnND44ntWTQkBjvCNzAJZRgKQhZ/lGDgceldlYkwV\nue/C\r\n=DDqW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2c114c5e5c9379ee34fbc5fe6cf0f96109edf557","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a4ef415-1606808719187_1606808784883_0.5700601554151556","host":"s3://npm-registry-packages"}},"2.2.0-canary-4657432-1606841187149":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4657432-1606841187149","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4657432-1606841187149","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b4f27cf06c1cfa8da31f490a4973ee3f8c4be617","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4657432-1606841187149.tgz","fileCount":26,"integrity":"sha512-Wmo09Mt9xv0O19yUWrabQvREzBNo+a7svv2N8IEa8+rbnoHaas53u7XJiOHbs3gfJc2qjQBimclqEQMIWnQehA==","signatures":[{"sig":"MEUCIQDc5gaxgn/JJAkC+QFBUviugCGspNFHvRUKp5Vu1efEPwIgXWkm0VF4GSlsf8jUSux+T8fMdigkTvTM8PKnDxyT+D0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxnnACRA9TVsSAnZWagAAYjAP/1tbuvNejY0/kb0e3RaA\nrcBfr28dxF/H/x5nMvgr/5ZtDntnGmj+2mK/o3X8+yPEWZbJV6SioGmZLnTG\nd9seYUhivqXWmhsC+HPNqq2WGqpfbV7YQjI4ex9/3RDkjv9SZZQ4O2vRSreP\n2FIxPKRLwwyJhfz4l2hj0WKDpij2hp/hkZ1Kz5njcmqBe3CAzlYJunn74iZD\nielpkQpCf+VDp9RycN9wuJYh81k22r7F/1GWKHf3MjBbQ9fOXlaSe9jNfP7v\nsOTiqNcC2HifvfMHBrfoGAix8W3oiFTrfclcZDySVIr26tpWZdGOggfFxR6n\ngbaD0DALjgDcDslLGDlduZmgE7b1W/pMDHrD0Hv91jLTZE/TlZDr81qQlUX2\nn3T534otBHj997zhF7UHNX7R3pgS32qTfqdfmhpynIuPSQLuvbf8dHrZLOoF\nA9MoeVfSHPnkWaV0ogG6sZl1Dbgu3om8lfamfk6ZgWyWCp3kVF6QXSP5CRCr\nksolHGoJfgi/xwfMRbqUVaLqQI7bNE+Z2zpAsMxyM/8k1ufXFGlae8VR3j2Y\nWKzwoKWUOFzoCw6TkI+l7UQL8R2Cj+MU1dh/bDmzIe4RY6ak2UpCGFYhn2Z+\nU2cHTUVOiaqkeN34T1QuY99vUqQ9jUVrEhiL2PfEF1JmBFzZn3XtEWsPY3xT\nNTuW\r\n=8147\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b36407c47fd5fbf1c9328114909a6f76f45685c1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4657432-1606841187149_1606842815967_0.486386694391846","host":"s3://npm-registry-packages"}},"2.2.0-canary-34f02e5-1606855294419":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-34f02e5-1606855294419","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-34f02e5-1606855294419","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"870aad7147845b64b78d99a479e28184059e25cd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-34f02e5-1606855294419.tgz","fileCount":26,"integrity":"sha512-GQN2z9hxhQMFDOhMJDiLKeqizh1FoO4UrwLxSu2gjGL+T+SUViVa2HuwQtltap5/zdLlaESi5Xs0rsLLeO7IAA==","signatures":[{"sig":"MEQCIEod2ISQ9CRUBBOr1wdPV550rdgDrbYBZu5lOYxHhuHBAiAbzQRipxjvy4/y54F2tOo4M/+F1oUALjgOG3tgAz7PlQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxqroCRA9TVsSAnZWagAA7MkP/iTwGdbMhUEu0xU8wspJ\nK/ueMQjkDF6CvxyMw4q+KQJJuthqUkybN4ig/CWuJwwBL5NZcY19LY5YxdoN\nbUMOAiLficnc73c1vR2xwNNhqDNASn9m3d47kb26vwsx55lKl7MhOjbLCJXJ\n1BK7Kq3uj2yg5v0F1eAFntQhgrJywmiQcZPH4NvUgQRfs8zEOrX1YXi7SawX\nXu8Ed1Dt740tf1TT9k/ol0jfBZD0/VzgiMNYrADuxPV+K6ClHm4WHgqbjrYW\n09CQT+bV67BiKcKDVbFEODxorjAgsk1dChmBG2SlhMj42BQXr7vt9O22wL4I\nGhWPyijc9T8FrmPLyf7RJzJeFT65laKUJ8WeWdMA9QpHnVAO0lAga7D/mcWJ\nm5nly5aGy4T9DjZg0O8t4AwfkYJYq1Y+ChZC9UkGA7hCqptx0E/N1RGGWGmN\nW5x32NJ1ZW8LkEvwqqVVgJNmV58qRREnWVuaF1uBcLcGyG2CQ7JlDcmeaeu0\n4lT5XTQm5lm54Oznlw0gcjG40wQrwKfcHfdkuJbbXITckWKtoDhS6bBiHW7x\nH3UtwBWimZYXmBXl1AHnrgw+t8P7o0xtGfHYMWsLDz01dWrmB/pmebHS1yiv\nOIDfJVFpSnX7KtimscD/u3OX2A0+jgvZtWomxrHjP8dInYl53LatJGCjd6tO\nIdf7\r\n=e6hg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1926e67467d7e4997cbd31f9c033324cabc9c7e4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-34f02e5-1606855294419_1606855399578_0.5899363572468632","host":"s3://npm-registry-packages"}},"2.2.0-canary-4c47c9e-1606950885027":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4c47c9e-1606950885027","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4c47c9e-1606950885027","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"92a3a9fd791be331b58cc696a1a63e96c68da026","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4c47c9e-1606950885027.tgz","fileCount":26,"integrity":"sha512-Rvnfmd6qUZOyzX5AwABBgkjyx9xDCcS0SZHXdfcnsxy/sCJB86PXriJaUpefSPO8BEZ2iBx0BJaVL7XrUT01pQ==","signatures":[{"sig":"MEUCIQC7SFqwS8HPkRblN7KhPJJpP8wWm5kRB1GunIawdzoPpwIgfNJMlZzkcHWhfV0q/X9Chggpxd7QXJpcKfkhrBL+YZw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyCAjCRA9TVsSAnZWagAAzfgP/2aHvwPFzt0tP1umiA2R\nAtPi3MW5mdYyDbLh1Mi7oypTD39h9bqenWMxGHfRuvlNzmlkjTPnBIuqRfWg\nQVg+KJdXFxgKp0uq9XbVgq0ccjlj10SC+iPDhc2OO44t2yW+cL9xoNIVqkl6\ntynzed3xlW5mF5UjQrGPSMDARV8xuaer9QKM60+EwyEn05lVReRjLgWHukZV\nVuJIQ4Y6fxlayovbPdBY/ZZNKaHsLDV7sAFZu3MRacABUmrL6/5/0dcEdY05\nQETxQNWzvgMlR1Q2Oldv3nCXV2Y8T1UydEcDTZ/GiNiWgbO8WnlkB1Voaqwq\nl82LkTahYn5nrqZkbJxGB5ZaICxXUN+s8AW4B4ZRkazA/QDpEMbuVPM8D4JN\n648mg1lHpDgR3sDJDhd0VNGvxG/byQyY96eEsPqCS+WoJtTXRxDoTGhW4JzO\n1LfM84FckBQKslvqWzHf3EgzuqLM04U6XFl47SuZ7IB/ZkXTU1YJn11lz4ad\nQemLi8GaQakerTJ48ZwuXSheLfFma5Q/R/x+qu9PTo1NrjuL9+Q5QzkVY5tu\n7IaaSuhsYZyNqsaAk2+2AkUAgAzwxxDtlO9nklixTtG4UyMGMgGwhyiG29Pk\nqk4SwiQcbaa1NgvcqIKlAM41uYPe437436sTv3VHeBHRKMMUYxo2ZoGFcBXh\nl1pz\r\n=cGQP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"06a9b1d6dab1bd1b81014110c283ab04cf7918cf","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4c47c9e-1606950885027_1606950946393_0.19818650069819","host":"s3://npm-registry-packages"}},"2.2.0-canary-2a58588-1606983746775":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-2a58588-1606983746775","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-2a58588-1606983746775","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a93a07bbf8c591d1048fad4f97eabec29d1a9cfe","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-2a58588-1606983746775.tgz","fileCount":26,"integrity":"sha512-QWBxX+LviG4SAAlXDmDt2GQDlclv9KDkghRDDFYbBS6fvYU+MtlF81ztMaGuK+Hzq2EBFexjJsJuSuyIrvfl1g==","signatures":[{"sig":"MEQCIH976GiHEg8NFkkjC2P9Ity+cpqmuZHj1QPZTCPJUOFoAiBYLXzppNd3j4p5Z/2QshViU61/WrQlwwoy4NqvsOIH6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyKCMCRA9TVsSAnZWagAAzsgP+gPQwFDsSVAoejRc48Qm\nTifa2dcIKX+INPCJ7mzQewQSidKwbXjlyOzlFrEsk2QhCAlGL1MdGGFP0jgy\nknR/fNSAxbm/bcNQKI0wc/aIB3YpcW1TH5fhpoEyJqRnjW3iFM0fM2PzipXK\npkxgwH62Aq9vnY9wjLeXhpl6/cfdzQ26pYKiPNXJ+/9K+frbDjIqcM7mywmu\nO3Mg/cdYa2eAx6UdCIx7FYWXeh8ttZEYh3I1CFalLSm29bsSX5rVnEzp7GYb\n12TKJ1pu3D/BF3SnV4hOkLihO0e4ZkL3VvszrrOzhyRBNgUZt2j+ELMCYf+Q\nbxkev6KK+A/ocBpkJ8l8n3Pw/qZB1wVCNZxUDNi9Xg87f/Un0Ux2cxd/Krg6\nz64yo4IWJi5tFfkhGOBy4pIX5vh26rHDsHRfa4ZJkDFehcwh6A2qP/f2N+hV\noipgCcoboMGrKqAQHV2FXAn0Rc1vEV0+lDxo2gOG86d5S8AOArT9G0LrM5a3\nxO7F6nHNw63+9hyn9eqyljrck4H3fHb7WXAAQAL4Ske4Md4jl5YJWwxHfjl+\naIxwUY4mQolY9Fp2hC9z2Nt5N7WBqpuVSSEaGIuABwqCPQk9T6QZh1tKB8wC\nafeC0HSj9KYeInnWI8D1CPWUgEK4GFUD3XwgUr0Gr8zy0y3EtD4WMlQIzk6y\nAuHy\r\n=j9yR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d8dd967ff4a146a5f167e29a16a7bfd530b18cac","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-2a58588-1606983746775_1606983820436_0.07385296103035","host":"s3://npm-registry-packages"}},"2.2.0-canary-0a39bf3-1606987459278":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0a39bf3-1606987459278","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0a39bf3-1606987459278","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e7cbed01048cb710a93f8d853bbb2b24318230e7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0a39bf3-1606987459278.tgz","fileCount":26,"integrity":"sha512-xEU7bQsdiXFUzn/xH+bYh6hhouYfpLIaUwZPbsBXcNwhDzpnkhjmtN6/6REwwwn3iiaBh7sp0t8zSQ7nel9fXg==","signatures":[{"sig":"MEUCIQDK0YBwjAj09A77cp5hVeuWjAn5zduBnpbVdxyC/3tyCQIgfcqIRwODu4WLtvH518E7RUruJT9EWggODfEwJVGZid0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyK8ZCRA9TVsSAnZWagAAUSgP/2uRj1eK4Ed3E9QpCBNw\nRTmJrRfLfVSyFNIBGvY7TwAou7wuftyEIzw/w1wxkOkSjWnWS/BkjXDJaZV0\n5XI2ppG82tQLpOVi2k8Kg7+oE7EPqGuypNniKRLROZJyekXR0GscX5TtW7oP\nOYmMhBgZ9kB8mfqexbkAqHVie4o3az4DVaE9HfJYBNEbieT0z2jcddehrnP7\njFsl+1UZjfEgl+w62T9n94z+lrHn5dKimBMR775fpr8yhzBcjbHHrOQU8ydn\n8DeZO1FXGgCxzUnGu8gDpGhhkq9U6jIiR3MpXj5bAd5bVjqKCrZAAVPlJww+\np6PeKXLB3QCRtMfNOekJvIwbWnkipYIVWfV5U1p2lesxb7L+lfT5mmpNoCCH\n84S7aI+gzJNzitznhRNxeDaXHBlt2iI9bzWetoEDq1XeQtUhOEQR6WuEJFCK\nU1iztbeD2JBnVPM7dqYi2G6jSUNDeHxGUTU8lbbWmrgevTJWxNH4SXPDSOAx\nBRltGu9Bc6Ptu6rFvGvCSDpIoU611Rx947tBvAU1vrGQZsYJ5kUi6q1NKwK3\nWsXvBrbQvN179qOYmoLONc0iII3TOusbMxLd96t5GOD65xc9ge16PJVruBTe\n8lWp/ekqrJiCk8sjsenT9PerOmCoSyl90rlqvzXnYj70i4tAOJRMZczCbIOj\nBA0j\r\n=qC2A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e8c1790418058b279aab49d2c3bb122cd60ddf4c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0a39bf3-1606987459278_1606987545254_0.13188578434424447","host":"s3://npm-registry-packages"}},"2.2.0-canary-8bfac07-1607102133763":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8bfac07-1607102133763","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8bfac07-1607102133763","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5596d7aa3afb848350c83d43ff1f0c9b5a17c063","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8bfac07-1607102133763.tgz","fileCount":26,"integrity":"sha512-TqFy7vPYqA5pkL5+UxWI71v1F3IdW1a8vTPD/zaA29lhIoFLJDJLpNQxyN9KUUE73huC7HI3FhVV/V6cLd3j2A==","signatures":[{"sig":"MEQCIHrFJ8Xg3Nh8DHMfqscgS9HBXyXodrQQR8GoylDH9Ns/AiAhRE2HhzkNjDMwu97KpvOaht0HPgu/VlMvlUtsb8S2tA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfynGECRA9TVsSAnZWagAAFwMP/3H3kfVjs5YnhsR+vJTR\nYoCvi0hbuF5Mn446gq7BbG+Nzn4s5fGQtsXhRqpXBLyhRgs8Nsj1iguZQVM8\nAfemaoPXguFZOi4Q2q4krDy5cTPlBQu78nXs1npw+CxyNGqU1iJdjP49yt5E\nycqdgKihRL3J5UD5skrmFWQT6FQCvh+9rDyuAvbHpgdU2GpASJ/UmwDQMmn3\nU8BSKlewLnIvDiBWyLeFP8ET6AC6v7F236RfsIgTdWAXitZDxezV5D32/0ul\nOxeimXptXlfPjGF4A2kRhaD0G/uZUwM3YsAoknTTC8jXzwfCVdPJvjCMnYe8\n/2NFRyMS8F1pR+2VIqEepf65ls2OeFlc73UhNj3LN01EG/34KrpRn2jyXyDc\nAXTgKTmHAtFHeOpDtxkcJjrxbPboe1hjyeuxfpbg0DUSSbfdCmwTn20KWRnv\ncq6QeA/ZCkTG88xd22oj5GLvat5reTUAHP1AZwycJs6fmPwyAX4azQMlTjR7\n2NGdbP47FPupBFlztlCQ1q6qNjKP5/0nw0BF8e5AfwQ0FSRV6VfpnRJqsh8k\nSWG0hmufPJ3yQ0vAG0T2G0ER7N71UK2Bu8YCwP4OQAdcNcPj0ehgVBoucru0\nQmcW/tpd1hPrK8FzmjdXn77QHfQlDkK7xns8oLy0jjuziOaOOj8/O8nJz3lJ\nT7Zn\r\n=D5y2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1b1ef98ff413f34311fa57a5a2478b6089297661","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8bfac07-1607102133763_1607102851787_0.5957553233538031","host":"s3://npm-registry-packages"}},"2.2.0-canary-0fc3a27-1607111306546":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0fc3a27-1607111306546","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0fc3a27-1607111306546","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bcf8aa9308c29d26b84ca63369b55de66854cec8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0fc3a27-1607111306546.tgz","fileCount":26,"integrity":"sha512-8itzQzYd7Uvrv709zLjh8Z3ZtNy8H8zCbhn+MCgkVPofzjmaHfpn0yPVG63KOiQrTtRsFiD7wMvflxNCj+yuPw==","signatures":[{"sig":"MEYCIQCLch0/0O8tbCkdr1JvmS2ziV0zxhZrOq9vebZD+vB5QQIhAJiXMa7LTFt4lC3BwAXlAHL/n2a7N4SrPPQ/btXOPdHS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfypLOCRA9TVsSAnZWagAAlzYP/1hoeWidiEJY4XfYRN3J\nvgoInxj+VsP1QNpzhsr0V8BSF8PnIp3fIrdFYcpaS61xqv7S2x6r/zGfOi+2\ndQDWkqz8JWbxU2nsgpzGCC1VDVDvGpUzGiUqLZsrbp+CDRrRmx1E6USjv7UV\nOS8a6mHsQgNipH6vevgVVfRW2RQPW3sE7NoD6UYzXlq6uzoHhqW6HMEgRRnc\nnGaVktkd5s4a7mvqh2J2YpavNy9vhQbZUK4z3X/uPPkdfmLZA6a6cL5JBrJg\nvCGHmw2jtb9x4PEmu5z3eVPY2AV3iqmdpYFW0YPOSYQWiYanoTZsFXcl9iqu\nUydiNRGu/G23pb536kvqIdE4HpSNJa6s3w+ENjJCynjIH2Gc5rQjp4o0ShDv\nKp9PfwPoB07xjjnA8pRdxzCwQ8vLzYqE/PvPQTQ5M6MZc5RLIMCXzbj0zqGj\n9pCCX3IdeBRQF4WPuSz2Bh66XE78IXavK8w6vVsiW43DcJ9kHPNtmDQtrqmS\njAX+1BxE0ADx8PO97FxSNxngnIlYqOijflL8V/y7Vcb+kxuDSkI8vPQT+ivG\nPSwHTR8/jB94o505D3RBTn80jNGEGiK7MER8a84QefQJDLonTRqCu1Amse+8\nfmhHcCvxDiO21FTsvaNiKedbKjyodpPoTtdWDOsxvqlGCVJqYWQBItAWbBeg\nQVJB\r\n=bU6f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ff00386185ef1cbcb5e2f997976653df2dcfea36","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0fc3a27-1607111306546_1607111374173_0.4633036257410037","host":"s3://npm-registry-packages"}},"2.2.0-canary-fe4a88a-1607156320137":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fe4a88a-1607156320137","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fe4a88a-1607156320137","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"04c3019d07466c54e5f955cb8175912e0a196115","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fe4a88a-1607156320137.tgz","fileCount":26,"integrity":"sha512-S3XqwD8XuKfI6auPziBq9wyaQqCny73l3WCgIeVRAIpkhCs8n/Wc/wzIOdfyTmYUNlkW1pFyuVmtEjR/PwhFYA==","signatures":[{"sig":"MEUCIBegSJ1CiV16rq7OA1bgffCNock7fte8+p7qqzvLvr/CAiEAjlROwj3eHSrigq7NYroT9tphB1j+JFUTP0JRQxiQIC4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfy0KvCRA9TVsSAnZWagAAQ1YQAIH5UPGpgB4KreEIGHCN\n7tqi4MftHk+Dppy++Fz/TfNmtepIb0id7pZi3/sG41emvvN39pe4kCDfwVKy\ngqN3/2wVcTcoSPraMdkV8EAFu/6DWuF2xTJ6DOLI75Kv2+4JnvOeMl/iNUil\njCI66NE3yRsvLACbdxCLEDVt5oGm72B/qZljWWAW/Ll3psSB+YhZGSmCUddg\ntUeWFVp7Q2jdKVNm8fKo007TLv6jFKsZmzop6rBvQowkt1NovlwyW2rjxa6p\n4ZdnFU+qe0OWTO293lsrVxw+CxRXCadalmOaz1TT5n7UqGgk7BPlIfUqVa7l\n5W68huDOREr4bWJWI52PKT49OGJTOLxSiQk+qE9Lp4GMgt761lRE6ahXvHvF\nL9+Kxw7Tld493xegGBL8NXH76Z3FSON416o+rto3HRjBSjjQVkHRwtb2ONvT\n6/1oFqT5UyoiUpDf7jjt9bKefnAHtIhqCNM40uajRvYtRgQ2uJ37FmU8Az3B\nEiW+1mKuX0/PAHTFLubVfD05NGbc2VUl+2Ebt1ZP9lwu/jDH0FB08R/YA9lQ\nlUZv+dklMJf/kcOG2lIPODmtaDwlvvOKgzELsEnSlc+aVNeb36vhz13U+JU+\nb5Clo+1hqfifYIeLEW6VHtykVa8U2gUMXgMpB/wHCqLnBVVguEemLgNuuB77\nErgr\r\n=egPK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1cb5846154427b7515b741475eefd0cc8f5a47b8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fe4a88a-1607156320137_1607156399011_0.0630104169939294","host":"s3://npm-registry-packages"}},"2.2.0-canary-f0d04fd-1607234492522":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f0d04fd-1607234492522","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f0d04fd-1607234492522","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a503a2610fe7f20d633298e5abaf7242119aa523","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f0d04fd-1607234492522.tgz","fileCount":26,"integrity":"sha512-1cbYYKy8TVr0ojgEiqRC+jE5ODpPYScqZGhLDhuRaKw/NpUiBIhTZTcNHqog2VVw258bx8vNEWnJt5qrjSNAfQ==","signatures":[{"sig":"MEYCIQCzVggQ3d11Nm/5NSOMeb6Ibg2Lmv7oHjz5I606nxeHBAIhANIYWMVEQzt1fzFsvIahzkYK5CIY1GTdxNZskQ2TX8e3","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzHQICRA9TVsSAnZWagAAGpwQAJAROYGQ9dManYKM1z6i\nw3/yPK6ymEJ+QOXKMNHfcDpaiMRqwOif7FNSnbe+S7D90yL380VlcEE1xbS2\nhz7ONHT8JY6Tt/BzlQbKJlT7WJMiluJfWyRaTIMFMa1F1Jn1zJhOtQ3jqN/O\nUDIYt+QPAxqC49vCibzcGv7NZX+XRGj8uvPq1B37uePnhThRzSSabPtEy2cz\nhpraMMraJLIeV00eQYltbXKBwGUH1kzjpcMbtvgN1GFC4y5A1o0p6mIPr+uC\nU2KbUciYcaNggx6ynK86KPu8MSJaUuOZe3ZibkJAQHuJqhrnLe+XuAvyp2KF\nKDhbVJpvjTI+GPIgcUtiWnkaxwAVImVHJNVexCi2K/Te9vRKsdxkzviu5U07\nUTU9pLCeTbzJ9GsrugkL0gUTwl6w5aEGWBjpz9tlOfg5+nl7ioiu55MsEic6\nr+D47QVJOaH/MgfsIYsd7Ouq3qUK0bpPeaVciYJbBlmZJQnKDNsq/7/Ol8RP\n7vtabq/elIGK+L9OOpdV27UW0Q5wU9nicbxEHxcOWqiMldm1DY7aU6zlnCeb\nrI7eS03la5c7ZXVo+rjS3hwKPEzAK2erCzA0sJGXGCTWs5Bu/KfL/0whhGdU\nFJE/6COLQrmfYDLowtehHxS0GK+MPbCz1END9EZ0NgP5OrYhLWu39vhsYyX8\neP0J\r\n=XTR5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"cf8c540d8a9d442f225e59e83524fe52243c6867","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f0d04fd-1607234492522_1607234568398_0.7460222874967879","host":"s3://npm-registry-packages"}},"2.2.0-canary-d7cba96-1607405150510":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d7cba96-1607405150510","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d7cba96-1607405150510","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"49cb12950c2ef23cf749541e4a43c314acfa8aad","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d7cba96-1607405150510.tgz","fileCount":26,"integrity":"sha512-6lwmx5ssjLRvLj5L8Y/4ssJ+6rHCmfGaTiRPjmBaXC75qYzeh3k1064UyFkcBN3968txpedzSUeGYx8KxG/4MA==","signatures":[{"sig":"MEQCICzDq7XGXeYjIKeg5D+MMWFG9kMC0eSKCK1Li0UzDUxFAiAcRQNVCXT9iE5U0PwKGVDqfQKFMstBYV26DetilE09Kg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzw6hCRA9TVsSAnZWagAAEiIP/37H+RCJJw9JuB1B2Qj7\n8WrjwvLnJY7f1kedOeZM5QW08bON6qZmwbttL+K8tcIUHxpOKvw1PomLZA9i\nWDDiRZeoG9pjVefczt1Nx/GrDU98ouPOuU2bFHkzwK1LhWu5uvm4sgL9sp23\npxcRk8YRSmhw+2Y0HNOJ/A3SIsf4TG8uo6RqoRlB+YqzArOQizGeKPI4yBlN\nzs8bcm1c+7rDTxuFjZYDS2drSmsyFPd2XPngjFyo+pneet8m/HhcPVih3p7z\nQeCzmuYxB1Ijy7HlyIhuFz0UF3Ofe57FTpraP4go1dzr+0GT77/ou903C3PB\nwRCF/+D+6JKExJadozbonWp0HvuqKbfOy/1UKO5O2wlxiLe7pyEhuMOB/tyV\nKb6EsN+EFFd91iiImvSR3SPLPrsT2lV3BnisV6Nur6cuUVfE1wJKCUZsl5qu\nrajrBSEiBYlxnXq06Op9dm5Nv895VJq/DgfroosP0oWlzKRQg+7NpBw7td9o\nU+PGT1MzfoTOPiskrDbmLJBkySbgplJmM8vDuP69NDk6yD6Y6ZPts2+KmVVy\nKIFQQqob/WvO6fPn/oVqD1RbMtSw9tbCM2WFADjR1kaI0R8Y6GjLSPG6EdY+\ngoy8dEUcB/mC3OYtjec27fxpdRPiu9rrgDTOQMMKzsFweRnUW9h7tRwukJ3M\njRkv\r\n=WAfK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"016ee4df79c37a4f29b1eabbefe5775e7e0ebb68","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d7cba96-1607405150510_1607405217174_0.2682725315746326","host":"s3://npm-registry-packages"}},"2.2.0-canary-ee6c443-1607461356691":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ee6c443-1607461356691","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ee6c443-1607461356691","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4d7e49532968562531243ef17bbb6196d017f9cf","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ee6c443-1607461356691.tgz","fileCount":26,"integrity":"sha512-ciNmSDurzIMx9a85/y27DafOljZYckUkPuvxTo5y99Dw1O9o+VAC2wlwZRFM63Ox4HagClz6q4/mh+NyKaxMbg==","signatures":[{"sig":"MEUCIDdjn2TAz46t1JkbzYr8TxyoN5KLxg/IGUEzIgNDbhBpAiEA3yKhbzrmNWQhUDxHZ+akQJmXBhrGfLkaExnVTb8peGs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz+o4CRA9TVsSAnZWagAARlgP/jBVGpie9bfRG8j0HhRK\nbcIYbCOf7heJPbphdgWgaTn/phTC4Fns/01M2PmkyE3oNcUnEPAC/vrb3y+S\nIgPQy42f3iYH6fP1pta8f4mbWfQl4JbR496jMZQt7iyTXsujkOTWOIG9/74y\nL/9TydVUg1sB1Ecbw2ei5kvHHSziOqsylyZEynQPMy6NF8gHc3UqFbpVYElB\no0NPidblDqBIkUmpa05sgz9E7HHm6Eoe7EYpKBsaQAlr5F+ND32e0ou2X2dt\nSDeOQpejEBGGwtpQnVjg49Pkwq3RT3ThNUu/i+anDnH0CvUz7qRXbBJcDiQK\nUJ65FYtBnvkGIpNwbSeDIaZcupOt0B/NynjcIJJJHg2nYfDvn/5KaQWa3jmU\n0SDeNq6y233ZUUhON7YDUIz50gAShOssc8hASeKTYFyUJ/MbnmfGf1ountiW\nkcb5xy16WsjPFon/Dqm2kk3qPAgMRvAr+N2brx2grjiAZwPjL3J4c0CKt7we\nz2ECScG6YFVRACv3m+3kDs/f6LFgoa+rVvJ/AAEmI7LlKQIU4RRObNCLj90z\nYRz6BY09H2eVTTZOfmhvaIIkHDTwV+Jc2oDmZpT2MqpnxKN3oE+AvpspUye6\nXgDmuU8BuLxb6ZmWMPAqZ///LQrzlThxsnia1qEMQADExiuIQ070Ae/Paiv8\nMgrA\r\n=I1w7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"27f675c77c51883437940311b055179733a1a689","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ee6c443-1607461356691_1607461431680_0.6133010504588476","host":"s3://npm-registry-packages"}},"2.2.0-canary-030ae72-1607626069233":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-030ae72-1607626069233","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-030ae72-1607626069233","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"56a5209ca729b5a4a45fa53fc3732c4e008788fe","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-030ae72-1607626069233.tgz","fileCount":26,"integrity":"sha512-aeDQDVvqxU2MHAcSssw+yqjTQmQfUl7Ls9m4UOwvsEuQeNnNgUmEzscqMw6klMweDG+pqtNDRSeu3sOclv1tlw==","signatures":[{"sig":"MEYCIQCRpnYDwKrG9AxMhl8ZUm5yUlgUCRKSkZz9zJPF/eRQ1wIhAMSFhstbTgAhUX6Xd5FeInHlUxeG0b0id9rNRoe21yFb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0m2SCRA9TVsSAnZWagAACJwP/0JVH0b7uezUUl/rEsQb\nTD7bgNUWOElDwUgHFkHWiHvIe/LzS1TsDFX0KHiXdJYiPvlHNDJwWbbVBCHI\nbA3RxcO9SEqJ0lcB6I3IQeqqPEtjuNpX/B6IrCQ9cgRN51ecthUcrD4KdtIN\nAh4e5aT/A15kgbfNY4LbX/WNPC8Uz/MUZ03/j4bV7B7P4jFGZik4BnxeIi9q\nAWqXshxlOxusR+/qCAfY3Vfwrpe63f2OCQHvB1MTt+APv1MraVgQmy8AYVLu\ne0VfIRHXKo5vt53Ssm2Tg7tmUR4A6k04VUUsGn8D3T+6akkmwTxgvQDTxebU\nEJy/PuT0EpD0As8OrHNfndvRw8DDceXue1zXyrtRpaYBvSUb/Dr+vpbBaGoj\nPMBmUXvNqQCQfhL4pTH1kaay8sH9HVmJVd90Vi0jUzk17iY1sSgqrGbhdiex\n4vv1k/KPoVWk4nCAVowZ3Eiycnpf9mBWBb2xaHeMcr9X5JftCYoxilaFsiuH\nVVvCrZuYBCYI3AUVLRyNjCB1hgZGBiGqvfaLWy3WY9wjJ0qUdUHoHM1VEN5a\nwekdC9Lp0FEM9N+FFJfJiEZ5nzh+dOUpHRRCHSEeX3qGDxyyP+smxuzKyIIW\n+RupJMmQiiw4otWio63Z28aSMbQ/aEN9uMfdPlv5V8KYQUQ3U0T+YFrbyYVS\n8MAe\r\n=7KM+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f45dfcff02beb0a1e2a3aaeb8d2ce28b32ac0dd0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-030ae72-1607626069233_1607626130403_0.789330545836066","host":"s3://npm-registry-packages"}},"2.2.0-canary-571044a-1607640295951":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-571044a-1607640295951","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-571044a-1607640295951","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/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"72890e7a45786646caaf838773565a416e8ddb4e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-571044a-1607640295951.tgz","fileCount":26,"integrity":"sha512-O9RaUl5LGSKExUbi7S0Y/jq3QUg5rjYzdQIvAh5kcs3TcjrvHsUysPP5LZzNcy/ZMikk2r0C756YjNnc9nJ0Pw==","signatures":[{"sig":"MEUCIDylXN2OuAN0XDly0AUU+bmUKLPZRGBY7VUdtIbLeFtvAiEA05IGbFTyop5mL/LPlR+VAgZ/S1OMgwXku2ABno7+rvI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0qU2CRA9TVsSAnZWagAApYMP/2aciXxVPzAVncD2oNpu\n05iQ/35zGzHmhF62GQizxtc8do83zAKdQwGIjjBMIbup0Z7Qyt5uGoTc4XoS\nx3C6mdp2gK2gPcoXZbwcwDq0kWtJzHysHIoTKw8EVHPPDWeXGPqwxMoLuBSX\nQPu8NY2fax3wHx21lTvYSyjDgldSWPhrUvQpWuo5MjsazQe1wNwv0Yz+tKfi\nojRrjPVX+IxdWAENlP7n6kaawKCzQTefRGBCSr7JQy66+doGRPxuq/c8E02U\n8mwcWhr6BCBfX3GR9KTB91kZ29f2XTq0rglofB0ofXIGLLMv9g0MOW6B3FjP\nldOmu7OmXIKCKw1ue8+EbyPeakyMXsIGCOKL27PlaCJTDebDAcPBtOcuUMQE\n//GFQCPTbNctbllFKC5W3fNBJudMXXfdLqGTPE/CmJAu+DiKOPmC63IfBA6+\nDScA9Vutl7o2T0OJvfvSwvxDs6o3m3xCT07zB+/4jenx/BzJRN/Fw2lcSTat\nVsHPjqtxboGdJOQBdl5gzIk/Vw2RBVWxfb18qMj5RK30QDOrMkiGDPwibVSV\niatrOhjTvlcxg4mUATtGqgCw0HQjfxlNvPFZoY+6qqUb28c15AjZCI3PHlX1\njV1ddT/fcNV51NldH1Hy4t2Mdp969vLTpRQeVLTxlTWq/F+tQcxZ7Bwqcmjp\nOK2X\r\n=X3vl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b2573f36eaf807ae097bee5190ba2323e379f16b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-571044a-1607640295951_1607640373881_0.5703995606795258","host":"s3://npm-registry-packages"}},"2.2.0-canary-8ac9166-1607945250186":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8ac9166-1607945250186","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8ac9166-1607945250186","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8cef494b6152aac5f0972011107e4a933abb68c5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8ac9166-1607945250186.tgz","fileCount":26,"integrity":"sha512-+6J/iNZLwiS1hd+PZtUJtUZ+tsMvMn/CxcpgfmB2Oi/7qzyxHwICOussz5ShWUQ8cSQbu15B0UH528bNno86dg==","signatures":[{"sig":"MEYCIQCWpFvd1gpGYj49eQznSOQD2Ct9ff8dU86E8ogPgbAc0wIhAML33Inwt8jDQwNBW230otDmb2FdCJLA5HcxJRboupWJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf10xnCRA9TVsSAnZWagAAMmAP/2o4ETX4o8LDHxdGpRCX\n/ypPz7Odt++PcR54OuUnT+AcC5kIGSbttMu+5JJCHtl+BbBRqLfqN4IR92r2\naPrURguBl9EhVZ17mGiq9DZAdw54hXxbXlGyr7q21FLJMxGVZd4LMa4dBtl8\nNjuo+A3CjgBfVWv+j13j0MIqyF2uvGDHV9rx6FKHRi2QUNGNSFe2hdwhLnxt\na5Az/7DKaDrhrDJPBVSE710NfFX/Y+o8xmZQqAMaQewteY8QYPCrJ6LMz/eF\n2uYHGuFH4E3XCNOBgPHJzNGgMV1aI+pJDQHVW4zVT8PUreQeu8NPSSVLMhUh\nFnc+n13/BMaXsGC6tTo7aVOqkQK0wG5FBV8jzSEGO87cK5yYplLVmznoc/1k\nGsUOwZVi8FVsaTt4jjWtxnuLSS30QJ4+OIfptKKvzlNa0TBEIrij4mJ98R2H\nGHwgqIN90lRTyTV4JiT3/r2jqAJ5dwVWQpQJe0oAle8Mu1WSdkL1UlBiiYp8\nHxGEbU2GKANpUSY5pqUv6lf8BLL5EX3X2kgRpUXplHWBw/Y14O/Q4q2vTq/Y\nJr2bsZ/8IxbeozQpd37IiaPOZnYECS1FZFVZZkq7H2pOSLDeR/40MFnN6HhY\nV2RSHvRCc7iV5l2H1OnnvFk4QvAvsTLmvBfRgAUxSAy/B/kQNRg6WkuBk7Ya\nxUce\r\n=EL+3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aa285e271291ee608d6d50ce1fc345d86f96e22b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8ac9166-1607945250186_1607945319380_0.7830753213477226","host":"s3://npm-registry-packages"}},"2.2.0-canary-6579ec3-1607957930068":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6579ec3-1607957930068","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6579ec3-1607957930068","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"89e5ac6da8719c90e7f75aac45b18b95d59dffbd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6579ec3-1607957930068.tgz","fileCount":26,"integrity":"sha512-4yUC1xnXJ2ui11una+J9qm9EoLAcBp08vhwd1HNXL8r3S2wkC4gtHmNw1xvgJj3KIqn2RlqcUWt/kwaOCuORnw==","signatures":[{"sig":"MEUCIQCXam9bcDSIPB6LvkDeily6Vr0NHNKug0UFffQyQNQUvgIgdxenpSoq8nTBgK1pieTIRn/Gql+4LhxrdINvsUbqNdk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf133wCRA9TVsSAnZWagAAyH8P/iDd4U27ov+275k/698s\nrSk1MavtPcMI6sEMLNUFtHFB7GU4yDqXJP4BIQCh7kj3puTZ7WQLaR89IJSo\nzoqM+EG05T/fdZcGrqCMKnLLZ270pkIuI2OEpubT2hvt3muqKV/Je4VqH8Z0\nuT/jGCdJzpyx003osIhTYxkaCdbmLvJV4SvAOkoIlGi2WGfmkXe3QTwbIsPU\nWN3O5sKExx4EquDsQO/RitU47tD9KpryErdamvmZMt+im5SRyrqWob5lUUU/\nir8N5zmc7nYgt5OaP//ZRLwIpL2Cj124PVVGVs4+rbvCL6sz99Ro6ueStxCP\nML8JzrgbCoy+JA5zv6nyKrrH675WhrUCANrgBDQf7uQkM7juzO9260KFFxi/\n4x/X0bwk+vuGN9LBIZWwgE+cVViPujOXTCv2zgwA8YwFlN+OUclc3tTRBBdK\nuFQICb6ia0U2Hzwg1JdkMx7W59472nuv+cK3Q2OfK6q5qqW1dg54iI+6t5ZH\nSJcIfNWdpz6hzsyBydylHjDRrvuLqdk/7VLQmZ0II3/1FYjyEn/dGbxpHC0C\n0P/0HblGU40Ji49QCEn1J4k89Db0E3aAC3K04+TXiTZndrXyFzzPDbZHTr72\nH6gkN2hNgLqvlY9YT0eXkxSAp680tHVdYjTNLiGZ2JS1/sVeImZyR3f3P1/l\nT37l\r\n=5E2C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"090af739a73e0a5c71f6cd39545c4b238dd7ff7c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6579ec3-1607957930068_1607958000311_0.931860145005422","host":"s3://npm-registry-packages"}},"2.2.0-canary-f6c8ff0-1607958461953":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f6c8ff0-1607958461953","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f6c8ff0-1607958461953","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"85b750178d5d340de30d52a1ff72fa38a484587f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f6c8ff0-1607958461953.tgz","fileCount":26,"integrity":"sha512-53xP+jRSqKhYB3sUqjrFqDw2+iWSu/BtmUk1NJjf+BFMWB3qHMafJxem1M7PcWbkSSJ4w5i1uR0V06fwQCYKzg==","signatures":[{"sig":"MEQCIFd3HXHfLG8nFUjeQYMG/FA4hIMT44oY0F2G8Ts+3EUKAiBM8n410rasDNVokbJf97UqqkJM8F1rmCcG1mB1m3Dftw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf14AdCRA9TVsSAnZWagAAP7gP/RJ0q6rA4pqZHc7AuwuO\n5iFwdNp/Nv6NMTXeG5Ge42onOCDINT0sXeY/w/ni88X9ItzaWwsgTL0r6vIs\nqPw/WDCxL4BW1nz/74Fu1mO4YN7eh58ZmeDSBgiCNrfuUEfAo0Q/h6VSUum2\nRgHs1cdrb3saUS07JGMmRUSIjZ4TaL/CTSZt194vTWDLcNCH8z2jT/WrZDpd\nznBoC2KyVmurwqVTlGzx8Mxfm5xluyDklUu6aq7ccDCI28PadDQAYW5KyVrk\nipgQyquTpaZ0CZhH/U+NNQJts61Vh48DPaJWPkAWK7/DNHR6VZbrzws+YutJ\nHP+Fd7iZ8Qkjr+K7CxWMsTaTNKd5ggeUEMsRY8V3C6GI1+o/1fPymK9FY/Ko\n9XBoZBx4HxRyEeLqsf3ZJvp3eBfbnWfQpizb9ay9xjFJxhheoVDp3lbBZtNi\nv6tQcsslnPQeTZxomPDXbZspn0F34wddT7JcDKMKYoNujUqK7j8rIUGtvXIw\nFhlvguOSoF+aYRIDWFlTk4gNmmgMfeY1j2JDw/rtdYc4qM7V8nNgJGh9QaGJ\ncZRarAvBXKkDrLgsdNUAtqALMAm3kizuQHbiSZXPeTviS38fmqDW3NIlnki3\ndM5nWt2xHRSDT9t4o/smw4mStfEeZgGb8ur4bdAo3k2nfDuwIPfYUv7VxDmS\nnz5T\r\n=NIW6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7dace2e069663a730cde9ba2752a2b957c96fcb9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f6c8ff0-1607958461953_1607958549281_0.46959365650167983","host":"s3://npm-registry-packages"}},"2.2.0-canary-8c83479-1608328920954":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8c83479-1608328920954","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8c83479-1608328920954","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cd7b8f5b7ceaa721248a53045cef8b70d2f5f061","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8c83479-1608328920954.tgz","fileCount":26,"integrity":"sha512-Yd74OQBwnp+srpljRjHA6t+nWREhCNTfyv6oZES8tuwwO/dGyc4wZEVSKdCle+wISq/4JiLRX4C3kSm38ts/PQ==","signatures":[{"sig":"MEYCIQDUunQIYqpzt7F/ymvrG4cCTaQsou8fQVyWDo+ujgwtCgIhAP7ils17R8OxVjmlre62D6/jnacarnwWVuSiEL2bsYMs","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3ScaCRA9TVsSAnZWagAAvyIP/2eOUDXhU/8FyXuQvPiS\npbHSgjS8Kw/XTKPh9w5ysPq2fmvtS1NvwAYbCTGaY+tCX/yfAiFiywAdFSP6\n/0Ci6ba0tMc66QNUJNP2O+XMbcrnFsXad0BqbG1i3m4FNHFWwKZcuWvrRsTs\nXrNXof8hSA0E2PoeokYWyImKPKw60wT3nBn4BzW1nU0TbTsSzP5nGfUuCjPI\n06voicnUgKQBeFeOnmV4NgXmj2zQHHUS+/8a0RKoZmDtQEMH98omrvz2otO2\nC5zBS1TeDkYMd2LcQBXFfez1Jbzlvmlml1YNYr6b75DzjrlmTPbuwCtVezFi\nJpMODHjs/KlfVQssQea2ZKDLL5i+80EqPscYCzYMMVmc9LQAX5Neu+jFfLaG\naA+PFmgRpd6muAtiXYXkGMZkiyZrqgit1fVxXZ/FtNwZFkOYjQl7nTXSRWxy\noDSxVmLnptC3SWH1S9urbktRp20Rq0NJHGWhyvzk1TFXSDKVuE9njC+HH9T0\nTUMEDz6JODlF81LwbFoByQdDAzqVYaT0u0AL5HpY7KyOo5oUle7U6MD8UNzp\nytGMP7yN9mSn/psZ9qZzayVMBOLHKfb0C8o/kdDfErsQS9rpUR5YkrvlZC7A\nA14PaMD5Cejfw5BFQBZa509nUxtgQHzsN4vIrsgbDfEezOGxUXpaOgIIUE77\nMLG9\r\n=C8QC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7a34c9c0b3bc8d88df0b548e6a68f27fd65470f5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8c83479-1608328920954_1608328986238_0.04026734763770223","host":"s3://npm-registry-packages"}},"2.2.0-canary-5a8f1c5-1608570136226":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5a8f1c5-1608570136226","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5a8f1c5-1608570136226","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bc9f7318e483e4fcdf9649a12a05d7215e873010","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5a8f1c5-1608570136226.tgz","fileCount":26,"integrity":"sha512-pJe0lfZSfvv9JUg/V6qzInIVrixn6PxyZWEIBTkO1ReNlsfVomRh856siyZrYOQWtQJP2rT4+7jUpnk9pJ/9zg==","signatures":[{"sig":"MEQCIDKTegycXFjN2vx38fBwKd9Musk2tVcUSknq6lI9mk1hAiAHt5usMlpuGniHP5gSDSp4cjB4RKI4Mj4wsL2KfhWgaA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4NVZCRA9TVsSAnZWagAA6+kP/3WWZtNnxvb5b26y8ZmC\nNVrQyDafToa1rgAXbx6JlaVshA45r836ysEQSdri9BdZQnGLy883U970U9LB\ncBMoA2JDiaz76t5kvXRS94KIAhM0SGOH3/fkdPYUrVOxEc59QzzruxekrmVK\newfte75vh/Meok00jDUeSy4P69ZpvP9QeklL0Kzm+VSyZQDn0w2O16+Da+SI\nvEeYkYfGTC1BrVEDBeiUC3zOYZv2wP2TaEZjsWw5oy8hNKfrcTR3KXLRukAR\nMzFe399yV4g85iJPnCPHtq1IeUNe0zCa4+kdOyvfvXjGwuVrOIl1liTVMLhQ\nrXCifVdeB4GfNfQzdy436DuBccBwORNBmoOtSmtnPo9jK5cARKwjOA+5x48N\nWr/Y/pjIRj852u3rcYIAaPtJVItndGlm9klxnRd25hO35AAawEtMkh3Hl06E\nmlSeViqmq1FbI95Ni/yQUZk0yrerrSOL6AUBsJ3Fg63lhcc+PGFt4K8Cd2of\nmCyxfaK5GinsYH6Q4HsSYwsvwUqqgmr4hTxqRMrditPZ0wwmha74lThk+3NB\nQqd9ihRgOw8B3Rt6wUYQEMOHilWB117ZD9qSlFCOXhCRK+MBWb/Pt2ksl2k2\njWAE7IieqO25hQ5O4Pbv4UD8j+dCEm8+zgDSpKkd+BCPE0hDK+EJSsKYlPnX\nTlff\r\n=pD2g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7413d23bcf1728627cb273cd1d9c37c2222c3892","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5a8f1c5-1608570136226_1608570200751_0.615751515554757","host":"s3://npm-registry-packages"}},"2.2.0-canary-d1f6475-1608641936498":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d1f6475-1608641936498","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d1f6475-1608641936498","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7e331fb41ca388c4a9308cb1b7b197ab90491740","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d1f6475-1608641936498.tgz","fileCount":26,"integrity":"sha512-gT7+Jga5kRlgUmJgPvkgXC2ZGr4L28mz1Wae3j5DLozycLpK69ClNu1v7JAj3uEe+dUpzN4fuaHJUnjbJn1p7w==","signatures":[{"sig":"MEQCIBzZaR/qJaLTVQ4l3KqVp2v9+WBOYXEHQxzdj1xrYwLHAiAlSbymmqtoBCM4i0c/jxsOEV7/Vx6ezBZmFTvFOm3Bew==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4e3YCRA9TVsSAnZWagAA2hkP/3RNwpnI+CEDgGhWAnWK\nc/0FEnXfaiYXdpiDHW6ryxs8mKzuHQk/xkOd+0hAN3yohWXtP2x4ucyvfhNq\nMZtF2uD2GCuQyWhhSWL+0CU9H+rx3VLqalVCTpUhH2uXIGuL+BmkQAgjF2mh\n7aQKEMtplLr3uH6O+eubC8JkvwjdUlFAZQZipMt38Gi6aM0M9TLf1TYi3EjB\nIKltLyGL4TLy1YWgJVs/kkEsavcgdJFFAPF7wBoG4np+xdees6aXTsKwPbaf\nRhkH1LNkFvG1yfMymuugsXSj7RxCrgZHPB0jf4GozTd9rg/yzUkXKHcgyz6J\nzD11aCpKmLfefROQqvQeVj5JG1x35zhKhrjYdKjdGXR3qQsMPT2ADRvZhaIa\nariBRy2KEr+jgnSuW/ROD25ID4VUWCfyvetBZiyDt5QUqe5cU7TcajMc6QcC\nIlrYPrF4RV5xL5kWtuLIq27ZvU8WkPysgci6XvX9Qm82/VrUjALG2sEVR5L5\nYSl9XxQAMKWMqZf3LOUBWIb95aoOjmDq+iE+GLQTbbq1OzueimVCnvxpGt9s\nfPl+0AzTsx6jHCJJX8GccVbWSY0jsRJycMaTKrBMInmpekzs8YBc8ECmTmza\nGgmwE82+fJtDEYq6MVLVB3YJ1Mzl5rtVb3c5vSKWOrkdVAZ2zHL/3c78kZ2y\nsjfE\r\n=T8L1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b9d849f4e4b263002f24ed25083e00730bb6c05f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d1f6475-1608641936498_1608642007543_0.9289070471037071","host":"s3://npm-registry-packages"}},"2.2.0-canary-eac3287-1609165037285":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-eac3287-1609165037285","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-eac3287-1609165037285","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e0ffeea1b911e22b57aa86b1729e411bc749c68e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-eac3287-1609165037285.tgz","fileCount":26,"integrity":"sha512-sczvVNx82tfaFgp71zyEw1X6NE0gzlDP4Qqric62dIuXQEkvoDxvR378xtqELF8K0mehfQZ9nlKjhu5cmYkXUA==","signatures":[{"sig":"MEUCIBvPmZ3E1SJMYsIBGWoOWD3SG4WdKdzSs6RUP2gvuvirAiEAvD9dasFzwYIgfL/Ww5ADmllmeqPLpfuA2zswfMEBDdY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6ekuCRA9TVsSAnZWagAAd0EP/1Pt22uMuVKnQBJIAhAI\n6bbXY2cFDpehTE7E2/CtChzGDPPxkcTbX6TZf9pMtSz2nudxwaY2TRMeTEt/\nbWQaZljfJ5xNEVcK9HtQisuJtAea89O8ApbTBWNNv8MpfAujga/tM/7oUIuE\nwCesvb2RkZ4oVl1BHCpSRa0UZYh871kF/4I9aJELSBHfFdgzNG6m7/jzc9wn\nDKQPRHBaB9DXOPq4byzzu/GftpT0ugvAhwkxnllwigOtdfU0LfceSDXozYoX\niPnpT/Olh/RGJVfOH6P9zmz+qNSyUYQg3YBD1azTZgBpWUSuicNHIB4Wj3Fw\n4ymRT/kA0OzGEdXABwWI0Glp6WgM4ldfxbGEHajfI5KIlkUJgg5bRYmVQd+f\n4MyDMPk0Fu8UzP5vR4Ji6/PFUVPImF2dBqRBJM7BPQoA1KjzcQ3YVu8tikap\nqpiPvcI30AP3+VlrtSWmwc2hgd2viRdxwZr2pAGnvxW+t3XC0fUtcoYKW6lA\nomdxofur6DdJMLReLcLZ3GofkTwcwfFaxMBccWjj2CVSASXzOULNdFJlHcgu\nKTJ6bN91n0TrDJYp+P7qDqJreZtrgivOldZFnOcrV7Z9zquy3SyGst9MpHgG\nUGVwOL6dgyGkl+bENgtyrKi+ku7He6ZkgNL+DlfoyOnb6A/ro6zRuXnJF++D\nu/m1\r\n=HHA8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"003c21d70b0bd59c8aab4b840d15c0cf8f63e33e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-eac3287-1609165037285_1609165102069_0.24707272356733134","host":"s3://npm-registry-packages"}},"2.2.0-canary-7940737-1609181462419":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7940737-1609181462419","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7940737-1609181462419","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"22e10e032df392d1b5cd6790d29a3da861932283","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7940737-1609181462419.tgz","fileCount":26,"integrity":"sha512-q9pdgQ7pv0e+vkBpRnG9KKP3WNYxcR3I86UI19IOdwa82nSs0EpJABsSRkGcGHrlXxpww13wAw3G2cJqxXeasw==","signatures":[{"sig":"MEUCIQC4Ol4nG6Lslg2z05sWaoRa5u5HUKLv4wE+13/JdiPFzwIgFaiOd38RNSa4cPDYqGIFYMJat1ukNpjS/Xu8vRh/M8Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6ilXCRA9TVsSAnZWagAAn2gP/1TGcWRhzWStq3BaZ1UA\n5RzPSJo9PJzFSRIAd7HYsqN5Tz2NTJtFMuuR195xtnixsNqgSJVNAwMYzQPk\na3sO3umBJeZTGXEAn5S1RKYlAzF/O1IaCHbuLq6XaxxnRX8hGUnki6+1BOus\nOAuONA4STdK/y0jqZ0ZPu0FPMZq/NX5Ju9qmeJq7PYYfHKiDfU09cZPaVsYP\npWSQnVE9qBiX+HL7Z+lyp2JubQxyEOGggSyKWl3xb4IUdTZZ3TJInvtjzoww\n3zXTfhLXicIkRokkgFrZv5bYwTmX61FtPsmpQ8CC+qA+obt3beL5wCDYxSr3\nd4co9xpYMaMWEjSu5/YSgtRo9NAHI502HbWYR5Qr4+aG0JUzxkBgRMdw7HqQ\n5rHdh4Fbvwm3fgZ3ktVRpkY4EQ4fwnEff39pfKJKPtQkCGG4akbx00YiEZRu\nCj4NuQkwE+tby08PXgIoJXQqRoJRRnPmwSsoUUbfkQ/yTpIQ2CQuU4ySimap\nf6esqMaR1JlZL6u8QOloW+j2Pv3Tgp4AQ9LaxrIWiuHeGAmHE4ucKyWI4k5C\nVqRcKKWmKZ9x4vEOS7TwfVWp3BjLRe+WwMwXflBBpMfMst8LaGdOC+qeafuf\nz/O/Xc+LI1sjl3kNfskRPNHBu6osiRBlh861yOMhwghkwQs/xuc0rc8bhfN2\nvX0n\r\n=t3QD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"79267b7d0d032d55b4179805c529c9351914ba91","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7940737-1609181462419_1609181526815_0.22842467715347659","host":"s3://npm-registry-packages"}},"2.2.0-canary-94baacf-1609219702885":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-94baacf-1609219702885","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-94baacf-1609219702885","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7390ec4d29fad7b52ad508237197fe77067e17b3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-94baacf-1609219702885.tgz","fileCount":26,"integrity":"sha512-M+4ncGk/SGykMo49aG0T2/NW+gZwX0AgqjBHGDk8X9RVSGTrBcnOtCzWXdURimHU9/QoKD92nEBJL/roPthqRA==","signatures":[{"sig":"MEYCIQDd36YzLlklHdQUNZV+3xzi6lWaeyHLb/8m2qPRCYHLngIhAMgI9TFt0hx0ryvD04+tRt8DTTpk8qiKVScIORS6l/Bd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6r65CRA9TVsSAnZWagAAfaQP/Rd0GEoIBp14xDLN5Yry\nft/Z01Dy/v9lIfGFZQA/oqx+GyBd1f6CTZNQFWYVCyHJhazYZ7WBEzuw3MVy\nWprnydw/rtR2QnW1w8CYoi3c3PwyDj/LCPF1NYXx0HcF6Ivm62CaNrLyLiei\nk3zGfIdudh7LjFQnx28Xvx5WtX6KCzBSWb96TJqDIrAL4By3BXg9ia0ea06r\nRpxfBk8q5URmzkU7PsaxA2VsjqMACbY7Uv13zMtXETRZHjkQ7QB/OXmNOHb4\n5k2yuUfNe5efhgD3jne0YGQBYxsunrE8P6wJTnfOo+HEKIH/6aQqDYK77kt9\nBFjRAohYAlsHfeQCr48VaToNWXe1dH38+5pRrRtJYPA2mmuZodQB9NqY2ZsD\nBiXV9yZfPyt8pYWhKdslgrVBSSKzWUCTDpWN9l/XVOUP0eXA8HxfYryQGOAS\ngALVuo/99W7vjmhl07KCkpEbOx6z3XDs9gWs10F62KRfOQzb9CRoNpTY1q8D\nppjB7Bldhg9C1WUHAKYLseklrrkUXLNWlP0oOsffnLcHFDxWqCfB8X53hFaS\nMnx746gvLvALRdIoyWzH0ZLI5qTVGMFLKZa8/Gwn0Y3QvYJi8YU0LrpeJJIz\nRhTKiX0Hls3Y4iu/pD+2jaT637DtiQWqY7pWDbFCBU+lHY2n3eiTSH1qq/57\nTcsC\r\n=esZK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3f8aac07507c5fb0be182237dc68f8dec811eb92","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-94baacf-1609219702885_1609219768434_0.7104195880014204","host":"s3://npm-registry-packages"}},"2.2.0-canary-c9b88f4-1609244687313":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c9b88f4-1609244687313","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c9b88f4-1609244687313","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fd3379593656375721a0a21f76ca5a909bdb400e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c9b88f4-1609244687313.tgz","fileCount":26,"integrity":"sha512-JGr9k55dAUblcIAgvE1vRG0yxWTLc1ySPHS/VfxOKARmfLvkvi7PU6dnTpI4c4Bto/dlurcXbDpHbmV63ZIKGQ==","signatures":[{"sig":"MEYCIQDVSmthztSizvauSCxQCATVfrP8UAZJrK9VvucPpc3K9QIhANApBIufrvGnb6RMyLCgMjMf2EO8x+dd+hR9yU+TwRz2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6yBXCRA9TVsSAnZWagAAaq0P/ROe8oc6WCcuNJnZB6Lp\nHJXQMf82iI8dggnL6UxkpLVi6UgfRra0ZklfmD7z7Cp/M9zGBU62SO8lJ2sV\nzgBUrHiBycekQIY3qowVoCkKihP3HUHmq585v5foWSHJs7FYTAIq1Aa2JIJf\n/vC349GzJIbOkCUMd1PLjdWOjy8UjFHYa/4bWf7MItv4EtHz0YDt85bwkhJN\n+fD4mdDmab0YNWOvJ5YwpdiZ2aitWwzSFGP7d7JG9JGu2xh+EAPHKh/Kifwx\nmaGQ2jImkyOzQU+TRn6DW/+kGOGb1tEIUuZgiJWa5kmdqwQwaXtjF4gbbRvH\nFTPGb0kGOLGXH6/QX4/KoROfjpURwfMDT6Mho7ODLFd4r180L51C7BFKG8Cz\nCrkJLaBZP31HN9C/YhFZmQvMmmSBFcmnpVtYia4SiTl4BHSfqwThiaZUvJPm\n/lmitY9ROrM61WVpgIqpGAQ0nmo9UCW41/PTxqLlDxASvi5fobhhNv8JGdva\nrXRsuycMd9+VwpxDja7xBcwxuxkoX3BkLa67dGD7clAiuvYSjMQHKTiqagrN\nQNQPkIXqqjZr4MWAZk0Qgg4AiR7kct1cB4KDFiQPqgAkzX4hHDnKl0VdFy6s\nyrxDo4tiLlrNCp//0paf+BaXWri7Uz2N7bWU/ZagvV1O6Hcuk4ufmiXkp50m\nSdP4\r\n=X4ve\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"66d26327d2db8e757b5c7d882a172116dbd6e3fb","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c9b88f4-1609244687313_1609244758751_0.21589338354797993","host":"s3://npm-registry-packages"}},"2.2.0-canary-a4106d5-1609264839516":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a4106d5-1609264839516","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a4106d5-1609264839516","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0a4778d5295d4c9da9a36095fb51580cc5452456","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a4106d5-1609264839516.tgz","fileCount":26,"integrity":"sha512-Pk6wXVvLp5hb8ZsjhMVDN0nFXzQJUGrE+CJXvanKeXHQdXvxchhA61DDUAvPj2POGYOM619M7bKsT6BTH4wv/Q==","signatures":[{"sig":"MEYCIQDpvPvbx+7j63N51BIqpvBJh8VUsh9OuwaDXdTy8iU+pwIhAJFG053Rkg3yFrC/Ouz/RW3Alp2JluvYrMpsLUhSoM+4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf628FCRA9TVsSAnZWagAAqVEP/1FoChxwVUN8Fv2JNYwo\ni68XyqLaVcBLzG+t51BkJIIVRNDdwd7BoY6f5X30qC49JarC7oQJ5Js2cg1F\nLlRwTMl32o2MHiFj0XRZTrW033erJ4Ffj7h8314TQVfFMWp82uy1juOGOv1B\n3IOeE160Hi301r+W7A2fRdvDwwqsYoxQbk+W0QJqvJkfjNajmYSwVCBwjIAe\noCc0u7n/JpaOS4dgFwZ3qXOvTQL5geLF9UfmoxAPZZo/Sn8Feh+xWwLNCTD3\n35HotVTgRfPV5v0iGdnIRnawGMae93nDZlcd9xssPmffptJXiMS+RwVBubyw\nLoida8xyM+/k7zctanNHDi4SCjSj2mg8E6Pycj9z8oy75xlVjk1ijzLV0wSx\nViI1qdO7UDaJcsVD+VwYG5CDxhPwECRJp6oO8SSC1IbjuzqZbgAQRefvUS/i\nw2SBg1RVY/pBd7TM74JnRwF2QG7DEsMTai6tEPkYdXyyjvM6ZsqbNEccaZfh\nMU1dl7W+xah16uPWg5vyakLSAkCrjhpJc2g6vQP4y5dySQq0Y2H+CbwnWX09\nNAzMmYtTfNzGYOANEpPKSVODVgaopy9YLeExQMGhC8FHXu+0cS8KzaDx97ph\nKdY6CTQemHuE5a+HSOnR9C75LMEmiYeLf8CM5f2a3UPHH4s/Gf9qtRjkikqj\nJJHA\r\n=v7up\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"cc85c206d573b98e3b22a4f4e2736b1da8826046","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a4106d5-1609264839516_1609264900766_0.5384781970377379","host":"s3://npm-registry-packages"}},"2.2.0-canary-d56044c-1609272411001":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d56044c-1609272411001","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d56044c-1609272411001","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0248644c05f042e6b9599015e926b80fd2dbcf07","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d56044c-1609272411001.tgz","fileCount":26,"integrity":"sha512-gmKOXG0MpVCt9F1wAcByHI31U3Qb7vZ5asjrBrP8HFGg6K8WTTia3aRmYQAN6qHOQZzyGFgKXIhg9LouetVVWA==","signatures":[{"sig":"MEUCIQCC7Z66iLHTRAC8Paa/TLz/6GtFiSZbsny9Xvi2Py3geAIgaf30yeTUn/sty3T2xnrAS+sSBOTew3JATfgkwbcqbkg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf64yfCRA9TVsSAnZWagAA37QP/1UbWKGra4eyoBQKKHcb\nXnl4ObXCXPShwTaj9KZSKGz9VLs/E+W/RlQzJeHYqyTDVju8NH00sp7/bft3\nDaJKL4IpG/HEHKMB2lKlh/mDfZxfu4Ma719xHaae4c2wpSjJ6H/YrDbWcXRO\nLFWsvdto3iLzGtZNzMMseFgobH2YzrujGI66AVupgdeZPN/JcSOuHGQpZuf/\n5fMQ3b280cHRfq5H9Si00pRA4obfFEqbEMILpKckWarAPtderNtCmI6c1vxj\nu2YdRtr00YD3tvZ/q8CR9YY4HSXvCLhHZq+6Umrwmd4C+lK/PEVDshBs7JYd\nmE315yEnzmtHW4ro/9sFqGmA9X8XUPaijjNvTHr+kxqf0Vb7qI7EhkMqcY10\nWK+D97VQ/WFmUo2/anA8emigluCno2jlQdMicTLzIrcKHOfoIH/9FpzR586S\n811BFgOodHOJ55mJKLiqCXaNtSQGmXIiXnkRMagQVfM5pmKZzbTBdYbyIFEG\nmXp+JyL2bNk1ZTwY47XwCN7MnxlsFngIlQc49VtSIDlHQBCCPj1SeLTcaUB3\nmNh4/RRYi3X0ivYXnf5OKVbuS+8y2slwP46o2aHhglmvTanjdHbGxXB2YFjI\ndj3oeVtc1fqFK1PJjRLwMqKxcHoKkBKYDH5ju+rc5fwSAnFxr0ao4BJ5m8XP\nQIH9\r\n=mcFP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"99de522b9af62c784c84a463e9d37a14b42b18a6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d56044c-1609272411001_1609272478553_0.8225994521962001","host":"s3://npm-registry-packages"}},"2.2.0-canary-eddc81f-1609286731039":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-eddc81f-1609286731039","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-eddc81f-1609286731039","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b2a7ed3ddf5858b762e0818255d4852f39d4bd00","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-eddc81f-1609286731039.tgz","fileCount":26,"integrity":"sha512-a787Xy4OcvH5kb/8zx10DC+Cny9uhDhvi3YEvUAaQHzroUsbFZm+z8Yfdaq5dLaN2k1eVY1I7KY05NZPabczkg==","signatures":[{"sig":"MEUCIC7sxq/sHMILLIt/p5pxaiwdSUSA150iVIGQfI++2E8FAiEA6VesIJVVJK3FybtXQoaUYgL2M4l5RqoMhMZ2G70OBac=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf68SfCRA9TVsSAnZWagAA5ToQAJcBYvBCZM7F2R7I8t/x\nFAv65EaPK97gGj/eK9D1HqAUNGuleicXT/66RB29/hCkOBPO+D6GLMBF+WKU\nkAZYaw4oXV/C3s0E0iKiuEaNeI8emFX86DxkCg7+6Oop1B5cQjAaiG3kEBhL\nMD/YIA72be5CFN0WpfNFvYldWoRIcszlllN13+w6gO7YK9GfYsM28Vf7/PKI\ns3q/D68ODgjMw3q8J5Vq4R7IKBZ/+ewInA2u88gVueqAXi5V0qlMkWCUmYNQ\nzRnKxkiAqmUfyylUc4VfyForPfhVMA16lQIdEJr7fR1aMM8FoXfS1igfVEzu\ng7bc0/uTR15rceTTKdX35R/gJRPfKw6HAKAfU+4kZxdtX5HOwgkjw4Pw0BWA\nwQyswQr+7j+HZ4d2tUhT3MURQpeuU7MHhu/u536Lpoapw8guArYb6eIp++J/\n9Ehz3XhvfUQZXNLc6Pvb666jEw4tqlIoCDqUFS7515vr7I+qduoU5Wor24CO\nEruu91vP4XXmd4gVJuKTyc7unAY9VhLeDP2oC+QeDNcTdlQqZdu2saaVoaWa\nxIO1xzrsvGlB+DwxYP3ywyTAcuhWTapjonwZ8kUGqs6WFMtXTYK+q+TXOuBm\nbuUrDl472xPh6/GtUr3Q/Ko3pWUB4ITKqFhUqUVcrCn/RUjDUkQO02wZpngb\nu/VK\r\n=QEA+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"eb4d8160195b18c8b6af91331e31ee75b76064cd","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-eddc81f-1609286731039_1609286814818_0.3970814522185717","host":"s3://npm-registry-packages"}},"2.2.0-canary-76f91eb-1609363008090":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-76f91eb-1609363008090","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-76f91eb-1609363008090","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7df6e9841c61ec87c24ffe032bcbd0c092766cf3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-76f91eb-1609363008090.tgz","fileCount":26,"integrity":"sha512-MGD3DUqI9ahRf4Bl0jt17j7v08K1fPyK25yzO0iSWAWCVvkrZHfdf4hROhb3/URIdIPpFDLvJvGhRNPvWz0eig==","signatures":[{"sig":"MEYCIQCskwqJvk3on45nBKSTNvvTFsPUfVkk2c6EV7FQfYtDKAIhAIlot6AUwFj0EhiqTveHXO/nEITdv8EDhjQ+Re7FABCV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7O57CRA9TVsSAnZWagAA8ckP/0/aIU57iifadHoiJ3Yr\nxUKsscgpzOSeeGDx6ZL3VwIuIPgS8SmVuXYE/e3Pscjuu2fpcPaZOu+QLMfq\nw4B195l7ou1w0SewYeCih7OgraWmPMK/KkCnEtbNTX5HQ7+vzX1DbfEXEjO/\nLc0ElvjUeXvmrVe7hgvH2NxjbCq1vRH1adfHrUUhWhp/P2KV0TuAuHwrdaje\nmz0mEX9fzEFnwgzNsTOoeZh5SfoPI2n9/okRlEmPvVNpxqGAk/fyrV7jjLh5\namY2Tx7yWZGI73p1ZH8cUmNvC62GITfY3IsTJ+p8AV47CObz3Ip4upE04Acb\nB44BCM0bINtSaqgYbcys5FfuBzdtuIOgm8VDHeEJ+WOvm40WJtk8f9HzFzlV\ncxwhJDwskE+PADepgJeYMotzHCRIY1C+Xs5qfKeIM18JBE/h5BapCXhFCN+8\nEudiV7DZgHfEe9Lu3emxpnjmn8Yj6pRXNIcE2rYJa72dgNAom8nvOn0MNebB\nAXQXZ0c8c/Es+KuAZ2zAdYBL3SDB7/koxWxB4baJ9rya9SLT1xK22sM1YT3Z\nBS5Q0teHnSb2iOPPNJqH+FXihZ88tHcZ4dcfDrZ8/Ouq10KbeXiEYYBIxJ7y\njej+XQx48dGWB/oRer7ePmXyq19TzcfC+x9UlIujWw3EmzrmHVgpyvJVRfmn\nK3wI\r\n=72Mf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"84e3ec5271cac1433ba4603e075830c6af7e5e11","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-76f91eb-1609363008090_1609363067022_0.008845519613686736","host":"s3://npm-registry-packages"}},"2.2.0-canary-1df0042-1609465244060":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-1df0042-1609465244060","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-1df0042-1609465244060","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3709970ca41a9c2bfea2ce73abafa9e02f4a919e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-1df0042-1609465244060.tgz","fileCount":26,"integrity":"sha512-nxIHKnugX5g8iexgBjOTYVo1pkmbswgCdf+yfbfC3xWK/ArZI+H4rsEJMJXyUtI06wycSQDDBBeF1aik/wCfAw==","signatures":[{"sig":"MEQCIDcyCipobVq43cXwV2l5j9XrzUnMME2uNGGQaYidnyuEAiBRw/tBj3aB0Gsf5iIFn9kaW71jkzG2jrxMhMl6xqQuJA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7n3jCRA9TVsSAnZWagAAP0kP/2YxM3WhJY11OzpOL/sY\nwSBjPi/0T7uPTwXNQ6tyIZt1YbGaE60LD75Wzo8GdE9HaThcnjCv2nszsU3U\nMKQdt51h12eHrqJaB6b7fkLw/NzZU59cYCJCbDqkBRD36N6lJV1tzsTklqlD\nXpoiKnmCmfhkWdlrHxRjDh01YrOQE7ByB36SWZ7G9QRC9bQRB4qpFFy6H1P/\n4UYyaGMUyxYtcxgQw0oc0seRsPgZL8n97pQrK4s2nG/AJ4sYWyqnpZ6j///M\nhY6tA13v8AEizVnYx31uBSB5R9ozQzL3sch/+JUWTpgWFGDOWb2eiH0Ly+QR\nKpFp7UNHxz2LV/shrnL5mimS051Rpa8M8YJSs4md33lqD/pXLmp07hCqLxhY\nvujLxIcNgnD8ghLoCYoltuaJZCUogGk6m4Hbas6kqkMSwUxWvEqqbDKcO+Lx\ne6gC1diPSnsBDaPjukMukntu7xJJvyNTBpSNk2fOcRzKxVOnkG7Azo1NZHAf\nVF+JlDShmHdSb/pIyku3uYiNr1pYJumcBnrSuNg2GK+K4j6oJ4TyEHJujeBt\nd4p5bJg4azhmiRygwuYIEA3eB2OdsA9aFZ47Zeu/D5RfAtNYZGq4EKSxzfiu\nFncCevg8ohB2oKIEgpvHPSRNXn/O18iNp3QtFKAHFhq7yQuDViBYePuIRp19\nbveM\r\n=Sewz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7bf20a71c4ad94b1b70b50b5d167368469937da4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-1df0042-1609465244060_1609465315172_0.8383862071750081","host":"s3://npm-registry-packages"}},"2.2.0-canary-1df6210-1609491543593":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-1df6210-1609491543593","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-1df6210-1609491543593","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7263943b8d0db72f479c381119b341fc98700819","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-1df6210-1609491543593.tgz","fileCount":26,"integrity":"sha512-pjDmzfRw0n5H1jdHEY4Vlwj3n1ueFb5T/Lvq1BwU8/GaAl3vp2Lsk3zN6QH01OqFqKSw2F39NEaSvOKepBQcqQ==","signatures":[{"sig":"MEUCIFNzZk1PFZjT8SXDQjvQ5/Th7WSVJWTQtxknRN2TyFX2AiEA8iZPCZpg3UfqwiHY+kESNIGMTm+nZcibmRtK6Ci9BZY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7uSUCRA9TVsSAnZWagAArTUP/Ro9AA104OVqFgH7JsSO\niDYPAv5md5ORyFYa6jOIUq03qpBrWW2Ui/KClvvLJU0U/oejvQ7VbKUEdLqN\nKvFHApPtCVhd1WYN7SEw2SZBspI2NWMWZFA8afTV0ehq5e4ux75HK5t8VJSc\nlSJToF42eCNczGPFluarcKVm3hG3sFcOtX3F/QQtzvri6YRqGdTf4L7h2xNS\nPQiWfBsSnn1+0ydSBcX4xkPyGZCGVWSfsPSc3u04vdpBm9GzVRVkBl6aUPxk\nuSi8euORRPsscOVneQUS+by+/2HujisBUFbADgWVQcK+DzyEkgsMFVH0QlQf\nmLoO/9dWvnBaAzF0ug062uAk66rFPAza0bbX7ues6mNN4gp1jiSYZoBb+dpy\nGYi0Qt6ezzkgkwB+UT2amnGDyz++0KZ9C3g03RUlOQ1ROPs6KUPM6uWR1mW9\nyaHm6Enwntbyn496GcUBgVIGZxYl4vk4LN7JLUens9GrNg1tt1A38RxDk+00\nMuTS06p9KmKnuDZS44XtgQlkXveJRJc3TEpu+mlsLi+IV+IvjVVve4Jgu+Il\nT9c37cTl5a7ykZW8yNLF4rJ1uYYQH+wLkQHAHCJJw3c64hn3on21VtBx0Rfv\nM2p98EZh57mEBcu+OpD6gL3d61HapMfGInI5Jw+7/G3ca6sGHRXC7h1QztVQ\nkW8C\r\n=jnM7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"790c11eebfdc307a39921a5e97449a713b07849e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-1df6210-1609491543593_1609491603571_0.8333021090988955","host":"s3://npm-registry-packages"}},"2.2.0-canary-c94b676-1609541250701":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c94b676-1609541250701","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c94b676-1609541250701","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"365b68fbd508f4e90e2178a6f96d22bc85e8ce3a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c94b676-1609541250701.tgz","fileCount":26,"integrity":"sha512-smuTyL3FQ+H60KqHmHQAzBGil7R/kYTjXJ0i5QtRpQPGFqkOMCXz9FpDZpMqTRN0vN96Qr1RXHA3J0qMqxz4XA==","signatures":[{"sig":"MEUCIQDSJvZ2lCpvOplyaSGJA17RTxbjV/BYF4bag8O3EbCeTgIgHO7Ca5ctZPTr+3HBwxvHOW/Rc1hKHYlph4q3IpH9YK8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf76a+CRA9TVsSAnZWagAAyKsQAIgIPhgoVqqOftkNSrFR\nDPCx2dpv+r+sKtzDpTZErMFEPYySzYYHY9mwWROQ6lTzxBQZU06wWEb/o+uw\n6UYUc54GEszfn69zV5MX2nb3XPw2VgIxyu422+6luFYXv/cVPpidjYJpy7ff\nGzN7xvIiV/mJJLmSMXebExylCwhLoxOKnqy4yyGUB0iQrhjHQVql2yNywyan\nUA34QVhmXidxHvBMUFZSK4IE0sVG1Ausvv5UJl1Fb0L04fut/hXnl5xWVB/Q\ns/U3gH+xPbThvgC2sQjq3nHDYAbAKqAhI+DMuhyn4qw4n8/LrKpP9dlXFKAp\n6DjozZfW63T7x/529iVK2mMrJ3kEIqkBg7mwmEuQNTa1yznLS+GgLEwvp5ZO\nHvkI3GRzPDFEIzLgb3i4B2zacBhE2rI5wGRwHA8LG1KzTL/cOkK2slFicf3J\nZjFhcyzK0eJgrW+yNvx2Kxt5UPAExffE7L0F9pxOzWVZvxfyP9CzglDHqEv3\nZa1JDFQp7p54ESyCe/gNngliftCgc5KqgJJJtj31ZZ8M4CqDscbpf+ZrOyqs\nE3xE+EBK7L5bW+/5WeC94/BopTY8JZ0asK6juf3haUYlWojdqemlpjoDwTRN\nHLPqmAAylih/VcnvzQZl+dJOzwthDrkXL06bfJWFwAzbndodNZXPcxNy5pyp\nIxlY\r\n=wQen\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f7c7cdeebe6c0a177b51b63363a440ddd88a4d41","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c94b676-1609541250701_1609541310153_0.026682728837489122","host":"s3://npm-registry-packages"}},"2.2.0-canary-d9a7289-1609557116418":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d9a7289-1609557116418","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d9a7289-1609557116418","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ab21db847c76b8438b7efe77f4ce07d71e1e61f6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d9a7289-1609557116418.tgz","fileCount":26,"integrity":"sha512-XemSSOzUoCrUxe2w+hSu+Tgccea4kb+N9qNkatKEG23JCNsPcAF59VFcGQYjDk1gMTLpvFZddYjkeFj5pBW24A==","signatures":[{"sig":"MEYCIQCj1rklBKBqMVlhro0lSyLhYcm46b+EKfR+awmvUpCIugIhAL7HHsPjQOgOwR7HSp31Bzj92urB+vDq0atsdyNvROcR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+S9CRA9TVsSAnZWagAAbJUP/2FLhOV6lKlYMirCjGM/\ng5RrX+8OddXDnpx36QiopO7OxEo3Enl0aRSo+vY13cJcOuBMiQS+T6uVnOC5\nvBKo8C/ahu05qk5bz/nm5tsS0R4RwlbGPFbzHYQDUD9VcIgT2E5CK3HinmgH\nbbxZ7Trh4kCgvsumLuFskA9BFdtHclIxlihZ3Fv7az4hBqsdpmyM8q4YZsMk\nVjeMFCJHmn7daE+FGQSX6NTJ3OwDpy7F24GCRC6E781oGXbwA/E605zZtP/c\nkAszQrWtq2zy1YDysuR12NH4WFNoGwujJc4vHHXYfcv72FL2v6m4JhnvvHgT\nuY6rIsbPuB6fla+Ah7ObzjAXZkhOB4PawQLESpRPmztli6r6KT+dWtJ2S0Pi\nJw62bkybGUSJox44clIyxphEI3Wd+zsVS46g1pAxqPw2/Vct1iGqBrAzEyg2\ncK3mmnjQkf7JxCS0u2hnzmdHNIVB7uGZc2hTftwJ4qKMm6Oyuq+2twWm0pb8\nwsIY95KkzdIX3vIAb4guzyx10ECVg1xOOethgYeEAsWH3d1s4TzF6Ybxbe//\nLS09HXpUHhx0sRfKsXCiqwQi6RXH45E3Sy8MbjW85lpJ0U5YnJzKe/mY7K5j\nCO5LbO7PxoEVoicbSyMGUwDlo8p1+Pwp+kU7B5c6HcuIlo21vHczKJN3XDil\nsG9u\r\n=+dns\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a9e01f3f0c1f9b9e95573de3b945793a1d76032d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d9a7289-1609557116418_1609557180434_0.5268657146303213","host":"s3://npm-registry-packages"}},"2.2.0-canary-f64d2bf-1609557285429":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f64d2bf-1609557285429","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f64d2bf-1609557285429","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6d8360d67526f694256b148d44bfdca840fd78fe","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f64d2bf-1609557285429.tgz","fileCount":26,"integrity":"sha512-3GAXIE9RAgoqtBHYfNFx/G0WEPRFHSXR+ALmVhH+m8MKnBuK+BTtwvVvCDGLIM0wOxQAn72+RCxN02AU2w7CLg==","signatures":[{"sig":"MEUCIQCOfKm51qX808RXGspDOymfaDvkepbwHkBlTU9S625SFwIgav1TFDPqFYo+TFnHZ5PScSPIo9R2SGnEYcNIvyBckhg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+VqCRA9TVsSAnZWagAAm0kQAIlldjLyWu/n4PPj6ldC\n6qxv/Nw1X5mgjVLKMCy7PhqiHI91NRkMooS6DLZhULJ6j5x3/JXex5u0losz\ng7Vv2ptXlZ00SrP3G7L/oy5L7FZegLnrBnBch85sNyW3ZHjCu2GMNpqNLJIc\n0/SrLVYGF7gN+FCuQIzdUdLx9Gkrl05IwiCl5CdD2wfo/XzydUO8jaeg1eFb\nJfFKnq4AP+C8BWtnrs8mCNyBWan01Mkska5IZ7hafs0c/Fj/rAyexOUZBT6X\np5ka9U3ImrAZqk+KnaH6bAe3aIl0RBNZlilE9WnH5LpMsReRz3ssrZovcmM1\nRg+imweVgnTeok7hnz5azh1yFZSPJSaIKxGyXDXSSGXtMJaHcdpE9Cclj3xg\n3xNgrP8lkjh6tmcUCEhP8bH+75vylnDqCycfBSbFOhB/KWmlgNpmjnfPasea\n0PLGoGBONjSoK00fG3FB/T6NTpBJGfh33kLXlfBD94lQBX5OHP1J8n7/rnBy\n/2UCZ0ks3M7QNGVoeLRl5s1ualpuKHEDiIxqWxarODjw6HZe8oWi2SnMV1nT\nCNDE11AHE3vRgd3swA8BgJFjNKsQM9vDn5wTPoVpHhG38U178o0GPrPPpvxS\nF1C/SPq6kU00zozvZtACUn0oJg4iM0/imU7Fm8kZtIlUoG90vcGkAUOa8CtG\nIisJ\r\n=YB+i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aebcfc6f812a4cb85b70f1174404bd7a21b5848a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f64d2bf-1609557285429_1609557353684_0.8438859523545243","host":"s3://npm-registry-packages"}},"2.2.0-canary-04c35fe-1609564213563":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-04c35fe-1609564213563","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-04c35fe-1609564213563","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"197c39acd6b4476f4f61d658ea62506f1a1da771","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-04c35fe-1609564213563.tgz","fileCount":26,"integrity":"sha512-FQvlkCQbtwl3ZIBOGYaSeYnIutqWuAhdIb8YqWwdBYsEP1Lo+0irInw9VT9EIuXi9BXFuw3au5T9LYRyoXNolQ==","signatures":[{"sig":"MEQCIH8gHl4XANGa0FMVx0dcSo2y+jZoeLXkmVvgPY8SffzQAiBkDuS95wAZJWDPShaRUkIkX62aTczkS8t51BvGb4oYnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8AB6CRA9TVsSAnZWagAA+0EP/j3fsOvB7AFch7RYYsY0\n3Z0TyB4SisSeGiOcFbNhqNS8/0K6RtOqCkVuAyGls0wJ7HVaVvXrIDOGWc0K\nedC82d7nI8AgSp1zS1Q7JLylnhWqZY7/EzIcYwfyCwLACx/8W3d04wp7dCgR\nzKRw54WbQHbup5icH3IEAMEtXZriFSjb16o3LzIaSLWklLokFnIcLTgOSp7h\nuEpWX+ZpgySz2yvyC1GnMlNPx7eeAuW/qCuOE1MQR3d6T7rKfaIqqhjfJS7e\nGFfVgF2tHzLlgP0LR1caPK/dCHfQnSnMpO5UW5I739CKpWU9N7OvNpPiudgx\njUPg4O14axZaK0y3/iOzu10J1dWvKnjWh5icNqlYp1MKr10CcLbtvy3glNAS\niGLVL2EKfdftYeJUWCEMqSbCPxbrGAHjqdUC7HT7KfpOSAtsX74JVg/5LN8U\nZXrTWnkvNeqPfy8bJPf44Yy7KoNsBGv5b32VB6nyB8YziGQaiKWWC+x6fwjo\nYctqUCwY+pPQ3DcSWTDApC+D7W9Rfcv7Nvk2C73FkqCrGqETVGROXhBksar8\nXkkr48VMSuYO1Ht/qm7uB4qcsj3ea43a4T+bRtRkNM1O9fzX+HWWDUvhIOcL\nkpi9NvzOUf94dDAnjvw76mXXFunViVuvfd1erqDkevKLu0jHKs9yIqq/wKLE\nYAcV\r\n=9JIS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6c0d06e1a06448dfccf392b35e13f771d4d02ef5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-04c35fe-1609564213563_1609564282125_0.3467685662361417","host":"s3://npm-registry-packages"}},"2.2.0-canary-b3f7e59-1609638935934":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b3f7e59-1609638935934","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b3f7e59-1609638935934","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a2e966f1949182bd235f1e0c16e522368112588d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b3f7e59-1609638935934.tgz","fileCount":26,"integrity":"sha512-Lv1sudIycp3vch2uSr+6T2oKKQI2bAlA2omJisIlA3USZcizEAD8AiW152XLFnEU4nhptmotBE7JP2CnGqoyzg==","signatures":[{"sig":"MEUCIHRsi4KpRa/TK8GwubzbisuZJ0R7RWdC6kagWTNo+gPQAiEAl3UOCm5Xlwcs28vDb+/WmxUySHJgkwtlzTsB0r5K6fs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8SRZCRA9TVsSAnZWagAAjqAP/0892lYFd3AZMBSTfF7k\nZr3mdYX9uiu9M0B0VmYCOwl1kTMdwTABmMqcNRKuuLCQnQHc8KmQeG6N/dvq\n8QETpL8mSuwyDToIU4Z/M4fudx9NJ/oabUrX2kCZyYKEp0ot5bh8u5J23F7q\nP4MtWyBE4hz0BW4/AdD5NA6lNHvEbmhLZrxJft6dx3oNaNaIMZWl+UBpX7I/\nFxuK3qrYV3gpnBiy+PTRUCdZKrp3ELyfXVpfY362NqvurbxbaepwILk9hNtN\n4ZNliRotoBMftmmkQJts40qQsfKpXlAPazAxlRMhc6ei975fLwYI3vV3zX5f\nQuFIQq7XsZIfkgqPhGFfBN/2Fa4CzC1IXbMGAu5S3RVdiCLqALh/WhFQuU5G\nDRFmn5G6v42maOsnR6magxwWFhHaylC3IDWQ8OKdHpHZCE3dZ9JN3OL0QV7z\neBe5UtFsaarIENkhUnpFPmJ7P/mFpu0HRczKciUrfpLlMpei75C4ct4j466H\nw4LNXfTtENjTZcUpPAQGKfKRb6YbHp9g80I6NEyfJ3UmXI/YVY8MiNdMVi34\n6dt+5B64HFwfTRrQpA7rkvSiX/XZuxczX172p1T47RNubEYSEfsTxsmUhQXd\nCvGKXFR/pyQMAhgRiRSNPwkqLzq02kqRNiOKSLg5PtCSOlLHPSy5oqKD8wNg\nL197\r\n=Ua7V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8f32218e9eb5dfe6f2a0d2f3ce697f9598ad9825","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b3f7e59-1609638935934_1609639001169_0.2646089674764516","host":"s3://npm-registry-packages"}},"2.2.0-canary-205fa23-1609715615953":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-205fa23-1609715615953","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-205fa23-1609715615953","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eb57da0e9578445fa51ea65b0760de76988baedc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-205fa23-1609715615953.tgz","fileCount":26,"integrity":"sha512-OijjIGiVmOVETtD+kl8Lf2ZvQ8UierIkEBfFLHgv59+uGXbIYnGxvc53Dj2KYwVecvxO0I/OGgCXOTPYCE0ZJQ==","signatures":[{"sig":"MEYCIQDtZlvJK08+jkIhUQrouMBldM7sn7OiWff0kAxS6sYT5QIhAN/HUm/PVjYhbdKo9dt4J2f2+V86PhBq4HdAZEg23Wx7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8k/tCRA9TVsSAnZWagAA1SgP/RuYh5/2pNPfnAUy+hOI\n5OxcBSpBm7NochgElGp+4Wb/MharfmjySCJ5AXmO58p6AyL8ChjK8X7hjM4v\n5G+6PwwuXdEHtq7McsWyL6KYAdLd5n3GPy+flSmqdicwzp++MZKQQSzTFccp\nTx9UIk1q7aLvi19V0BkPA42aLHZRklBHa4rPK8lvX+1vOh8ik8ZD6T92o96I\nMM4Rttxzs/jOjjd2uWKEtxnWS/qrQv+ayIWIGoUo3x9/lWp4ued4FStGzmcX\nesN9Z+ZsCsq2yPpnH7jBeaBOSq1FOTj5c6FQ+ElsCvwmxQRvIfLglZZwPr2D\ny5TT/Gr4Y1xaKx9eFf0gkZYy7vNRy4xDNk09/jxdcDTPRn08sNUVztBSVsg4\ntZnAPnSfnQjCpMzRFZCj6ZFPVgqV+0fwAR2OO9vFDSyqCmJopYEvh8Ad2zzM\nqtK9+N4MVNWSB4eG9RDH3z/qk4hkPIzg7FGiXxY9jzaiNzCVZYfJnB0wGCoB\n3Ds8QNUUTYCzFgvExquvrQPKJKCSBTo7dcawb8WvX2/Yrvi7xGCSFOG9mgDb\nuebnQz1Dni0z7Rdggu47/ur66dUnp4JrSKYDyDDJEz//SMp/KEvix6GWqZtw\nasYdHQhkvOnUEcwGKcpvYM0LEUDbF600L1Te28p7rcaYjH/OOoNDo9Mr7msY\nCDhP\r\n=ktqQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6c2c4cc5c095c05abd4de67c42f37e7edb2c57a2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-205fa23-1609715615953_1609715693165_0.4547610492899352","host":"s3://npm-registry-packages"}},"2.2.0-canary-f32f36c-1609715656088":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f32f36c-1609715656088","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f32f36c-1609715656088","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"30ce2cf15d2d2cf905ba5de1b380bf2e6c1b3b4e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f32f36c-1609715656088.tgz","fileCount":26,"integrity":"sha512-C6vr2vM07Kx0NU0+CHp9smjMNRKTzNQz4NGI+wm2pL9rUxIrzc8sESd+c4oqnhwUzcSezGRmpaLDbdkQTJ/2cA==","signatures":[{"sig":"MEQCIDvg7bds2oHR+lVcl7tjp9a8sanzdY0cFWdYBbZah833AiAvDiLRZOpr6f38dahaRcOWwNBKH2gc2nnY7781f+zxUA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8lAPCRA9TVsSAnZWagAAfNcP/0A6wgKj5h1nq7edV0Nf\nt5fkwSehB1x33rMacpm2eTFAdc7gaThxD51wih6P0/cDyGYMxJgObW80ANRF\nxxbMPOp9vESXAvOw7BVYVBu+KPSmUDdyyQXZFFgT7AjnM4N+FN5e9Cr92C6L\nuwkT9zWVDnFIvPD6I7nDLletNaVTruZ4M5y256F5qG9/8mcYPTGa9rtHjtcC\nw7LZfbWRdkXGdL+4x2aBsfDNTEA3V4cSalzeR65/Vp1+eHxevYSgilMgBnWv\nF809tLmbBg0m8t4jBzqn+pOV0vo/WoLvBHtiD2Zc6i97uhDls0UUGiIqM094\n4t4NnUqHWmzO8e9ElB0R9BppbXDcQK4X2i6RQEAZWg/p2/wfzlZi+XgnNuY+\nF3oooUN8i+sid/dSkuPuRqJi37NaRIfTjWeRkzqFpUeJKv8XLSeZx+/yRSpR\n4dket1vzFAs2JllG+hsVR0rI6vb3NQTXatsnyKzPblQqeFmYxNe5FPHIlpye\nIa89O7kHphK140vms55yDrY0KbGuqSmKMkQUNpoS7isLGTOnU1ZwbTZxpYqt\n4C2+yApAk69Bk4OoroI79W2XFsvyjU/lLZ4wFRBVyymIcme39jnoTAaPAIPL\neVgk/G/IzsNfHGFrJxwawK+Iq8kGSlewQtiWa3wG/jBhj2rFjAeZ9SCOTufz\nXiOa\r\n=NSmT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"635dbe0a869925e9bf356653636d9e7182bb2088","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f32f36c-1609715656088_1609715726552_0.7095134413363802","host":"s3://npm-registry-packages"}},"2.2.0-canary-6acafef-1609791562033":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6acafef-1609791562033","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6acafef-1609791562033","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2a2364dcd5714d76965c58b0fc108cce2cd00967","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6acafef-1609791562033.tgz","fileCount":26,"integrity":"sha512-wz3mzNtzr2Uk8jZvS3M+C6Fx4/O+3S62dLnJPZEt8A/pmzlNdWHbLH9r/mw0jyFvIh8198JFi93OYVBfjSfPMg==","signatures":[{"sig":"MEUCIQCW8HkRaFh9N2pMci21441UEQCG7t07o7+xGjf3GwR6xAIgWQvg8H4kZZfChY6CKcTveW60qzARaimvxuhBLy62hEw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf83iQCRA9TVsSAnZWagAAKa4P/ivFjiYJZj8KbZfGtgpa\n89/JmC8hJiNC3Mqk8ZHPuue1d6pzS4TJrT0R2jhAl0i+eUs47UzJE3bBGo6L\nwHnTiccveXfQs77Dv2wbwVPOGoYGZkF4RE8bKSU+T1EERNt1OshhCffek4+2\n8WgUZMjYZlq0BGno7k29Y8NKxaKCtDyJMCFX9UjcKFC1tmf3T15ts5CmohWI\n9djft56z8iQcVVBMiSwkoT75aC9C46PduqYyRLoCrBm3J6U2n5vNG5NhyfZF\nZw/+sI5+DRk/1292ajz55TJKQMfjfTxmfWs164xbxppyPmXoECAPr189bLXg\nAuawJ87sHd2x9wT+ZdFIIgfJDhyEd62uhGvU5jrJd/KuJYpwV9T2eIc9qvKG\nSWgNvx5FNqOvdpw4lU2Zes1l2lf0qtinkpdD54ULcTofFAoeEBBNol98d/Rk\navLP4UY20YJ/kcliVYp/2RWs+eRiLNtIOmN0CmbAxzdsSupJCRtVJQp86X5k\nTce1MoJO5fCd/6o6sK/o8AZbGlXLthXMSMCA1BzNqWgUCFBoishjPlP845wN\n/pZu4nad8L5mUH8JJFHCR/A92g7urrUL90Gyk5Sh9b4Ggn2b0WEGTyA2aVzp\nPLvQwA7BDmOEMGWXyUKkgRB1JQSTDZ1cJIijVskRhboNMLixXsDSo8cE3J9W\ncNxk\r\n=478t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"a82cb9079f19228f8da5585e207a19c86fd8e0ed","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6acafef-1609791562033_1609791631932_0.3212067649947705","host":"s3://npm-registry-packages"}},"2.2.0-canary-d2580ef-1609806752672":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d2580ef-1609806752672","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d2580ef-1609806752672","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5ba81dd5217abe331ebb3af6004aac6127d273f0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d2580ef-1609806752672.tgz","fileCount":26,"integrity":"sha512-IIwB6/iD46YAxh3OMSxJVaygeRFR1B3ImP4TTEGuUJZLdh6mDxpvCsCl9Y3qD3ZzMuw1Kq9RR0NHDfQKpX/lvQ==","signatures":[{"sig":"MEQCIENDzsotT6uDJUfXO0cIhW3Tnz8pAhto/NDcnQaSElLqAiBDIb41CKjnY7/4wBXLkmeCRsDzwUvrwfVor6F+QtRW5g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf87PvCRA9TVsSAnZWagAAygEP/i5/Z0K1+kNhfIe9dUqS\n8gDKv7jg7//34hwKfaYUbR6AKjMVavv4WDJilS1sb0Ji/LCRZJfPg306M8rK\nrrF0eqnyk9pR1S0XVOg6DpXa/hdQxEPF7Et35NzJ5h0vvD1yZOqYPsnpzBLJ\n3v29OqGqR/gJ113tclRpbrApUDdVyvIPB+6jcNbVvcd4jOvAZASW4mvom/jg\nY3UQxSqFEU/mfwnkLJd3M8EDAiT50d0yKFSRkHQ55cg6SnRwrAlARWuwVC/I\nV5FV62w2AVyUL+HqplTuNAy0CArJDIBxvNA5xlA8F3uCHGuuB4m4ipyXXUV2\nCnvhcR1Z0tOnbeq0/s6tRQl613JFqM3Jq2vY4f55anAJPY3Vronjute2OBkI\nerRpQVFTGsnOXd8ROKBTbvn7ifV9L8IgGgDQZrmHeWHrwBAf2Z8fDIL4zcl+\n4Ssm3iGHuSgQikZMROb2adR+Sn3BlPsSW3/FBtQUTuvx4S3bI99Splegt2E1\nkuOajWiKqEx9p3y5J8GSF4bBvHUSok6zQ6XD/ChRa9OgIXeA1D/kQz3SJl/c\nBBtlf04+/6nt7DvKbftzBTfuCN2WuLHK0DomznW5Pe10yylHK86fmBTsSlUf\nwH9KTe6Qt0x6lMkK+Tq0RoYAoX4N8ksF+HAEhOuvKkRENVYQl0chdK171t4t\n0Atd\r\n=pCus\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9b1086f8a9e8928e79908bf79ef1f9471067184f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d2580ef-1609806752672_1609806830725_0.22272893778226455","host":"s3://npm-registry-packages"}},"2.2.0-canary-f24c29d-1609854120453":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f24c29d-1609854120453","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f24c29d-1609854120453","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"55a9cfeef78da11042a99da65ca6beceeba7f434","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f24c29d-1609854120453.tgz","fileCount":26,"integrity":"sha512-6+mSelAohgl9UvCW4gtRcEb+R8c1U+mbI+WMqkiGIAiQvYrfiph2mtoUW6AYQKTeaB8KAQWRpV6zjqpIL33VgQ==","signatures":[{"sig":"MEUCIAip+XMTs2Wckjv2R6XnAdYG7L9FqEMh5gLpHMwy0yqmAiEArurXhteNFJg3/ckKfOEXImRnuD64G0WZCdrt2C44R2s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9GzfCRA9TVsSAnZWagAAcSEQAIgQTteulTH0ZFDoRjBr\n95GzW76bWrOdALMwDWpdSzBI7poYWPzpnBIXAqdy1VyTKAGcjaeO1KJKSlU0\nDL9KezedzA7DspFWwDfr7AsdqtvkCSOSTQgVu/RtRAKEBYUKdSXhlmBy9HWB\nPVrwzLCo+h9TDiaCwy9rwAqqpN8HwGA1m4FGgM+pt0UV3vTpKZkFXmY+NXvd\n6X2cVZTUpfQhabkdLuI9xiT+exuyP495ae9Dl8gQyvZwsIL8ykOkwmExNIdS\nAZMDqF1zz+zVcPCEgSep8ff0wilSlYzs7sUd0h09ou6FxndCYHYRpZvw4bab\nhTKSunmKxkBKBy64Zn/J4hnmDrpZLS/3CXwkNsBy5Q7RpuXWttxLZ+HI0BwP\nlw2XvTZBYnMDezxowYPtMATJWRW4qqY9F3yx73OexCF5PBwM4WraI+LbiXgw\ndl1FF1PVwnniMjd3Tb/IxF++KFFwdsR5hT5cguamhg/vF43rm4XZQG4YHeSF\n3AjR+/pZlsBkpc/pZns37k3MTTrPDiXiHjZaLw75zxP1PRNmZA/7HcRYhcgz\nFYg03iHBf9QXTgz5lGKtxkShkdVrQ+NanUnqcEcmQpDMKHTle5Hf+h4IdwAR\nATMsnMW4+3WdrBHa0wWMyNpCk94cl0Gz4ol4hbmQk/JWGIdbhZ0pQoD8fr0c\npe1l\r\n=11om\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3cb5d2d2031da3e6c73575e452e4d13e4152e1f6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f24c29d-1609854120453_1609854175130_0.14816968753667425","host":"s3://npm-registry-packages"}},"2.2.0-canary-0ee39ba-1609854319648":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0ee39ba-1609854319648","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0ee39ba-1609854319648","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2307b6e4062733285444bdef189929d10ac3ef82","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0ee39ba-1609854319648.tgz","fileCount":26,"integrity":"sha512-ChkSq5EvQohrEhFu0/x2hey4z4zjlKc0QeGfzyYcSVhNtlAB+MrC461oxA/mVlkM7GHMsHlACnx8K3qirfDV+w==","signatures":[{"sig":"MEUCIBIr+9/3IkmgeCdWoEz30MRONlPTsejXsPNXbt/9pDsqAiEAscc9e2fJaYXkDViW2eWKUnIIytYmvJROe4CLRtU+0M4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9G2wCRA9TVsSAnZWagAA4cMP/RrNAu3zWoLZEESIE3L6\ngbWrYFo+dPrJaxncKshUxFsOGbIzcXMPeFrGRI70Cl+/FMPGtbKMXOF4L9dI\nxY/F5ngNH09L3VH5NbJqhhtyiXK+hhrZQZhRe+/ogfRv/M3tna47IKEB/peV\nCiWON6QZKJQwGlvbLPnuL1aXyuUc+2W05Q7/G2gK8kQmPMCYf/9hk9ACXGXf\nXWsrRcVk05GnPIPYzDByn1QN7cM/sxjMOqXx2QaEeD9fAD6zzHEyrjQiX7I8\nO4Du5AwMUVMFeFYYiYouY9pLrNfStmL0p03x1PB31IwqnDJmA/RBX9tC7RHF\nQbcy9RKF9dgUY4u7TZzwW/VdEacsWMgIvmct9Ohan49x0MrZSCZvAGutXuwK\nFZ/OcGFy4/z0b1Xhuca/N2oV3QP0uwk35vrob4aOCMTrWce/fyifKO39OSfA\nItkuKsCmMk0DJjSA+6Dw61CtS67GcUM53lbuuf77ZH2CTX4w/Ncj/xenmvyX\nyyH2L5ARNJUdUvZYlhruh1FQjHNeakoHAe3e4doBgjJky6RuFb76r2ByVKxq\nhVUJw3IG6r+y0zFyUqH+DEBEvH7xiKGa7N4cHfafkUnCsjEHok3Pe0K+9kh9\ntPX4AQZb+oHnfEpUsumoUVU7lgOQAVcLN2iEl2hXPpoU9aNxe0VXdrnIb+l8\nFeJT\r\n=ypmc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2b813b2e227a3fc30451a9c30d7a8c7f45f6598a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0ee39ba-1609854319648_1609854384067_0.6158601379521993","host":"s3://npm-registry-packages"}},"2.2.0-canary-7d91076-1609889808530":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7d91076-1609889808530","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7d91076-1609889808530","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"037a5ba4bbf5c628b09231909c38360f7ca2a577","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7d91076-1609889808530.tgz","fileCount":26,"integrity":"sha512-f/o2YgObxmKlbU6JFSyIfzncNk3VY4cBrAc9awdsBnvFxarpxUHILmZOG4qM3LoNW+qZdEBgdvlLAIfCGhIxeQ==","signatures":[{"sig":"MEYCIQDx0ZO8aBN57H54r/S5qKiaLjSJnz6LGdmRI8ipnOSsHgIhAP0GTe9K+nBJ832S8w0hxBQ46OQzfqKqMz1xG4+bcPIO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PhNCRA9TVsSAnZWagAAAIcP/2ANS0eZtpAXQDsi+jw9\nRiuq0qIrUjCdSx6cEMn1UZqGnzGX1t/YFqXXylCANcP05trkoa/gRnkjnSMM\nKi7OMttbxQMYJhlYZXyus+GRH2S7hE1YVw4vv46qHhmnMKDnr8k3ZCoIWPQD\nkEqKMnlEnbhTFyL/A6O3ygzmlOI9PYXO3azK3MruRB39mjnuiwpCn1tzTLzP\nqNwzL8SjLjpdKE/iXjo4oza25QDNkrdgAzsDJjUX0YlbWJbUkWxzlwKY4RKC\n72d59QKGnekmGb4B0kheaqHUpO8vbnP07SybFg10+ZFPsBmUjmV44183W2KI\nUxvVRozKIGCdfswnGznvfr9odk30mz90TypTUgXFywX/xpdLHMgCEosUAOi6\nH1oZAO33hGSX8O6193nVYW1Qaf17UkpJOV/tLKkBSv6za/mEGtSoTcBKdBxT\nxIONdhizNNuk9KpuvdOYLLjs711LGSKH5vuV4GZyGrBU4uMcix6aZsMIMdFm\nHtDkRcV06S/JzmBLNi0mkicDkWxe18WxiHHRj/LK8yn9zstszQt2DbZIwrjF\nvBSuznfF3/cUzFzTKHKeK7P02wjPHy/EeOEBuLEAe4Sf2L4r26COuJRPMTVa\nV6V8bCUFKDGVTN6mNcgLhlYTRddkeMT6Pjub9BERs0lAFTgxnuwxrD3qLK2G\nuaZY\r\n=Sie3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"64ff7fd9120d179b02a29a3e0f68d91e06a1095f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7d91076-1609889808530_1609889869494_0.39853240442578497","host":"s3://npm-registry-packages"}},"2.2.0-canary-f8fe98b-1609890000444":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f8fe98b-1609890000444","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f8fe98b-1609890000444","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b278bd964890ea73f01d111eb0ef209b0c764b02","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f8fe98b-1609890000444.tgz","fileCount":26,"integrity":"sha512-xopT6HysR1KBrbsMdYe6OwabYXfF5dcYO2pmmSd/gaEd3AvSirycmzGLTHl7o1+r0U175gKxoMUbJwZyHtKBDw==","signatures":[{"sig":"MEYCIQCmNUpS3GpQjbabdZ8StUM6AXtmRsk84pkujIRxBCcDhgIhALMZ+hGjnX75vArm6qFuRr6bN+ZaKqZq0WjVty9vt6XV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PkVCRA9TVsSAnZWagAADpoP/3O/YEqdxyE8cL2MGyuQ\n4KMyvSRZpSKJF4skuYwM7pGRp/UQpIEmVE9c0GRgDt/L6P/7iyvbbJmOtYSN\nZrENRX8NUOD1IsXcGP7zVSgdFkyWJT6oXZBdMiRyt8g6okeENfaTSz0Ybaqu\n2DzmDapCLjhGtFBiVdkwS2TSMZNhz7qkHuABIssxpFZPifL2dErQqskGMXwJ\nS/a+nU7rOddBS4vbam1v/DdlBO0Y9lSzYCNxq25Rk5LzBWmmPLDat+UHgQHo\nUFhik9O7J6+3cOmjbqx0dusYfZMuh1gOKoeacL4osVO4SXHmbswFto7ruwyz\n72KAGmXtGVZfoy5XWrpM8abSBmWxgBOemaB899iblkBXTwy9BsGzmCAjD9dw\nXDDWkb/WPyjuu5Iu0L8vEPL2AdOnyj1YtbsjpA/ULb9V6kILgY5gPoYAOQTq\nwSeOea8D59DB+014yLERqtvVnwzdeJ/LNYSW7hZmnRpOrpEYvxEQPmFYfFc5\nFtH7A0zQoBWsjdydHXuWXh12Ab7tK72anjl9N4863RoRZ1geXJzmSQE0zvOb\nSj+nW9yoVD0cwvRAREW55X6U8/nvPQEeWxDeOTK7q2CQRoOlFGi/FdBcfr2I\nAmqwkHUQKvzGu8FLwPv4943FXY02miT6eq7WE2f0XybbW5SAeDH4PWm03imq\n++gP\r\n=3cfQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6149730e8a77305a9aaaacd817661489f338c043","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f8fe98b-1609890000444_1609890068784_0.3234257722431202","host":"s3://npm-registry-packages"}},"2.2.0-canary-3601b13-1609910540328":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3601b13-1609910540328","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3601b13-1609910540328","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"23f1a6124deb5b066e94dbba901f03eb660769ab","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3601b13-1609910540328.tgz","fileCount":26,"integrity":"sha512-ZSHcFrRz6jKeU9BFUnjjQXseBBDzzQ55UxbVxnZ7rMLUkwRkvmiutniGxxd8ggpp9QxV127zzyT0Oz0Ry8POkw==","signatures":[{"sig":"MEUCIFqk70FmR7jqgrWKGmRFmCPvdfbleTd6QNQSZ6A/CPOIAiEA/OeqyWYfP66ErA5GQWnVAaSK8u+W97AS+C7Jlx2ZJtY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9UlKCRA9TVsSAnZWagAAk4AP+wTMzCPdUxvvyRtxv4iD\nOZyi9162SPYVebcVchBeyh9BiJ2RK6p+2vATGavQYTp660A6eI+EFugY3bAc\nSkHIyIXnHhg9Ayos6d+uiuZ6WO7niEF3hszpP6FMUCpy7QEWsaqwIPUtgBjy\nLwwQwP9yoAmSXlbU59p8FfVH2SAHwZ7pT4WRQPc00SvBtDeesAKiW9pCiZUp\nzQUPEvkZxIGn1BpFHimTAae2kdTNx9vLrwlWXiSXFv+dLwb1MANtpeGF6ES1\nRpanyI3/YMbtYeOL4dLBA70ZNUA2MsJj0QnsuXWo7U8SNVDoce2lHKLJoKbl\nP7YljPHIU5bRk7ggVqES6/hDv3M7YZhpI443MB1ZN4dPrUNUiP2/9TKxn8rQ\n+x6/27MKFrTYM28iEJKFRELDn+1cbRrSarnbMLwCGt78JVoDcz6GwILTCyCX\nyweK8UTyaZmhFnfcfd+ocPtLSUvPCe98LeXTKnv1rNjjm6+r2h1FYZcaEFn2\nMdY85QV3HAOJ0KJ7WE8llg2bjgZYRQgbsUxRuVfY1kbiXhLLKIYlwq8Omb1d\nDObXJvJ/Tq36sGj8X2qC+QAQR+t428RtPIimKWqZD6aWrdeDiCTTvDgzQWIG\n9VUmFsQtKOSbkiAhbuxOamrrlAkiopAaQQdnfR7cMSZKODeVs3zpuPPTbXxq\nUhim\r\n=A7wL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ab04cab3fbeb668b758c7845434be059805606f9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3601b13-1609910540328_1609910602215_0.9087255052715153","host":"s3://npm-registry-packages"}},"2.2.0-canary-12c6a04-1609943996350":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-12c6a04-1609943996350","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-12c6a04-1609943996350","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6ef83e5efc546a0e497ee64e8326f432e1c23628","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-12c6a04-1609943996350.tgz","fileCount":26,"integrity":"sha512-0IQxJSUDeZrEcV5Bwd/7PHdE+NdPJkh4ksrSToW6VsY31+K5BFZzqn0lWv/qHLQ3ESaQf811zTdwZCsUjI3pCQ==","signatures":[{"sig":"MEYCIQDBLLGC1Nfw2mqO+045CsOqk/2c/lKXv/IVa/fRPZ5ufgIhAIwJSQ8TuDj74ds4xp/SSIx/C9CBlFAXcoKsepWxD3Wh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9cwJCRA9TVsSAnZWagAAWUwQAIMcjIJSDvuVb7ELpXdG\n95UmVkXD952vHHR6gJWVP4w+058OX5MJYgS9QxHtzCW6VdrzoZj3P5OU3nXg\nM644jUBchLBc/pFZBTgph3QH2w/pSCBXtzwnz0L+XwhrHWfBnUPR2Twxvakf\nHwGy5cVoLuF5nWzNq49PNxKbk+lHB6d38Won6lBf01ZMGuLUbJQ9iiZ7TACf\nC6aKkZfAFZFdnFcOJ4uZzFT+NJf7b2RnOmVgE6xI6wpZt/6xvOs36U9fAXwA\n40YpMmLT4n6637vxnV4N05Cb+vPWvatooWliEwDLmDICvhCRtxOitpUsKvhr\nXnwJA8UKgcT6M4wgjzd1FVSmtU9KDkjMHDTYafVjQfL5cw2M3si4gDLzi9re\n+eJoesD5v5NdkT3GAsm2XFtcrQy5cIbIa6f7lJGiIA1I4P6LboSLqErOXgZc\nlggQKkAh+9vFtCDVNEuhIApIeTSjUqbMcggBH7PlVMIkpP/gPYV+hzpWqyuH\nqZJx3RNAYMwyBEb3nkK8Du2+FphjXXOcGR4BcLR0vE3ScTADdKDrQMH3mklA\noqEy/CaPtM+020KJYX6MLP3yfKPngf5VAeMCSqcuy3Yr+1tAkCPBhBmjkC+2\nVQnalc0TJDL69tnbgNYy5yA/TPMaTfmGPFSpWhgE/s621AHNmMgqkP+OqgHY\nvdJ1\r\n=X+7A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"410f19bd006ff519e2dde14c1564ef8ae73d7c47","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-12c6a04-1609943996350_1609944072825_0.6643757979894644","host":"s3://npm-registry-packages"}},"2.2.0-canary-eabff73-1609944262255":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-eabff73-1609944262255","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-eabff73-1609944262255","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2318f388203e7b36500a763d7e11ab82e3f86701","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-eabff73-1609944262255.tgz","fileCount":26,"integrity":"sha512-JKFQk8gPnYqT1YSwdpDhc5MOs+NGE/t+MgxGcep88Sw1DD6cahYwdFtsGCsXCJbGCHADl5pXnKy8gQb5RDiJsg==","signatures":[{"sig":"MEUCIFA9OmUh+TR46kV64mNdOArvH1q8MUkRTRC6wdOgkknhAiEA9PjlJ8hIZXJwgOS62kVyg5WJRulurIDt6y8Q3yz9aFo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9c0KCRA9TVsSAnZWagAApZIQAId+MtfbOlRtTld0luvD\n+WV+JTSzVy2a5fbFpI2TXzcDFtoWMF3Kfi8Dn4iwBC9d0ws6WWCGypT112c9\nYOiTOVxWyog+1lCXOLepFTpv6xEjzj8ipqxAdYp9gtV65FzbH/cuZs7Cqe0c\n5xUEsoVWEE5Qddh1AUgsNC0sRhwR0MzlWTT9Tz4P4lh38ZqRcbqUL3AJ/93c\nJZP8iadNwdaUFpxn0zFXnb6b0W9Pb4yIb81B6SY1DB+vCJ4ynUF4knHNdwb7\nUNZNCbhZ5V/XMYYBxjQhv9xCDo8XctMWV+28Ra6+czE1GIO3LURsbQFEufn/\nXZFVYFVsAXV2qZUuOTKFhVDaMhf87cQJnFuROikt6Bhc8SH+Tr9avH6TC06O\nXDQmmcAojYPwg3kz5EOyry9IH9lW2PYot+y8sjIOICyZw5i1OBnIQ3JHo5CO\nDrTfW/Zk4VQAd1ZwZPeM+7HhkuekzFrC/s5JA56TvjkTZABk54YYhksNare3\nLHWtR0zAYmvAW+q9DUFQ6Au0LsHf908iPdT1NCoFzBUwbnP1IYBdl4pY/ite\nWF8SXyWCi0o5PVakQ1DwCbn/jwaHZSI8ETELhxi3rtn4vHycdKysILhQbXnl\nCaCoIbF662tnZcG+iXJ5Yv84AJjAHRmP7qWioRUfVPGj6Xjbfotn4vuDxGDY\nRez1\r\n=kUeE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3b4c49681f5d4ee0ebd52dc5b9fea97f9b63d629","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-eabff73-1609944262255_1609944330372_0.6525834271062243","host":"s3://npm-registry-packages"}},"2.2.0-canary-4ea6e24-1610012193119":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4ea6e24-1610012193119","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4ea6e24-1610012193119","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"301cc5dde9579684a2a77bcbde300031d72c8bcb","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4ea6e24-1610012193119.tgz","fileCount":26,"integrity":"sha512-vLwwl11Wnx/Ht09j8ck3AovcWSjbkj62Yzpur/tmxsSgREM7UIlRC2iDJXdhWlWMRqxDzbOe3p4GyO+D6a1yHQ==","signatures":[{"sig":"MEQCIBL38KHpEOC2hBsWjJgWyztHzKTTXj0dHHH/z9kQeLWCAiASAIkSV4R3YgplbACyDRlRzJZX9oKG/lObtYKxndNXvQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9tZrCRA9TVsSAnZWagAAs4YP/RztNZC860zEATNGb7+9\nQc/+cIlFNQe2zRezxtwl+owmSAcBun5zc4y8CV0vafXgsz2AhyM5GE/Ymh0E\nXDs7OAx1il3KcG7d46MSs7onsMRFeu3TGSkdShzTYQmFiAjG7TQWQiZUGsDP\nN25eeeDTQg/NZYaf6dS0KN53PRZY6mPTsgUBfBE/BLJB5uzsX+Z7e5gMV05v\noRsuLC5UECJ8O1vlpFTQy1Mj/5NvfFxwWFIwOFC4lnVxpwZvIwMK44j5jhKZ\nJz4GkUvUmUeo6CxvNmTOzgkMDPVmm8ySF5MPURYhDcxsyR/9EFVi6roji+cw\nMZKTWcXw3RXgcfx4AMSFg1PcLTwAzEvA2qS0P39tIahOBkHAg5FUKZxY6qdu\nDri3NoWoNCxeKsmuN6ykJt3RruDQGaFTYSu33jkrmR2U+IRO/kkRybBMyg8l\nhFBzDC73aHE+ZrWg6zmd+Aw8vkt0QtT0dDQli+Wzm3d0f8ltd9uuIKZS6yap\nRgM5fmCdOdrF8EKAkv4ZIWTnhXHWPEm9dVI8OzzGSw5Nar/g6KwZkV4xIhXQ\ncmBdtEYKsc4J/+JwPXDGB5Y83VckUTxZG/vzWSRcmu3CbsOAG0jvukGXKxOM\nOYen5O2UvDCjWOuFaPFq3w17BalRQiLPk5RE2TVnRWOS8xs/YeFZE3Dq9Rfp\n3mDl\r\n=j5ig\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9a4be31e027aa9de45370c72c23947cf03c277f5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4ea6e24-1610012193119_1610012266583_0.7424377625225769","host":"s3://npm-registry-packages"}},"2.2.0-canary-451f336-1610012363027":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-451f336-1610012363027","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-451f336-1610012363027","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d23d4a5fd0d74d71fd33097121a5eac6baa50397","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-451f336-1610012363027.tgz","fileCount":26,"integrity":"sha512-zry5DwgdBGmcDaeJj9llhpvFJ3XnuQyS7kqARN3W9c01+sVSdeY3X/alriG1QV9NuyVuDAzKNaWZUKDH5VGzWw==","signatures":[{"sig":"MEYCIQCq1PERrqyZQDM1UH6EngUmiJUsyg1ynAS/vwUwtfvW0AIhAKFdtzbr90hK7/yif0qIVyMtqk74zxq+i5DM+7aqqz/t","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9tcMCRA9TVsSAnZWagAAYn8P/jI8uvldf9QHna5FZ0Vo\nvxlgfAh2kQd1lHVTNg5DRC53iRbomKnVTsdAQsaJbqC5ecZQdznbOzB/JBRz\nvCmET1Kax2mspkOnmEAcIKKB3doY3Stxcd8ZwCYnE02HtG4XhRXIDcU92vJx\nL/Mis5/DxpocKopMXzNe1QCbKjipRChPjKXR4hBDNQLvbgG211lWkA7FPG9i\nBhBiVG9zbK/FfYpl4TeI5odBdL+9tZyoMZpY0HJADO/GX69py9nbw9PmL+RS\nmd23s7ufCGtr2/1/RD60ramH1RYSD7ROvKTXabjBIVHQG88R9fnZ2mQilffo\nYRWmmM6/CzFdAS4xQvIcEemVd0aJcHHrI4BQvQXB5dTKek/ostcElZ8H8Txu\n2pXv83QiCdzlP6KXgjJHItyykawmQCnQAYPtqUQ8ouJz33qiJZ80x/GDcCZl\naO8STvLTaWfNVsGDHd6qMLO3gl/oXWtXK0/1HWl2zHiaORt0yKmm5ZxD1AFL\nUjYZm8QnzAGV4gwWn6SGmR8xQoSCzuaDsRGPSJCNG+MunRHZZtvW3GKrVm04\n8uMKVlPGD1QzXXcGH8UWD23v3DbU8hTHAl/ofCQ1tsCaDFegaEVOiQcopR7y\nj8jZwYvqja7X+xO87GRdEi5UaRk0U/5uCOqDbmNPRR0+cUAL7I9yn8XxzBnF\nuupr\r\n=T+fT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d1a91e0cee07baf404511fcc28d9f5399f27bcc1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-451f336-1610012363027_1610012428047_0.6169855983850254","host":"s3://npm-registry-packages"}},"2.2.0-canary-dd30db0-1610061377557":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-dd30db0-1610061377557","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-dd30db0-1610061377557","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3e8eabb6f2523a3b27314c7f6f7a3f6ff602c749","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-dd30db0-1610061377557.tgz","fileCount":26,"integrity":"sha512-8AYv+FUdc6aNl7ZUO9TRCS94uH1tEvp8vmpT0NrCTCr4lJEg+xeR3Nz9BElQUliIAXsQvLeWGNHCa8eMk5Hj9A==","signatures":[{"sig":"MEUCIQCprvlIVNv1ntojd9a8v0pCBw83uBucbw32g/f7lcQ5HgIgIAgdTjJRlBJNhIm6g4KaSjKP+l9xLbTZoh34s/ecdPE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95aVCRA9TVsSAnZWagAAQ1QP/RHAkPGGCutVFw4kxwLD\nFzJ34lsvHwtXNhMicVOuWnjwDbO2eAssy4Mh9WEBo+pRhy/BvcbGpRx2RuO9\nvElqkOZE7PLAGBc8S81/GP7XV7r7ZomDHKBBeUJ1tBwSfBmofiOeGpSQqMgV\n201m9yDibzgnE8O521gOon90nb1iBLfAdlS1HPKnPwLUGwlDZJaiqM9ajE6n\najLOvcMOfzVyLEpW7Y4IoliUGYzeYhz0pKn/sMkO8Og0l9Yjaix9gSe6WgeN\n4fIOOIVRlorvq13nKBXUGsy1MJYY7zd6u+G4tXkshvHozsKNIxCOs2IxC7Fv\nfmS7MIC27vzO3jEuWE8xMdkmSyW6fl6b9dBiVc9Ri11jmaClzIuLEzSdzsb/\nZT8l2kT8krjIfMg9YMQPXEBMkhqtwComgyjJd9HEtL4EHymoMLT3zjfzqmB4\nEiI8xyhIgOyKFmKHedY0b7lCtD090jKFMc+DxgVDt7FNg9qhLNqO6QcZ4xaU\nGyR0B7gfVicC2CzQTq3QJvqZVLgjeM4vcLPeQqlTFpKgtYWiTa88iOSQ1CMN\nitmsQ05NYngO4cJ6ZGafQoF499sSseXOH2q9nbdfoO1UGyNMZcv7d5XKv+0y\nviKX+v/DNBsJaj2Kvg3agPY7ONOxUoPeFqjM686KvgMN2ZAk7vox4d96dH97\nGpuv\r\n=/O5j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9568038d8646bee59fe2230bc451bc0079fae5c8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-dd30db0-1610061377557_1610061460786_0.9703491930052832","host":"s3://npm-registry-packages"}},"2.2.0-canary-bb4b421-1610061417167":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-bb4b421-1610061417167","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-bb4b421-1610061417167","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8cf82782cafa222272368055aa1add4aada8f182","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-bb4b421-1610061417167.tgz","fileCount":26,"integrity":"sha512-3cZdYj4AiiEk2fBp2jOdet7GPCPVzcG0S1io7YZLQB3Y9w24gdQs222xM3h4giseP6nM1m3sdytCqwL31wNAug==","signatures":[{"sig":"MEUCID9q5RYQvSnxMC2TYig1Ao82doh36nG4uejSyRePnLBLAiEAqu+1XQUScwPv4aX9MgtdKDnT4Mh9btylNgxRiBmC+wg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95arCRA9TVsSAnZWagAAtBkP/i3xSRM9SMqSrdM8zSdF\nnEA3GfyoNYCGhWt/POqFFnqdJXb6dKjqpyWOuEyc6AVxJ2e46ZYi04s+P3ul\nWT9ehmI4GeR/58eU5ob+JzktPjmoksuT8NIKronVNinWPG5GjpHZRi+vtgxC\nldHsesbJNFJgYge+TBavgtd6FOi4Pog2tEwaiij3pMdox2sAfWGCdx7Gsk07\n/j5tzU7NrJo0OK04foAyucfW8qpAfxHSy3uW85PL53oZ1XmWC6rSEDlQCZWt\nLHs9BFY+tmCmX0Ap6Kao15aqrwhqEkVI0D8IpZMIJn4iWBmHwMx7kbJsQtuD\nX5NsXwhhOT61HWJsV+1FNOqTL5Ie7IyEygdFVlOpXvIyfm2b9TpOAqGoRRIf\naeO6voSdql2ytJJMziw8eZzXEayePFNexbn/mYTZF5aNlk/Qlf++Ql4GIay5\nyJraFTJ295/XnPuGLIdmZb9cXfzUsHRnI0bY+lFqm9JCXDYC9w7xh2O49c2K\ngQUsY8lNNp1y7wYuku7E5pIIn/+jPfceuVhYuFsHfzWt5o99p99se+KYQXdk\nTQyQ3gYWy3MUzTEzoZupvwM7cnTfUNi/opVJ4WpmBbLWkexeqwM1Q2AK/97E\ntuGfef+XfQ4PXw5+OlOYzr4Rne9O0lXN7iSVqu3CePVTtodvpcAGkL2ibWJ/\nOUfn\r\n=aBCS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"469317844bd661c861d3fcabfc401ba58aba6f67","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-bb4b421-1610061417167_1610061483053_0.035833186395130445","host":"s3://npm-registry-packages"}},"2.2.0-canary-d0756f5-1610061447005":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d0756f5-1610061447005","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d0756f5-1610061447005","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"03466bd18ae039003268e362990d95e99389fe60","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d0756f5-1610061447005.tgz","fileCount":26,"integrity":"sha512-1IpRPKzN0feka8CHsMVQY8jeiQ9rZU2SPsCSwitI2YzLnUFGCGcQ3SZxzHgndhFeNZmZZIS/Q/rgEuU8lQYpKQ==","signatures":[{"sig":"MEUCIQCPrpeuhZF4C01OZgOyo7Zl/yABXnH1YWx7c2RMp5JKxgIgL1rsiM8Wmc0r7qVbSKjXcH2A8PtKJQeqWxgQ1J8VOtg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf95bOCRA9TVsSAnZWagAALFgP/1kJH92yNDBT19ukfOxg\nYdhGfr8Rovak3Ln3JywMVqKP8pYqFeHOvOeNQQ0Z73Nt/zq+LyxRj2Yc1UBh\nAC4TWvGToFjx51nxYNXYdnJalK+JrJwqREBrym54YPyESUa9O4dktEGP5glR\n+gqOpry8aDOv1wJ5ZsIb2xlhkFXfHIw+Dlmv9bprX91jzPsp3zeVVBan9DP1\nmn7QOCpG5kFiy0y8zOJKFjPtc/4NVf0cXu/yoxUebIAWalJ4T77F46wUHqZh\nEOq0hrKY/CaHJP+4cYUVfqDlSfpAdfMRc7HwxL9mwQZMeTi6y385WngWGyqh\nQA3JL/NY9MnsFRq1SyqG90EYA6A7kjClHZUHIpoe41NUoaJ8rcOuQVuJu8BK\nf4S+6G864dzL2rw/zzQh9/JL+tuHmU/tWYCYQ776b8/fi5rKM6/Eec3s9FJa\nUXLjIZTPJwegqpwJ27f/VOAamZDHhp2DS/Nn6GgQ8LBbPxMml4Xqi+OVBrof\nb26+B+0K1HY+PoThWa0feZ1heYJ81wDK2G7eZkTvk9h/4shkNzrKpJMWNn1y\nYqrwfJFCnfS40TJiBdHDerx12Nv4kO+7V7UiNKlw+2x6gar0A7CDWBGGhM1Y\ntscUOCzi+QvFZcWeJjDlnKwhvVnLPbE8YhKnXkQwyEYW8Tozsqgv3E9zyTIN\nN9ir\r\n=vsqi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c4eadfdce1b541a525a44d277b6c044f7f198308","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.17.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.20.13","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d0756f5-1610061447005_1610061517708_0.6597317464374786","host":"s3://npm-registry-packages"}},"2.2.0-canary-d09cab3-1610223918629":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d09cab3-1610223918629","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d09cab3-1610223918629","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"26ed3236315d45e1212ee00a30a7f26c3616e322","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d09cab3-1610223918629.tgz","fileCount":26,"integrity":"sha512-31FsqaXkdxLKOLmAnfeRXe8xKbdAlttAiZoDcvTkw+XYnuoDORhux5CZof5H+8acmqDdmJ4r8lzDSny35ayy0Q==","signatures":[{"sig":"MEQCIGaerZys8GvRTIjbWD68nVO14d5MmGMXJRYA2VzeJ40vAiAzivqlbOqPmitPsSlKXj/rPXZCIOXdpn2QiKP3IdWgVQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+hF0CRA9TVsSAnZWagAAcucQAJxretmBerUp4/Cq9DqD\nyh87P1CetCndVJwrVBId0pNFbPfsGFGT2xKpfh8fK68kO4DcVaAx9c8awJnB\nFYlLMCLHD5t6+xm4ctFs5V0VyIpNLd55EEoxj0nBthazVWCPGzhAxg1bvQdE\nwmAakFJrSm+x0ccaX0bhcY6PHj9cNtiL0plRlT/QVDGlyTj0/uuSE5F9Pzk/\nDpfEcZzT6Rpg2I0f8hWee+R7jwoiDXkzRVVm06eJbHaoxoOSFHDNSHo9m1xG\nPiOMVdKwfirhwr2RwT87KfX7/jV/p2ZEbMFj4zREB94Db1WyO58+hD/KxVPr\n/jqQ+AuaxtxAYF7M5++KBysJhgASi7x7EIWQSJEj3gx6wGEESQj/JZ0lEahA\n/V3/h7PixkCIQxlSf7EB2r2DQormxA7OweAoY2MulE3VNFrWqLCNs1f5tMmz\n5gUqAzoDn0yS3TMKNoG0EiM26RzoRTl5K7MfMTI/JeekQDms3PULWEwlKHBj\nHEsGt2l7M90rgnLl25IQCDpwBQppa9SW2bg0WztVpJPKlcM9dZx9Cd1Jy1gR\n7KQjKoUHFqAh7iUsJEvJvl1C2gwQqodJ1ymtwtwnP2wfn7pI18ZEMNd3pktp\nPDYAx4pWn67VQlFRahx1Ezmlqp6/lavbFNc0PEH0Tt6zN7/lIG7op339WTWA\n7fcd\r\n=3lmk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2892c2419bbe114d4cea3bfda271c56698dbbcb0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.0.1","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d09cab3-1610223918629_1610223987518_0.43667938857698174","host":"s3://npm-registry-packages"}},"2.2.0-canary-d12f7bf-1610710690993":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d12f7bf-1610710690993","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d12f7bf-1610710690993","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b85cc6c043dfaa8aa0b9db82bb44cd4165a7bbfc","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d12f7bf-1610710690993.tgz","fileCount":26,"integrity":"sha512-ecV3TzFZPFwuVXlTa+CHiu2SJ2gHX65Z/x4dDx6bhl/driGBY7Fs7qrr8ixu3BhWVJ/pFLRJutqcR96Q0AOZ4A==","signatures":[{"sig":"MEUCIEO+IuSH2viEAeqAbU+rFOSIe+C7PEISvEttZUQul4ezAiEA3b6nr/UuIN/x7bq2G7dv58JO5VhUqBix8mbXImCnq6w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAX7oCRA9TVsSAnZWagAAnFUQAJE/fKNAp8LS1usLet+j\nSoUh0+J061ZVoDex9QO3RVb/m9dXWiFIhmrAgG6Zr79cZCWMVPSS8vDBfiT0\nqZbEUssDxqM9DsKKJr/CGt6Qzer7dFkNzE1NUMI9hjmSFQUWGDk7HGBGoNXc\nbabh8Epn3ZxCBVf68nRRotoT6LROiJ9mbeT3dAc2BcMJpiCUKBY2UQfRGKzP\nOsLNQn33jX4xdzNWsBb2jNx9fRqDUFBYhhydWdt+3wygyZQPsTheN1wOUJn1\nYTKsGNUpaFaYE4at8Ms5kf3fibklp8BmO/t5fiXph0xIRzu1fhXYVtX07L+l\nI2K8DYbzVgUUkvBWxoySBsRaPSKZAmHAxqk7z8KlbDslDtPrkkOasZP3Ks8O\njYbO6dC24u/DGWcyy2IBJhVV7MpWkLlRPmtXSJ8uKLZG1GjcYmFKmTLLH6Os\n42NyF6YtDehp73FeUKoFAeB7SDKNDqI6InzSroeyYAmHGNiAeaqHUtqg14y7\nE0GkVlQpbXECFfbCFSA/JugA0KjHSU3Wye283smwjS0OUbvqFeM3PikwbR5S\ny5VERmMFQX0oODH5x5JpuTxMn+xhlpDiUQuxWh2aCApRV+Anw3U0BrA/6W+n\nPDuCwIy6zL0DuFvkMZMuhWpE8sQjh/W+S/rTBBnqamUecBI00U2zP4uF40dN\nh2+r\r\n=O9cp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e2dd38f94514763f2b0a4aaf4ff12a49c50a1a9e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d12f7bf-1610710690993_1610710759850_0.8644605267283185","host":"s3://npm-registry-packages"}},"2.2.0-canary-4c469ce-1610710857588":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4c469ce-1610710857588","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4c469ce-1610710857588","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2156ed8f01f491f636460ca5a8e7618089a8b62b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4c469ce-1610710857588.tgz","fileCount":26,"integrity":"sha512-I8E56K5h56yUbkwePw1ycIj8Nv4FBrKOP1LBHBTELZDULIdZwm5xVX9ydvrcgUjGj+tg/OU4vJF5vc4NWW2BMg==","signatures":[{"sig":"MEUCIAM1f4kUxjaC59fNIXJyL8qMoJsx3MeXT9TCLloWQsCWAiEA34atBjuP2KaVNrNQIJocRu6RbA8y/n9swOkXE1LFBFI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAX+NCRA9TVsSAnZWagAAovUP/jRjK1HVTHgElG0M+Lht\nzW1XuNIm8C2vP6BL8vAYN2Ist7dfXT9i5J6M3sPEZqalBkGBxFKUY2h4cc6O\nuzVTqXkcDd8mnxvJnbtHO2XOdvZ1ulMPGN5HzuxEvwykOw391f6wOLWUoJ76\ntN+IZrB+U038bkat1yyWyP7yEYxSEPKgYCz3dTd5zBGct5RUTZW4Blfjb8eN\np3h/0ohQajlU5RBOhpAZiOww2Oy+LAkYFou/MXSbhMXoEcH4aC9vTjcRQwlY\nLIXNhRJpl4z8ZwbpO3neRelon7DhMkDfifnaqtLbt2I/Cwuc0yc4q70a1wWB\nVMSHvW9Mo4zn03GMcO4Mok+a0NGBL6FAJc/ZdEuLT/YONkThH60DP2Os6Ee8\nLPSBPJ8Lnj/JqEdJZhfT8b3rZMli152ZyD0qe3HLrOdiT6En0f8117kJ2uwn\n0TJWW8KjBSv1qEYly9p6UnetmRTNi+Pca/2yH6toKVnd50bjimdOfrIjucuq\n+daCbV4/RzXVzJX41uU7gPTk4MWIzMZBAX5UJkZDt63vXPufxAotZTx737r0\nt6fis01brAj5nz4zAt1+hvyHHwYHV9mFbpB8XWHS2aXjvdn4lONkH8t7NQxk\nXG91HI9M1pUv3heQtqSXaE2dGub+pGvrzukSSpXkq2Cs5hzts8kw/PQAT3Vv\nLktm\r\n=ouQN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"fa7fba3c7582378d4873dd8e39f1d47fdd378eb2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4c469ce-1610710857588_1610710924933_0.6915069121655102","host":"s3://npm-registry-packages"}},"2.2.0-canary-a8c4dc0-1610752676343":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a8c4dc0-1610752676343","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a8c4dc0-1610752676343","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4a2ee6fcac0f8740d57b2cb2c1b276ae140931ca","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a8c4dc0-1610752676343.tgz","fileCount":26,"integrity":"sha512-xYcSPQr9ecCZsN6pYz4e43oBFbN9fT7Otvi+3OxjhMcfOZwEDzT+K/myPVkT7OtAW1F29zH96nyOpMUg/sUwkQ==","signatures":[{"sig":"MEQCIB5unLRjHOr6NgjAw4qo4ao1447s+BstjxZ14/XoxvtsAiBDheLyyXZsdWhnUkAsc48GQxy0xmZEnf8xqzFVgA8jfg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAiLgCRA9TVsSAnZWagAA/0MP/3eSZxTYdIgmXo1j4Slq\nb7Mne/CVwTijBrMGe+VZRLxw+84A5FGNh8Y52feIDb0Y2m04KoQ8++2o3QLf\nkKKY8mtOu4yVzb1et6Klw0SUDNcYO/x45SYddgKB8sapy1FEzbdJ38TkNP2t\nyVU5cl7jPtLrOU0y+DwZ/2xpM1uztz5ML41KiB+OtWT2aH39HUcBHvcK4tdm\nfd9li4iEDuat2EOv8iZSf7/YFx4Hg0L1Eh9gR6x0/p6difo/Eht8NB+PS1WN\n9msNwqwcRm0NkuLRFWOsv9yChfGHL3V2h4T8D0THWECsnh7pNWzRJFXtJ4a1\nACbuHc5PurVipd0iT7MnyVlpT56ROTiEniA6rAC4yCOduAwC0gPwI4zkVEgN\n/rNan12mRoxIUVRp8jIaWlIiR3S6WY0/EaAI5aS1Jk6zFR8WQxqcMESmYxyp\ntD/XZeGvjzX1BklqHHdESjk3M2LsS1oZgpQe2ZC+PYLeA/EL1jbVQW1/X6KY\nQ0nxI+9DZzP5V67l21y/Vup0iQbiPMd4P+dZYZwfOX+kHK8qLQZM9UgCG7aG\nfd5kdBmU+LBwNB+8Uu5QQ02ZzLRZ8e/NibfwGXZqbKWPqt+L9BveOt37WoRJ\n4FxjwRPwu6XX7fhm+zpo3Z0eOtDO3fZ7LAOmAdCDJOGEhPtsB1p4ufjZCks+\ni2rC\r\n=WjwA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f8cd6688f1451042af026c1b0b3e76a69570c021","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a8c4dc0-1610752676343_1610752735592_0.5873161961773652","host":"s3://npm-registry-packages"}},"2.2.0-canary-92d2633-1610752858597":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-92d2633-1610752858597","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-92d2633-1610752858597","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ee833f3dd04cfa873f169c27f3cf070ca7d10243","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-92d2633-1610752858597.tgz","fileCount":26,"integrity":"sha512-W2gnvY8lCFQPVzT4Nk+H/W1tak4C+aGWWFJG4ddsUc4h71J0EonSnj/tXt9aKAXPINPlhqljQ9VvLBAnncsLxw==","signatures":[{"sig":"MEUCIQC5bmN2vaV6z3esu9BTVxGj5pqB1Bd6FWqnu1bEEJibFwIgDFvicAjbDMZNiofIUo5w21i2NM2zfFj/BbMbJsWPtHg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAiOUCRA9TVsSAnZWagAA0SoP/11BybzqBW1lpUwRix0S\naeZIZN9SJJLEUUEHekhtRF0E3HQ8Clv42fn+uNRcUYXJOyzmWWFWZCI/uO+2\nd+Fjnn8cIQnEJnvnqV3J9nMDjPbzr/w9oVkvcxD4Ybz0e8K9yYV06pvjX4AZ\n1NZrYtgzl7BQBIJkqJOdzA8MHLLPHCCIgsXGHkt2NJCCqMaUlyyb8WS1s+dG\nLpjLg99tFJ+yBAUyTU9WO8+cYbhPErtEFug2QCmhY31j0lrr1k4h30WXahga\n/N5tZBwv8ky2RDHreep8nsMKAFQ7XW4VP9iwDvQwPptQpoduqoyFzOkACM0S\nS/ojnJj/zYRW3e6ZGKC+b53CqmVApqptosahQgvMdGV6DXyPYY0kMHv/O3HA\nyw1UW+DiRUU5hLj2v2dbvTTNpjjW0AeuATLI2AivCh3sNXd0tK1aSgOwUaxY\nWhRBOI9X2C+xIEEoJWRCvOh9cWnitRrq6cCdEwL7m1KyxAM6g/LI+GDlJh6q\nbY5MDNgeuTBMfHn4yj8JHIaPUqKPBge5Zh7/C1Fo++YWz2ZV45UsGwSILibf\ns95oyNOtA1tIJYlVnFjUO9MWYVmdmnwEA/ZqYr3782LJPu12zCN3P7SsVeLd\nIrLPXbZzj4Mxbh+wcHNeVl0HCiBoBOkXGo/Kd2IMNLlLCH49lAHxSOA/V+cY\nitv+\r\n=kWZU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b24515e60908ec5354afa8ef3abcc1b0f1174740","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-92d2633-1610752858597_1610752915568_0.5577013365946142","host":"s3://npm-registry-packages"}},"2.2.0-canary-7702c87-1610778995736":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7702c87-1610778995736","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7702c87-1610778995736","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"729ded83cecf802f6510860f878ab4d013f0c5a7","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7702c87-1610778995736.tgz","fileCount":26,"integrity":"sha512-amHh6X7f/G0VV6wZIb38IhIzSnsYZscEIbhjfEcXHR56r5hRXmlwwJilAvaitzGpPE6FWR9fMLsSm1Zq2sYjjg==","signatures":[{"sig":"MEUCIQD1AKApghq0QxEW9LwxHe9AEZFNHmGHKu0NFnGBhNj2MQIgT18wyaRswri+vdJZ01Oik/0GIvVUKILhI1vEb/hqogc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAonCCRA9TVsSAnZWagAATtoP/3sBxDoaP0+MNN3NuLFS\nuXrU4q479hBZUXCQPd6ObO0uUMOSR+lqRg0JpBVdo+KqI6KTy2lYI3l8SRmg\n+bsAPsjl9Tk60KoDHD8pxR9m/ke60DXzyGIunbwvq12iPk+dyv5rjfZCnL+2\nTKdIV2G/Znsfa1edK35xXpn9AisdbIso0r6xPnNW4XWR43jFRTvxjV0kMzVB\n3TUDrNtRyGpdX8Mp+1sfNYMZY/3GRQnpu8/Rvz9Bd/duFqVtvVC7GDlDyx0w\n1enIwB18ykIKM01IA6MxyhnRqWkeky1xzaDr8VgvzRbki3gnd7bFMV08utmC\nYVPV+/08hgjzHNx55QL6pewgrDIlycmTdxHeyd02Ke30OWIlZGujYrACKzLZ\nLH0XZTC+llDNzyNWSkfV03YW7oEeAkzaxSvUGGFlWoNQXSLWX4M3oHEAQruD\n6iH0X6yDG7QolRXVLo+/THKOmSC/CHaU5wqO4Ty7o1uM7KspSDNYJAaqw+MT\nVQgcGwGQM6O3i4BUBjXB8ZJrbFy3yNUu2mhY3dGZArKnt0egexT1f8GttwR4\nBymo4AasBI7wzqLrih+XAFQPg6uM6oNTkOlhMj4KwVygfakAQgcGmHwfxQyK\nYX91CObXtbiRCC/m9Px0S+gWDpCW9NCDo1gTTsXqrzQwLLJSOqZXmcWXIM1I\nWCvV\r\n=EZVN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c238dbb1cd53d4de10e50467032065bd6c80b1b8","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7702c87-1610778995736_1610779073635_0.22605113974129232","host":"s3://npm-registry-packages"}},"2.2.0-canary-67ca37c-1610779176035":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-67ca37c-1610779176035","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-67ca37c-1610779176035","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a38cfaa474775493cc0d86b070ca91adbeeecfab","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-67ca37c-1610779176035.tgz","fileCount":26,"integrity":"sha512-NPuG9LKC8sRCAOGlo0Ssp/9tSFUJd3vE0jmEBHVKlG2TdqFRg3bL0zouNvO6bwUYUx0/jTkMgRfurtVGVPeBxg==","signatures":[{"sig":"MEQCIGu40pt7bnM3xeQZTaMj6kzAxDVFwyqzt5NnlwysvLIrAiAxm5aK1g0SzuYp70LuRk0lZC8kCzDEvTj6K8Vm7su3pA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAophCRA9TVsSAnZWagAAC1gP/2H12PGngNzq9s5UThdX\nvKULVZsbaGFJjYs2NhnQFVhKnUVsaMM1Xxb2eOGOStmp+6AKCEoUlFmuEsOF\nf3xOUjJ9R+6qpFSm7lt6aYvylJmdV89l1vNJLIMqPk+1ymv0u6QGvwYzjGyx\nLriOU1vI9yL6H7CgwMl6wo3sG/EslfuWPKggKiJKhdIs2WhyzpOWJwaaysn2\ntV5IjE46ORKfRYxfdPCqxNBrr+42z0PhKI8x+SB2Z17ymAVAKiBQjJIDdqbT\n8ySHemWqHYOJ9vkwMXxYx3qQzwi5jnvTpQjsf1hzClLAa68869VnVEPJtEnt\nUqRxcUWk2YzFgF0i/Flh9d1z4qJY8WyJ5F7dz1uAejK39ZdOcj4A17r6n8Er\nYt/cMsPG5MZ0MpPqXWcXqubPhPCPhsQ6gQP1S/MrB0PrxslqtHekAkY7LLn7\ndfd+5wHfPy4nsoBXVJvnhCNqbqQZYRx9f5ACOQKF7uy7JDt1+a3vstq3CEWI\nYSHbvuuX76a0cxEGv+j2pfP6BKDTHTvLmqsv2GEJfZru1z32OEfk6hL++Jq5\nL2O8arS2/FZ0lrouzr069XYK1OtTcNwlW5clbhGkzjMIytzyScSF4lutTkrx\ntbRHxlFD+M8OMkEsDDdbN4GJrKSyXaeaWhGSmswS11etagM39smNgG10IKkN\n5bzq\r\n=HK6c\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"76306e1a02e63232126efc0fa0899ab05ed20c96","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-67ca37c-1610779176035_1610779233467_0.5525735237781515","host":"s3://npm-registry-packages"}},"2.2.0-canary-42d0b11-1610820742268":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-42d0b11-1610820742268","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-42d0b11-1610820742268","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"573539c6e9b7e0f0b2e47ab5f1c666fa25fc5e88","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-42d0b11-1610820742268.tgz","fileCount":26,"integrity":"sha512-8S8CJ2+ejNV5ysO8VtiFJPEzJCE6yv+gW+hPmgNKcVEdIin2VL4YFLhRtI4Qtto5+sRv4/PvZSiXbcA2q+/oHg==","signatures":[{"sig":"MEQCICEFdYKdNDYqqyNLuVpQYV703hQ+PBTTFdt4g5QHAy8LAiB69MNwXSkrQ+ZdQcW1QRbPcxNP+zx6doL9LazFLSK9AQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAyzbCRA9TVsSAnZWagAASMwQAJn/Rf4V0esrtQUMBlEr\noVwkdIFywV64KPPq+SycKRmYRjRN9R9evyztWwERmqXgbS48oSZE7WxSUcuv\n7jXtPkdLBjG7ItcNBgS0VbqBtOexTuCyCy5T7blyQJgAU0OmEkP/EeWkxMgI\n1aq+dGaczwT6hjrMgNiI6qlq2xS2d4jb8rn3XO8a+dwLc09+5q/kB3IWbZ8d\noiMA180CsrsNslR2EX4K3dr2/5krhE8//o55Y2Xw7LYvz/WpD7/BtEuYBCFB\nsivFMV1RwYofMeowdpga+PIW2+UqoGJ+2uPYbIx9PSSsgClW0ifUSm5kHaJb\n4cFQxCt4y8BepIvZYAfBddN2EFVAFSKcc0l7u9w+HdCBlwDxZCt4c32nO3N7\nvBPDSRBFOW7dC5S2c4fkIgCjv6yzlAP8kzbyMkfWXC5HBL8UwZIf+bO/Dqsi\nm0BfZlt9NprINihvjnNxS42hFwxw/Imj4Q0Ud7Jp/dPFZCtItPFdxg8YJNs0\nRWvJNf7BEQytVQMhA79qYqObWVZibhAr5uTrSrSjnLX+dN15TX+jCzTocbng\ncAZORDXDz4uNCbFfKaWTxaoeT7CU2FZBz9NUN4aCGFERaUO5pLF2embALoa6\nqu+9UTnSIOCgADb2BICFy4f+izPQeQbr6MOazaZgWX0Hu4Pm7A0j9REqBWh7\nkIqe\r\n=VLlS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"737bfde67e92a29d61ab316c8a052da83422747f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-42d0b11-1610820742268_1610820827385_0.3763168208784309","host":"s3://npm-registry-packages"}},"2.2.0-canary-adca190-1610851064591":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-adca190-1610851064591","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-adca190-1610851064591","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7e1f0721e1e9fc7ccbdd0ca8b1f0195482afb93a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-adca190-1610851064591.tgz","fileCount":26,"integrity":"sha512-51pVG52WsOHdW/l74q6vRi3rHiO9Jx1nCp6hmvBmUH0ZYsZtNqslOtGo8r5vDnRkLFvfi3KEGQp4IUP2Ab7+lw==","signatures":[{"sig":"MEYCIQDeNHhxasHqBNcV56YbK4eW+Tm1rfJZb84w5zlnVYHeKgIhALFkESs8AxSa5LPTth3gwLdIkAPhHFPWWR6tPsJMuIwM","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgA6M/CRA9TVsSAnZWagAADtoQAIhZBdpZjEigCiG0N3XI\nzwIxN53qdCca9MHOAeKVxCZYZSxe3kZTaVvdk8gdxQJbFmHKFy8jCHb6A1bo\n28fFSl0T+oGkelEYaeVntlc9i9orHXhiq+IuAxRYZcYERqdcQCNqHID4nwD8\n1KwPyUhuzRIcyU/SwoZdI5hHS/hYo/EOFSUO4AGMTsAsBaDxSF81fxzzo8GD\nDgSNKbQUHhgYoRJXULdSxKA3BAMwZmPkmKS1OESkOpPrW6YmE8iJaApknEvw\nW3qatTqDgoHfwHBKgwgcHRVXQPBF+c2LaFE4ZolL1SWr2pbqqbThhNAwU/c1\nHd5xpM4khGQojnEXKnjNzDZVGb1KUE0SnTxHBYV+S6gWcspoRcuZPW0nfldh\n00DYNIxLYHFh5SgF29ocwoA6oJ+8p9c8K8gnv7yM0K/QyPnR+x3JKOq0B6Be\nyuHsW68sFMGpNNjXBrG26St7T0aA76jjmZcOfQbbttmKJbqER0lyNxPCTWp5\nHBEoGqwnGTtIN87KA8H2UUXfTJzNFhgTmxS5+R0thEJ2UhIUosa9Zd/zpZRJ\n+RAAd7L3+3Gvs3XZMmKQ+DptvY9MNVcuBZtBNQ0No/Vq50Fqcvm8zEx7yLIt\nSv6YLyyA3Lzy6WmFI+SNjeW3I5SQAQNPqaRx+XxaZVDoNBs89JfRtfjDpJio\n3TCu\r\n=YCRp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0f6216253d84ab2b696091c229a4a888e801947d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-adca190-1610851064591_1610851135056_0.7419751074902079","host":"s3://npm-registry-packages"}},"2.2.0-canary-fde3fef-1610925935584":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-fde3fef-1610925935584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-fde3fef-1610925935584","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b2cf3e47e9addf32863e206289aca7ca64bcda34","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-fde3fef-1610925935584.tgz","fileCount":26,"integrity":"sha512-eYSAnF5vQhRJIps0wFIUXNaK65CGIgWrDMIO50jCEjb8QsFfoO+10R1ftIS68ub3E19BH2d41354NY1MkBh9PQ==","signatures":[{"sig":"MEUCIQDA4UigHX78MLTAuXbbSyxCzMcDiyodt/pxV4TAtXIh4QIgJhE1/n6eVSNfuNj8Yl2oEiHz6/ZUEGZIkjwcKqPn8nE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBMezCRA9TVsSAnZWagAA0QkP/2ohN/n3y2geeSjtC3/G\nRxEpvjw7zvTcqYjVkLhaFHhUfRYnaKtdAVc/niZ3Drik59Ida/6f2HNzLH/V\nLMHFVGT6mVYX6fGFqJ9ENrC/dLLxvIm5WYgmj59QBE4ldfOXaXesGzEzUfYg\n6K3KUNmVyaC8q4mOGEUpjRVU18J/aSqqvW1WA4W8TpTVHCx6DmeJZtMj8zRp\nBh0yRYvxFzElGZdbLNaN5WD8qWY3bHUambNUhouJhb/ZFHglMmUaO4fsXSlw\ngiD1frM9moi8SZjXVN1tDZWlL3Yemc1KpqJTry10/8vu6HyoAOXaT2UFm/SM\nrQu1ATjwV6y2sV5dM+mVZCEqaDoC5u9ezMw2s0wGUYMzbFUHbKvm1h+FK96I\ng/RI08BwyEE3jcCRNHkl6XZzyowSDl/tDdZnbDI314rQ3E1uNIeeHDF7c1q9\n6Q0OjanE5ogdSUyOjRUzpi2nYY2g7v/yZM5KFlL3S0ZgXd1PRRB6vy1HXJJF\n7llXwXDo01x2VKeNljwGNJbruHZbZ0IP7YkuGGBPPR5df6/B7QUbUaj8rqYE\ndMjF0vnanPzpvS6gLKHuGvSPuoId56ZjgmOcpGnqSuFnZ/UEAkR7Oj1YHLR5\nRcmxjzmqC0DsZcVlPcRpTFfvmARKfpa1Q3yjnbFywjbmEbg8BYW06KOwdqsO\nlUhb\r\n=VYn9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"aec38fc4338ef3bca305b4461efcc83e3343bd8c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-fde3fef-1610925935584_1610926002842_0.8263784656200506","host":"s3://npm-registry-packages"}},"2.2.0-canary-12ae02c-1610925967170":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-12ae02c-1610925967170","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-12ae02c-1610925967170","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"86282111da72d6d5de56088a6876a87c48cc2e6d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-12ae02c-1610925967170.tgz","fileCount":26,"integrity":"sha512-pUaM7wPJo26JB9kqyE2Jx2pVJSAoH9GNTqUfK+KtlrVqwqzccPWnd6Kh6oEqRkAxzRGT9jLit0f4zW44tOAOnQ==","signatures":[{"sig":"MEUCIQCYbxkJYp759Uiaoy7TH0fP61UsSO+oNK5Rs3/2ifFU6wIgTj7zcBa/uZ1/qCKrmNSL+x8cjsltFRRr2OcFp9BWYbg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBMfMCRA9TVsSAnZWagAA/fgP/0nSIJI5Gk/RVI9vKnyg\nI9faRT/fUny4HRaV8wE2rMx833bAL5KuAwWGl5Oafn2vFjotdl/MCb7RsgNd\nw43KPyBB17Ioq0HGkGkJDW7EMDCVE5GHPoVTILoduCr4Z7Gqx993xFuZZ4T2\nHlLcMtoBtfSLoLQtLlvAMTgoj42bL3J206hqZGaYbw47xR2PZ4CYtlddWQEP\nLqcGBJ1NstNYAwmMdF35aeGacc8ypnXfQdc+T4lPufXKtocJC6YdYS6Eglx3\nDUqiJhu3+KRaDvXsPMGe8+hI+Al2vn6qNLiRdTE3Gelsnd22wOj80JIlWVYz\nL6eTuYgt9h9bgxxjiwB9Q2wDANLQjcCJOP28dvpG90agFOuHfH+5axgnp3WA\nUFSDZqxqqXHtj5+LpkOWWcbllus3lIoxJhDCQ1kyWUghPJNn/SDCGe9dtuqn\n7qIZ0OYSJxJm4Oi2NperJxIo9FWrRQAfVnnr1/aXBpFQ+8G+jwM2ZRJ37pik\nbJh2GjNe9TSbzhWLuJycl/31dQumlHU8dpW13Vys8R9zAevcwQqWfm3wisFC\nOLijcTWNa3465dYDeG/Gvt+bcr2kLkhvwXsNDZWtkNmzzjofYi3z0X3i3el9\npcURqVxE+FF/7BUDWakM2oAZu0bF0qYIOdFrPg+GvBzmoyfzqBHvr0nEeyVB\nPj0p\r\n=91c2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"145b252798126bfd0731454adb71f0e03bc28e34","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.36.2","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-12ae02c-1610925967170_1610926027731_0.12131063219399896","host":"s3://npm-registry-packages"}},"2.2.0-canary-3fe7b14-1611045800944":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3fe7b14-1611045800944","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3fe7b14-1611045800944","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e1efd7cb6e6de4c3a7c326554fd9314b1c36b08d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3fe7b14-1611045800944.tgz","fileCount":26,"integrity":"sha512-OzCqa9+VZ39V4jS6gT/JRD83EkWruJgUVAg/6tcFJtcDeP7uwq/aCLmiiTzo54iHqQ3JIwRkt4eGzt8ynh0Dcw==","signatures":[{"sig":"MEUCIHH/DDz0gNz+ebEDQymmNETAoHdWq5giY4Qi/bPThrXYAiEA2DBLEoiepO0Jl+Ex0N3gTPaamA37ujSqBcst+WHSxSI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBpvzCRA9TVsSAnZWagAAC5oP/1LNnt436IHWRm5xs/k9\nZccPjRccPBT4XsMLjTwXpJ8NsIChde69GzeUNWarvIN5On5SSgzKtJE6lYcZ\nZot7QdNNW0qXSIRlZKzuv4VekWy1Oj7TpAtWYhHnGTv4K08aa/YgDtN6IfJw\nVL8v+4xEkE4Q/oOKvZmTBH3NYV+G+qHvhbJTezGfVEGMkOLv1uyk66PLOvNk\nnOTX9ul+5que6GtTCMcw8pWGYdONXrc/cmAEceE9HbLdO4klL4gglhCHG0fd\n8byV+uCjP8CXrKX5wPxpvInD0AZdbCj3LIZd87SvmwBZNzrKHsCyVm7oXjkq\nC6pu6v11IUbs/Pukdv3844se72WqwRYfNNTwZ/Yam+yOv6tC3KKaCyVB/mm5\nAsAw0O/vwtUo3/Qkn/GJ3oc4y6GhgB1fKTR7VJPW3gRW1sZ5EK2HCZqLfQlI\ngHiIEulS0g3kZbewfQN64Yp7968rQNzMTwiOwztUnVTXnNuvn/4W8Z5Ln2B2\nfTz0pJEr7VJjUl7C1jb9T6QisEY+YsCr2Fcvo27boRr+dRoYMQImXiRMOKo0\n8d5+4grpdNEep1yVqViGYDwPcEjWxDFoxuo+XilX6nHKLg/MxAGDu5qrYG+p\nek4mR/nXsSfoqqmgyNbEX2auBQvkME7DrRX8FZ9wdIQk3PEBd4LR5+svf/e9\nE6iv\r\n=zRWq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"19393a85b30fab3b737ff52dbeb918b6e88009c3","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3fe7b14-1611045800944_1611045875379_0.6672948970572243","host":"s3://npm-registry-packages"}},"2.2.0-canary-961e2ea-1611045978677":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-961e2ea-1611045978677","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-961e2ea-1611045978677","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7038c4e15da2c96ec6b755ee978197d367b47956","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-961e2ea-1611045978677.tgz","fileCount":26,"integrity":"sha512-rGCsAWRHBeqgE1Faih1WzYRQWuf/Yoa15IbImp7EsHTQgaOiFelOio9f/z8lsobdZf3QTijMW1zUE7iM+A6pNg==","signatures":[{"sig":"MEQCHzhJuDxLrqTdW1F2EF7Kj3SEM+qlwNFWR76sRishHL0CIQDhIt4MQEJ0P60MDlulF6TEZ3rxN+WpaBnQ3bWbW/YQ+g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBpykCRA9TVsSAnZWagAAFMgP/A7baFjZeagOAUpxsRY+\nSTUlxjUNoy6H6sIKKuEFUd+XpACUNeSBJfZSPV07lm0z4IXgIitYe5wTQQei\n207WTpPqDf9GvCTbtBaQpPw20OuRsagLb3djM6s+AzJ2thWtuBU6oM41J1HU\nznpyK9diE/biXdCg5z7B3t4AfNWUi27s5x1OA7IPzp7svp4FDFHy9qwC7VgI\nr79W1dbI40y2Bx8cFzcBFNyaOjl5KbhqvdOvdBeVN6X+35TPu+JaVk/I+rZM\n5tppSu1+0OW6k4uVAwZaXS92rHlblYbb3m7KfCTMbsTi1XRn7sTEikLOaHOE\nnWTye6w+BEnXjaPhKLQLb+FY2wO/fL4lc8nKWeZg93TqkoXxtbxFYBtn7j0x\ndvTl+mznx76T9hyfpjqlCUlBI+IPOIXh4TspKGHpUFA4/G9t+EMVB/SqclAV\nKVTWFNZ2Rwekyl3zK8PpsSKNaRYtkLfMqKx4MJDOu1psNCB3BAaj9SXrX7z3\nql50mXvtIOM3DacjbR9Zjl5DL9M+ugVtRk9/h4PPiYwUk/MIq2ZeF8lyxqYO\n8HGcm+WhI+0rcQP3wbT3kWu2BdLY6o3AC+jisYGIMnLtfm9Slkk7egI0y7X4\n2S9oFc5gFHgjCQwfe0nPtiSPV6/gYinhgY9isqSsYDoopk0yp7QspXAdV6x1\nZVkt\r\n=13M/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"2a3d2a7929c1183abace0640e132bfee5c532bf4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-961e2ea-1611045978677_1611046051470_0.9197716445119897","host":"s3://npm-registry-packages"}},"2.2.0-canary-c171b5f-1611145520301":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c171b5f-1611145520301","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c171b5f-1611145520301","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e60c4fcf30e0f18c6e208187bca78a4e9ac8e937","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c171b5f-1611145520301.tgz","fileCount":26,"integrity":"sha512-xjxLcrJ4bf9gj5ZXBB88G0NSWYL4z49aak6uJQQysDLdTvoHPH0NMs2vbJ/qHlQHCJSGOOfYvtFqxY+mTFjiaw==","signatures":[{"sig":"MEQCIBF/NdziTg7WjwfGy+Bnj+/mrbI0ecMpvZOmyH2DqysgAiBt1sFiAXHh5vqx/489R8Bo2LPNec531uquZ3UfVjWwkg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCFwCRA9TVsSAnZWagAAx3sQAIMg5YjNHANKtrexGIPT\nPB2OAwxvJndtuNvitRiPZduOoGnlEcEVrbz5LWa8P/nqkyVU2GiXEpO9QhqX\n++V/ndeyLITJ0sSeraLCkG63xZPjtxIoeP4ManFrnxxQYgNIiwt7MiolqUaw\nA1zOOPLE1rYRKiLYp43H7Z4c3PZ1T/IXI7hh30/KTO4rL+dOe0xe9AZPSI1g\n7G5eJ2vdY9Sq4C6Mj4Sm28IwzgBL+4VxTVf0R50cNDZ+4+xb62XM6za3HwEJ\nwLOjtWYkaBtj5SQQGt0EbvqQBxYcjk/Jazc9p7VP457oPgxrL0Lf8xNN050j\nJiugYogulHPoP2PASL5AwMCW03KRizcqOGYlG2WS75tGeFuwGbYYls/jt8YH\nE1CCRea5uBJPLpt/KfNwPoTmD8U5kJPB68logium3sIZzrbPwjSyuoZCn8IY\n2CoFZjzz/qvAkTUCPJYn8hXzTxvmA3BI1lD6RYC2T4AHIHSJZ3Y3EOKiItui\nusx9/Q4DjotU/43g3keo2Axu6Hx8bjDvNimgk6JCkKfuQlKyZgYaZSzhjW+n\nbmcfJRx+OVTu2xn9ZsEz3/9/bmohp863Z6oFgZNYlr4OfM3o+5AIC7cyM5pp\n+gaHXRpw23UxVkeCKsX81amC2zqpGGcNZvQR7oed+NLa7MbfQXQgClpm/WNA\nAIW0\r\n=c3Wt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1161db650ed75bcd4849b08df841a6558c1b05e4","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c171b5f-1611145520301_1611145583963_0.31974857260475953","host":"s3://npm-registry-packages"}},"2.2.0-canary-811a2bf-1611145720267":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-811a2bf-1611145720267","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-811a2bf-1611145720267","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b36d007b636cfb5dd7b007ee7c92ce7e169aea26","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-811a2bf-1611145720267.tgz","fileCount":26,"integrity":"sha512-YVghzUgxE7/v13HnjdxU1+QA7YTjn6uFIT9oWGnLovy+dgXMefrWG/vb1LNiShgKRxQpnjH0hrOCB8x4R/RyDg==","signatures":[{"sig":"MEUCIQCSnpXYjRL1AccoLmz+mZ0hk8/Nf8ln9SLzSzvrs8LQagIgDLtKxVcpG9Kc4pOIxZVi17wuBrQmwQ6jxl5nJea+b9U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCJACRA9TVsSAnZWagAA4/MQAIpDybuHX4tFUnL9EO5+\nYpC/GWA4FE10V6IEBgEmwnFgHHK5IS6z7oaDB5KlXp2hIDLfWq2IYTtiu67Q\ndPdCPif7WsI/DXCqw2r+rXo7vTG1Zn83lurfYdlWopk8tHNRRBUvv6WykAK1\nw7b2xOp/AR6huIMed1mpyS63AHB8ol8M61NigwWhyucuA1E+cb/oz2Qsus57\nlwenb2a6uG80f1pHsK35C+4GEdYJJaaK5tG2jVVqsPJKM0Y60IXW4a1s9ueH\nit6KYNCSCQiKpFiDNnXHvKKYfwxGfoHMiHcGdZ9O6WJKmbIw6C+MF3bOMrZp\nW04rrr1DFAeWhntOJtNqQGQxNzLmhGF9680c47IXvQE8B2jbRHWPdj0vTNK2\nhtIKGmR2xNHJrcWID56anbtR6o+cDYDjU2EHAXlmL0DZA4ywjBVfSzjjFs0p\nYe6ECrBmLizgQo+1MslWUTLahKqowm74cu8dXE9/KF9hXLVENzIsAW1noFKv\nLneUL/k5nDezulpTQ0aNt7lI3OpAx/j1mwcxoBLar0gn4covCNp7AxBNBuku\nXWwj0ZA+NtYKogiUxvsTC8b2Vr+RY5P4lgSCD4AMZTgFhi92p/p852tC2IkG\nutrmENtrRdp6XYEZSe4mQQzPFbo8/vDdMVvQTc8Zy1C0epV+VHP54x0hdq59\n0ieU\r\n=43T1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d30498035eefc70a8c21c762bf5c7e56d5b9588d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-811a2bf-1611145720267_1611145792079_0.3256164486984845","host":"s3://npm-registry-packages"}},"2.2.0-canary-b87d435-1611270868270":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b87d435-1611270868270","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b87d435-1611270868270","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fd14610c30711e5acf254b64d86a747a76d68d1e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b87d435-1611270868270.tgz","fileCount":26,"integrity":"sha512-3NRPmDqe0RQjgxiWVhPThE50LXSnwe+ShgJ9c3L/wBqnUe84ZDEeIwtJDc+thYBQshRZvnRm9h+WcxZzj/b6EA==","signatures":[{"sig":"MEUCIQDytO1lh5+JN/KAIWfwuNqAN1vSx2YE/lrMJw8/Hqke6QIgCF9jNMkapfbgQwEP/SKbCLnYRthHX5r3+inKMBY5nIQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20378,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCgsWCRA9TVsSAnZWagAAJ8UP/2Po4hG0zwfmzN+u8x7l\nnrv8xcvNDhWgGd4Ryq/TlHphGFGgT1oJXuZirzOgdIjFQNnI8n+AdNMVzwu1\nyXAzPI9IiBlLEUiBAL+0/UMKcCPmPkluO5CfKLrooEVz6tUIJ65F3IACWl6A\nSJ0rB8U4qYl26eKaQdGb0P9nl2bzuVlJH2do92z61vkRzLCaNKMvj1JIv7Jn\nz5exdW0vK15l9exB2IgM1Q35oxmICvGe+urgMjP9ns/VxnlqGN8o9HysEMIf\n7S0FJz/SHS69rvUAlJoRputhkZp4Bj+lrRC++rQkfLh6mQosurlAHY8Pl/8U\nrZwbye9TaynXtu0uFpQ9U7AGhiC8jHzn6aB8JRc3VTR24P1ehF+2t6sW7P9t\nuQy4WdZfm0nySGIDDDBssBWTAC6ZADeiDDjtiYn63q830zTAS5eEKV8lQssa\nr2dmLUxZAZtYDgUmlsEHQs7rFEbs8Ewg7KZVrlrYpRgKJTIUNBnX8chc68IP\naM2DhSsxbilNZXAOn4GeL0rrgiwfgx/pxyxw0WqoKK6MNeFA087u0nlMPoOJ\nYIMrZfx7gJFoR9KRkCVRo/cpuXA+ogjY0PsBtm7ejoyNB6gN7vv6yvKC32rg\n+qcijkwRCeelO7chqz58+9VzC4dFaDtdSt0LylbX8tTO1609Tj9ZzEciOWCl\nYcEc\r\n=H+zM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"78b16d74b125ad4691069ddbf7c6ad7944ea8a50","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.37.1","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b87d435-1611270868270_1611270933948_0.23913038409145337","host":"s3://npm-registry-packages"}},"2.2.0-canary-2ae1c10-1611270905893":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-2ae1c10-1611270905893","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-2ae1c10-1611270905893","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"370bfa9d7077f11b0e7784ef9677adc641d3c89e","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-2ae1c10-1611270905893.tgz","fileCount":26,"integrity":"sha512-kAV1XRATZu6PUtUnOD+7KL9MP0eJi9GO/dfqzpAjEqCl7xm2OpDEwp58pU5K/fQRXGLbiGPcPca+MPmY7dRmow==","signatures":[{"sig":"MEUCIG7/D0PhTp3CSfPbF03NyqPTu1I9lwXy8zU5CZNfMpaBAiEA4oeeLF/0erDh3VlLcSa/K4s9+c8veIyaRzH5uYvvDw8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20379,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCgtBCRA9TVsSAnZWagAAJJAP+waLVoGTsnDcTf8TgRpi\n/waOOEzTITxR7nyPM15LxFsVhmYhvPmHWskSleUwWSS4GZS+cdmDnzyJMZiQ\nU3CSZZB00TMjURgmnlaHiMg5XtWkPUbUShGrZSntcNtuNnw7xM6VOMtF9ara\nhJ8ZeV+T/gsfg0y4PWnEVCX4RrjhDZecRrWT9c8vWysLQGhfA/uDoPNRQvax\nA7rvjc3WKCFz1/4MyLVZjQcqXzpy34/jDxYF73nkwhXk23U4ZQ/qAiV2jgcf\ndutXG9dpWKaFlXOjFLKj9dFgzHt0cyN4DG8pEyrAKcuYfoIHcnL8jTl5I8yd\nSbx7ttIrMQA36pBtoF0CgOzUAXcbPXgFs6x1s2bg3teoBOa2faMK51oH8MSk\nJQk2GUTNJidP06emgmYeMJaPiWBY4qLe0haOp8MckSeh+t/gPETXhammKTxg\nHy6y/7KakuIc6UKhRhIdsCeWGjU1Enczu6n1kdhxNxX9Zm+bM+5dpa2AKMbJ\ntGOpk/Gvnjd6hplgJ/PTasljGi6WB5rGq3VqSphRVeXKdx6yk3Tp3NkWPd4i\nFIFYOhyaHWeyIG2ja2yNalRR5adp2Llx1xTYBTCszU5PWAIGWQGGGfGxRP5b\n4fSVLl3kwEkV3ASDL/ypMF3JPWSjMNHLZbYlDxJFzbfgV6afU1Fa2ka9M3xu\nKjVb\r\n=ZzVM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1b34f187e7538b0e71dd2c7852f747e90ca58b7d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-2ae1c10-1611270905893_1611270977480_0.08294256427458202","host":"s3://npm-registry-packages"}},"2.2.0-canary-8186b41-1611333161103":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8186b41-1611333161103","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8186b41-1611333161103","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"51a3b7993b6fb0882b8a5438c08a19b2e631395a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8186b41-1611333161103.tgz","fileCount":26,"integrity":"sha512-EKvJwtiTB7UM3lkZWeTbsuzU9CtHDRqXl2hZ2dxrezpZq7fD/EZQhUkiXz5tTnBsfNGp6qo2p6y/N7yWxLyucw==","signatures":[{"sig":"MEQCIC7D/p2vgFRimq0BtbmxPkrMHK76H8/ZqgRphWuGDVtKAiB3nNIq/GCBCOqcJJ2L9ESsXtYzYAVB7kOmr10mv+RhUg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv5pCRA9TVsSAnZWagAAaXoP/A3mdrZ3P5xF0LtnbQ3m\nNXKKEt9RVmAJGq5sPziuIncR1ngWa2q14jjBTqBZ43PAKKZyKkp3pGcEfhU1\nhHHBfgifRjp+o0G+gbCAVn+yvaRivE4OdBcXR4Se6m/KxfqDf+aRgER7UykF\n9oQLZVSGcHwkL+KgIcmrNLIb1UbpZKdoiXpD0l6kqsMBmq91kCK7dcg641jV\nIr1tbjEcmCg/CwNYKQUsxDL8skwZ82H53FyjsviGM0m9tSKSzbAxrzelSnHl\nSwGbWqFqMm9WBurn2YadoWYugpmfl3l+l2N/8R0AaoGZFx7GEkIliky8uTLl\nnHY/MxHO1lYrBErLa3aJFez7W2hZTz7YfaE2jSkIIE49ZlAow5e67y5y+nF+\nyOMZSgyyBn2y0pYPrHB/p2lmu9prQxtH8Qz9bIs8KQeURwzMEPlyQN8E0YR3\n6zs/dfPNewtVe2I/RIHh0hN/jk6WzWq0BX+P+5UQ/bTnIx/ye+Zy8mAh27Ay\nIqYxukFeyiDf3MLs724GRrCWUrkXqfym7ZcPhY+bgCZjm5QjcndR85PxBw4/\nzS8lmSfbqZ6C2cPcGO1QKYkMQ4coGpt+xS16g+E2R03Fw4sYBYqGI7C1qkpq\nzV+3liI2tFgLc2lu6sqDCVphyO4bEffje6uGVfqlSs3yDGZ3H3Ujv10Tz0lG\nfTMC\r\n=pL8+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"6e8f1e22369aeaf5ef87ea2cc2f74c216433717c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8186b41-1611333161103_1611333224903_0.29788957005833505","host":"s3://npm-registry-packages"}},"2.2.0-canary-4f2b0a5-1611333330663":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-4f2b0a5-1611333330663","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-4f2b0a5-1611333330663","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"198499cff99fbbed5f13f1c2ba86c979b13fcb4c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-4f2b0a5-1611333330663.tgz","fileCount":26,"integrity":"sha512-+D+Pdo3TEcz0AotdwzZoEUv+35EnWBQGZmBe6hXWKJ8tjDIoEVx+n/IEcglJUr31JzMmTCnbnyVa4iGPH4jb1A==","signatures":[{"sig":"MEUCIQCpqMzqqoApFImkb1T6wGYcR5oHF40ALdR+gxGfpXSVKwIgfgGowng8lcMeLdfNj4xPJO+K5MpSZOMQH+2BLMWMsP4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv8gCRA9TVsSAnZWagAAQQ0QAKQpk77Yx4/kGa6ECld0\n8vSGAHpCvXcycd6asa+mgvaYf90mJqpsY44DCaX+nEEwMK4E7KZLSLjOTCPD\nf4Tp/IeSnTzWW+NjFW8usZGOC09gSsMGiYLFqEFzcjwqcYeaYC5JfGgc/wMf\nmn/Hp4gHAtkcpLXcHlJOQMZlgTnJzrCkkjK9un7fZWRLhs10iitv9lhJCtVl\nB1EKdNHr9YkNDU4fzn/FpFigeeAX46cENMTnAshfO9fZsiFOR7nERKXSL0Zl\ngYaPk2RY8tuyze6xrFNdZw71/OViC6TwpTbmuW3A05s5310+8nwdbvizAz/n\ntTE6d9VyACs4GOnHRNGmAZgdDtK5+waKYRRaQYTkzFJbhCjYlDXNBjR5ivLa\nwzsAbADko1+KuM81cLIUGDfmjdBF6FfzEC8YT3bwV1/a9tsRYVBtENp1Hphu\nvjTmm7KVMpd0QQDlKqhdFphognCQcB5gn8Z87KNSKsTXVSmRBdIdienx7lez\n8zF0Tb1ySqLYYrcWCex/GNqg7EOreP9s/1b9Hnvz1FJe5bmX3zS580/gL8RW\nSTwThU8dL+H8xvuGtkEbp8KlOPjBFvh6l9Me3bM7WIa0CUDzphmOGt3RGNe0\nNVa5reOUcLwi5ne/TClY9KNX5Iz1B3yYWKeQco/j92pi+/fWVlmLDhRnxMiv\nVhRb\r\n=9tkB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"57b4be5db575d3e1def9b32eafa99f0f03b9084b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-4f2b0a5-1611333330663_1611333407641_0.5618376345920957","host":"s3://npm-registry-packages"}},"2.2.0-canary-2c8f18f-1611433272384":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-2c8f18f-1611433272384","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-2c8f18f-1611433272384","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b915cf50e98f3d441c91efec20c6c01282259914","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-2c8f18f-1611433272384.tgz","fileCount":26,"integrity":"sha512-y2y+UbaglkaYD92Ro+9LfDQtZIWCXwdCCm7Nzg1b4mNvabu9RwcXPbIbg0DWoZdJkhtZcXpNZ5VjIdRvFd1/0g==","signatures":[{"sig":"MEUCIAhRSmcTKSVfhybef/5xwdnEi3gADh9f7VYHwtzX1sqKAiEA0s6Iqa+qpU0uZYgOy9jJzsXSZSJaPctM1J1aipVgVn8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDIV4CRA9TVsSAnZWagAAhbgP/2RFBiJmdVY3aNBh7bgL\nI4GOiDJaQmnE3vyKAlG9Tx8xDxgnrm3giILFnznhHYP8+Il9fOfJLlNJQPwf\ny0VHvxrA93BFPTunN14zs0mKvWcI+iMh+buHl4RuoBtZ/tMNi524Ulmvpp1O\nEqRqmAQzJtZiVV4VqIjO8whW3KnCaEso+HmTDfa5Xt6xmSxoT3m2n9nOP7eh\nDHciDV5I24U/MPztAVQ0wKMdy7cmsoAGHEwEXqw21FY/usK63s6J/YxHcLiT\nInvRDa4FoDBNQ+zRGL0LMto5UieVk4be6wIvg1FcUHimUFtIYb/aErW1Lg+t\nzscX3nCUX/0DCB0Fu6+0bUF5TXVDGpwtf68OlXnuGwYIko3Mu1iZcl9FSQi7\nrflJd49M9fgjCvF8EkSExfjjVNlL52QNMftihoApKRpLHtyUniA/rdqAZTdn\n0nL3tjmaV8pyLyja4vW0jPh2YYiSS6sfrl+Z5etJeWxjBD4VhIBpUzvMmxv5\nGmPSmLBCqYpu7RU+PhYuSYhAxw3lhOlJOgG9V0QYVmYx5YRf/N5CSmpp80AZ\n4E3x75c82WNh/JkOsgm+dCNW40Z5kV7rk79jg2JecVLUnSpApPRoEuwxkYu0\ntzVitt/Djz+uxXvIZq7Kh5lr41hchxXNZg2lBrnqe0b+LcPNf9j7AzbDyyze\nJ6kb\r\n=Dmnd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5f7c41f3beed70a4c5b4a7df65d34c4bf3ff4a46","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.17","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-2c8f18f-1611433272384_1611433335941_0.360314140440273","host":"s3://npm-registry-packages"}},"2.2.0-canary-6476295-1611517165323":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-6476295-1611517165323","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-6476295-1611517165323","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"9ab2bbc7f8c30bde25292d0fc4d5f1a45b6df710","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-6476295-1611517165323.tgz","fileCount":26,"integrity":"sha512-lJuOqqdhpwNgSFW9fJoxz+wGaWeb1JHSqifb8TPhd2hMIQzxyf6dK4j70UZyrJ1cNkpC02+69FDBz3Za641kuA==","signatures":[{"sig":"MEQCIBzog+hHjiqMcSGYfRoT/A0R7PtWX12roFvlrSIAcO76AiBfIGLh9rLlpccMH31IL5rOtdz8XQIih1x8Lk3cinTwNQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDc1PCRA9TVsSAnZWagAAWAsP/0VXIdlK+bL7C2dvXTJk\nIaWergL9B3+R67LM1B//U9BRy/Kb5QN5gMkkQFWbC9nyMKJjgQ/I+LgJDYnq\nBDxWaa+NKRsXzlxEmVtemrSt0qcFWBPlkIRnxdEvuVqrXjkqhCSi8jGVd2rh\nCCHTal1hDKOBrTRzeznf2IewLQyfcDzgTWDtTgd+NDuYIUDSFIRZ8dripZSR\nhkHDuIF/xk7ONqI5IRpq6ipZYBpXjujquhmge+0KodXf+lkzJoLzGN736ybu\nBh5cp0aNDLjuGDOBN5VJYdSMMANZag3bLGn7HrMLPtC1oWnr7qLS3qtXZpIV\nimRNKAr3ccaa+gma6rABVAfqif2+hL2xLfNZOWxXpd/6Gmj4o0HuXn/2h64d\n+kQ1xJqLXUnP+xc/gEoZNKJsGkuCl7LWnbkRXKnUyj/L7D4zrfZvo/nFVhAZ\nWK9SJRrE39KYTAFn+AACobhaeEDkEBXIh0X7EEfSHiesle2CFFRYqF5vlcpu\naCjznt9AZfD2/HVloF0hvZx0ShaIkW/WBJH4Ha80hqJHdhXLWKRL1sSYVrky\n7qG11inxwO0Up9ngmeuJuur3Fl0dee7XLxUlWF8kbg5LHka3F4GH+AhlHFew\n8Ch+hZNVGoMkFxOhQkPOAn2IhINbEQXCyLd9JkBZnduUGeIopdPNpY+W5krQ\ndLXa\r\n=lWY2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"61943ee10507c75f04f43015b0f6deb31c2b3418","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-6476295-1611517165323_1611517263391_0.8796537253383867","host":"s3://npm-registry-packages"}},"2.2.0-canary-71403ff-1611586337939":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-71403ff-1611586337939","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-71403ff-1611586337939","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"b9b73bf0dac44308aefa7970c4c9e9dc80ae37e3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-71403ff-1611586337939.tgz","fileCount":26,"integrity":"sha512-4woABhVH8mWSxkOXLuDdRFx06gycrtR+QbjdYleYN/ipKi3+ZkMuXpQ5PwR7O5KSrMLu4ufBAQDwT4mCRjbmHw==","signatures":[{"sig":"MEYCIQDmP20pO7yufWtjDiqxmvJx+IyyNwNbXj/vZL9449C4igIhAJqJvY6Gv/6NqXcC2ldf3lH3rroDzPp+pnWS6TnGoO/J","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDttyCRA9TVsSAnZWagAA0SMP+gPzxgd4tdexH2h4lZJy\n7N3ksREqev9XIaMiEqNPy6+fbTfqfXFqR9Zf1k5xN5FQAh3iPEfFUK4FZK57\n62p2P8edvD6lULu8lAKkPyNykkeWTUkBm74903duea7IehVmUAyVafrW6ySZ\ngrxkHrCi3hm/5AyunzVUso57/Pj8wbsZXKcaa1ng/jNn7trE00+vJz/9kkhq\nI8PwHcApZj5fwtml/VBPm2xp/WJxEd+sCFf6AQWGOPsdNYtsI8AuIgGTKXfL\nIby2/oPc2DLQpgddbkXdAbrC+6f9fdYKWHpMs+hkkBKwo7YBbAudmJ+BS1tm\nbAJldEgnhNtCatxbLyw5CcbpayQUz/cN9cFWL1yuyhUjVN5EnfR7nUjP53EJ\nN2vWBFjAZW3BDn36frJzR1A3fwE0H0lriTj+/71/9K1xdbhP3xVw/FLrFJ8w\nBQD0ptIKfi1YkTmAB3yVL4h4gmflKaXt/aYOkWSnPjSDpBmah9d1GBIKo9dT\nlfnIAeLP5gb1BY/glp87VaBmYt47yprmkm4sJ5WWeoJPIzsKSXrdmwfQaB0p\njUxJ2PDR18X6q1Z5RiF9K9cGtTVUOmXrH6h30sPyoMJYf2CoDpbhsQdA0bWL\nn6uibo51WI0kUjCzgusRoHKITpu5DfxHP58NEe+6/igX4ob6P3b6vJhXK5i8\naPcc\r\n=Lapl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"867d6d1fd18d200bf86376c208c365098efc20b2","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","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.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-71403ff-1611586337939_1611586418157_0.7535534866872315","host":"s3://npm-registry-packages"}},"2.2.0-canary-3e3bf94-1611591136236":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3e3bf94-1611591136236","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3e3bf94-1611591136236","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"28e6f6228e98db2aafb3c4302f55c6d0801e39b8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3e3bf94-1611591136236.tgz","fileCount":26,"integrity":"sha512-niHAwqkHD3sXbDP81AlXDgwbabDY0lTYEXYyB3NhLqw72QhZkredqFHknWt6IDEwb0H/ETNOV7ZPdSY1cRr7Vw==","signatures":[{"sig":"MEUCIQC0V81H0yYsMCwGseXrtR1iSLmb9NOc4dMWIO4A5vihzwIgSgM6dMCsjXXEnju9QSd1IY7H0quaW09ujY+5p+kcwtE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDu4pCRA9TVsSAnZWagAALg8QAJ0fbqdzqTPbl+ai5Dw6\n2bToemtZYn37OAeeWp9K/0a8vagsqEkUYV3FptnenVLvH+iBVHx8f3JCaP/t\nNHcjuLTBDTiaPi7RXoqfmJ2urG20aP+aN4l5D/9WPRe3h45VTaoRB8NTGDrK\n81DKk+9577foy/R3t5hGGnaPeBaYu3+MnmrVd2GtAMr4PNmTygM2ZSZU50zd\naPmxEKHtcuUr1Ad/IF7OUjh3S3UI8tr/X40EDBx3w7iRSxeQnL4uNo6BLTq9\n95W0u5oQ+bFFNgdg8k3WWZnegqKnSWk1FgcsRqgsBuzgPnWIoXRC0hIp7qqm\nwWL7H6PXAMDjExFOKiTk5EJ8JYNNyRu3NpVo1oXeQVdTGDVyibGEFIHFTy1I\nBGcG+HCnD63813nejhv2BVBU+LKClsIkZ+pRdLuoqZnmSNG3H+ay1DAHX3qC\ngcEj5UWgzqw08Ks33//uvmYWwXtqzyRWUlRj94A/9BM1PK5lpnXfKufe7Leo\nSDCDtTslCUknzq9LPKWQ+FGg26ebKMJz0l0XeGjXRyio+IZg9R/Th7ionJK2\nJa4dvL1XHlUnewaq1q7PBCUxMxDWsM+KhqGfH5DVan5FptHeKaHXwdz8lFSw\nMK2NRS245afeKxblpe5VuHM4qBnG6Q8scvbclkSJMMm0ZD88BwJfKZGQD/1x\nNcLd\r\n=cBi7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e6dfb5c14bfe4174627dca0598dd6fc851a17d24","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3e3bf94-1611591136236_1611591208506_0.9023355474932742","host":"s3://npm-registry-packages"}},"2.2.0-canary-c5b1c8e-1611616463756":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c5b1c8e-1611616463756","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c5b1c8e-1611616463756","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"f495e0bb404a75482d7c80ac5b93f86f228d7218","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c5b1c8e-1611616463756.tgz","fileCount":26,"integrity":"sha512-GhEG+5OqnBLgNTgvYRZkD+99AK8M1UnJ2YfhIjoaPC2rTKgnynqdYH3j+KqbVve7fvTxaN5M6MBDdN+L7c6fWQ==","signatures":[{"sig":"MEUCIQDLfdzKkXWdIRZDKs1WKHPaepFlke62iu8VSg0PHeVgxwIgYL7DVtbri4/TecdlzGC66nNS0RVM9FX0WB4QGr9b7WQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgD1EUCRA9TVsSAnZWagAA9HIP/iz8yJbOFkw8sGbMn/V0\nZru6TcQxqA97NWEy3Ivd1KbkdQ1wrRc9UJvPGd3l0x+iWPOd4LtOQ/nC7vws\nKp6RY1bFSR1aNuHTa2hMGSKU+KI7pyH7iwCWvICgBzq0WaTlp6O6lgjuXl1I\nlOJW9OcWdzVUXgOwCc/l3tzO7Gx0fQNjJiszE+8HLltSjKmf1I7D1XzeRffi\nPwgF4TeEs/iAPRu7tOChcpZIi6tuObH+viEVIzxBfJ1qcMpB9NVJX8/5yjNd\nb95BTkmOYFY+/eCGX+Rtx5iVKamOqO1oWQiNJAKqy9l2ZQEtkYdZr/ZTKBLZ\nQvQeDwTMVJkHrFJUGxWRxi4yQqFsHt5rtq6civxXgdJdkktoi6ArrHfJVY9C\nQUbdIW39pVpMb5Bt3wW0r9uTRqZN+D4iAVSEsNoZHPbJfUvs2UfNJ7GnsCUR\nHlziaCzJMnaDKpHGSyXbxXFj5f1MeuTNTDyPtamGCY6826IhMDEPMsvHM5lt\nwwRA+K66xidXWRhIlgAzKHfSfAPzji4tUn+pl7UmJx+JwCmI8j4ttGuJl9zv\nR4cFZgWhTEkQzB+TiLIdJE/gJ6rz8Ar4wfZMAx2CxY4WIzmstGAmNvacVz5w\nYdcoU4ansZohrYy4+ogo0M63joJlwPsjngumUVjcXgUBxJW7W+JDGHBBU1Uq\nUjAk\r\n=Eyh3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e180644d0bc8265cc9a81fa6e98864024e31e7de","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c5b1c8e-1611616463756_1611616531572_0.5834193284262743","host":"s3://npm-registry-packages"}},"2.2.0-canary-685ec6f-1611616501032":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-685ec6f-1611616501032","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-685ec6f-1611616501032","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fd2c8d4d9b556539ca7e46739fb4a1901a4ac7ca","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-685ec6f-1611616501032.tgz","fileCount":26,"integrity":"sha512-uj3DXsPhhy0cN1lxZGpiSGIzqAHMcBxIdMG4KyszdWbDqhRkw1Q9OKmmjjEox9rhy2JsOqZWvboWuxzsQu7l6Q==","signatures":[{"sig":"MEQCIClVDqaSb2aJFQqhS0u/YfiojZb6uKC4+82MOHCi2GzuAiAFB4Pc0iLLE4E0qTcu52ug3HgBymAiheY+JjXZa8Cb5g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgD1E/CRA9TVsSAnZWagAA6dIQAIeJ0wufHuJcV57Qkibw\nzNi2OqbdS4kICZvuKGA6KmOSSFN3sKEqasW1KFyD0vAahfCSTl1G8e4E74xp\nCJrUjZtWxmhoy74h8cJfDevcHgIv+fQ481IRADnXxG/o+vR3oGFz78VTU6Ov\nWdPw/6USRChdKtrU+QEqvzLMyZ1NlZ16eGb1dxR6XB62yymeDw1YxZxNkpUi\nc7b9D8XkfV8qrJBcXpDhPhRPcrxRMrEHBRiC2nFIXaNWCeSHVp775BvPnXaa\nS4mCnXUVGf7KPWis+VxZINcopKk2ZgrmCAbhdSd/voFoanPskJ10+kF9FZlN\ntyDNMaxjMj0C8WCE+ZW5bL1mLcY9/4bW39cmIVg9L5SKOGAgcOpu/Ki+VSFv\nSh6qAFZ672zzzr9sfk+94FK5+LS32mcFK3v+dSvXRhgsT8rsK5phCgOZF22/\ndiPWzfD/Fkbr1tjFWpOgkyPjqlW5StNqGkW2VVFremlHY9MLTq3eaM027B4r\nO43F/t4n1mvWRGeUGEbnrwGvbepwEaDNFoS4fYeU9Kd+XpfngjzqnWRFUsyd\njNa9CSax/xBuFedAD3gtE+btw4aclwnH6iStdec8a4oT+KclNGu1KStJwzdU\nhvBhefTIhRb9mhsqiIpvWssKNUl+DuQdpx+srOIeDUJN0ghjMh/Q7vUiUzOI\npKzJ\r\n=OI7D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"09396602784c46a31a47700870c8597b982c974c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","dependencies":{"fp-ts":"^2.9.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-685ec6f-1611616501032_1611616574497_0.15723435091940097","host":"s3://npm-registry-packages"}},"2.2.0-canary-989c4bc-1612125201183":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-989c4bc-1612125201183","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-989c4bc-1612125201183","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d3abc09bf4f7d8d81e3e4d14e15584846695fa77","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-989c4bc-1612125201183.tgz","fileCount":26,"integrity":"sha512-VgeJOeJLTf/grH7k9toaDU2CtNr5Yf98+D1qqGRHOm7VnRefoDfjKUMFAjwudbpJ3SAciJa9w/qVz7f/7CyRpA==","signatures":[{"sig":"MEUCIFcFv7m+7K57n6GDHyH8q/Fs9SQPS80LjkPjvCVWVIRcAiEAqo8NOsnKbSKdZV7OX1LVjSv8fcPLSAhm1yeWp4ZRics=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFxRSCRA9TVsSAnZWagAAnboP/R59Jx7OLufw3bSKG6LG\nFRMI3wDkaR0lvz780p1SpQ5rZoVdgbjNjxgptLfZlcyQREZZkf09vFgNSjcJ\nHNRL8w9eWDMNGilVhd65gRADirivGg6BIlOC6GKxzbrTWa//X4ZNk/wgeDK7\nLnfVLPs2rMegZdLmB9vRn5d1NpJ59vzXcB98IavyLKjnzNVM92uCV5qbPl56\nPTLQ19YA+5irtWurzU6DYAsret+cJL5Rxn4i/pD9o+HMaGR5qg1t69ceqPuW\nK4aTSFeIB/AGpCGtkiInLuV0zqY8bBrAdXmMfCwFj0GR0JmXKTyPCPDSTnZa\nb5dnX4J2hZR572E3skQV5z87SArbs/zcYVMbMYMa9v/q8rhO3wbQW/62VX21\n0rl+gcsPm7FXv/AM1UG9SNQfmyyQyVXqwrxzylZkNQDcBmHRNnyxWgOk4dJi\nUb0BwzEaJKsWcJEUbJjt88p1mu63wOX5RzNb0qLj5gv3H7N2oN2Mnl7FeKK1\nMZusc7g9B8xvVYj34HS/lEBZUkCMQcwaKsQs+w6ZGbG2JyqRnbUkBUslxdjE\nJQ4o/oMtMSTZRHkGPTvAd7jw9IKKvtykunPfkYOagndcMKyB+QTRhrgzsq/U\n9tjJ8vkuvLSbAXejzNuL5/Hhysmb2ZZYN6fHZc1VCbQLf4S9boictqrJWVJl\n18J8\r\n=kqPD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"50c2d71f96c0a0053654eb455eecd88fb0179495","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.20","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-989c4bc-1612125201183_1612125266085_0.7652397189249112","host":"s3://npm-registry-packages"}},"2.2.0-canary-3ba294a-1612355534064":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3ba294a-1612355534064","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3ba294a-1612355534064","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0b4e3daf9dbc198fca4035258c764b6319a16570","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3ba294a-1612355534064.tgz","fileCount":26,"integrity":"sha512-ZPPycL1f1bHFvmOZH2S+MUXl97xv0U0XTJmZEHsM8/9miDOgFlOfFdgw2qDjR06ZkEWE5WMvN5qRBAEk/1kuDg==","signatures":[{"sig":"MEYCIQC1Np2amDJwMSgdE/rPcwIG7OOQzroDLHguK7jYDFFFcAIhANj6etjRTPSEaoE+GIRbGeFSo9C2HHRevP6WWy2RJfQc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGpgMCRA9TVsSAnZWagAAm5IP/0uOT/Ix/+CY6rPd02oH\n/7+DZyE5d0Z38EVJy03FZ9u/qlaWbN/XLl3v5zWDGwhfSUEWgKF9U31HQDnr\n2PMn5wqufmQyqLD5o1oWXSQU4562rnSp/juPTZ+rjEC/2GEb33MQm8e+a1N3\nAsYSvJEY/Vc0OFXy0IXAiM41UUtwg1K+N3W4uruTbGKqVzcsrA3v8WDQmy9O\nQiBwAJb8TVW/pHY2HjItd3G3zZTjMHOIzC0fl7g5Qznfd2gInO5vsqkpcRlq\n13An+UcDfgkKOVm7aJYcLTAz3ObttM5DYLlzBAZn+6G1VPPgUQ/LeThxwUm7\n5FOOAAn+5XXrxe66lMThHu37xYtH+IzTbnOowbBw1K77jblI90XNdTIxwKOD\nt6EM0XxB2L7eG4EztyjTTtoBH0s675E7BYA9pGXDt4jvJDGbcszulxvHMygs\nyAOYs1uHY0jhlEqen4+nUkgoJEClkp1IxJYf2RHgr9rlmmHZ3Bo+8tfGLN3E\nX0V40/U04GsVgvyUuWdcOT2Oz4/EKkCpAkMROa1T57nMGA0CAdPL5gz+3VbH\nV0EPLFhKsUpyGoKVREVRBHOXmgvcmPWHNRZwHKXAhce3TF1kC6BT5mTuGfMG\nuu9/P3zVyQYvi0njrA4aB1tbFdll21mvXbClYuBTl77JSApQSmR5r4EZM4QP\nYC77\r\n=bFHO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"52bae8f1b5e93ff793a7dd8c4ee77142e7ad4ae0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3ba294a-1612355534064_1612355595453_0.28299348724451723","host":"s3://npm-registry-packages"}},"2.2.0-canary-30424f4-1612365022004":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-30424f4-1612365022004","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-30424f4-1612365022004","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5f57bc40f1b9fbcf83f218123c391a22ad6f3188","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-30424f4-1612365022004.tgz","fileCount":26,"integrity":"sha512-70LQDsYzdzb76eIekNV/eD0yaxQMiv13Rxd4fwSXmPq5FSt8nMKOBS54Akv4FlY341rD9rIPnMcTATwgfxb0nQ==","signatures":[{"sig":"MEUCIQC6fO6YqVBwuIh4jzk1BmOlEgSdXj3zmEUr0TWzXve9ewIgJFHK9Pq8ASVyJ8Ynj0qNnmwWQnahqgernyu9hFzdHRA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGr2xCRA9TVsSAnZWagAAa0MP/jHTb0d2NNGZ2fYfpX2Q\nbSrp8yEM9UKvS2qSTKTAuRT1D/yvltWICtpwRepbIOrg1+piP2UtzYXeAfi4\nzfvoddMOEPNcbiFrMC+bZ1AKtymhS8e3NOeynF1EL1+/qsCskC3zYXtMQ701\nC6swIFkdIHqCBgWaKEGkRrEec+2NGUp55alL9f2qImGyQcp1OaCYm10m/auj\nTKlQIm3qDuH6cnb+827JESkcngXk0X8MMx1/WiTrRHqGYiLe7WD7OpLEpjRT\nUeAYUNQ2TTl2VPyuTJsgtEq0KUYAaMxR9nAriG9OdJCQrx2fCdt0i2nkp7/H\nLJqahKI5/vm7bIIIF3uS4p9/H1JtFbLBpb/qphPZRteG0eGdnrwinhCU4jGc\nK5YUkcZljCYuI1NfBJtnEtpHY9fZmMgf59AS1vC1Y3rAe/IURfE7AFcXF7L3\njg/hA2TJvBCA7VKzMTFL0Mo48xQLZ+aNUwED7JKpvc1efDgyMl3Wc+zjzlOc\nKP+BCupoQ+ToMkiyitG2zxdDJLeumFmZP1TaOrym+Q2JnRnTRX9K2MjbH9ig\nRSw73+Tl/zp4Fg/wFhfEeRaOBq3Dn9kgXlkBWH79BdKPe89oJU09zAkkcoW6\nq9/KdgavKvzGsfnWFdgoWuPmr2WUnHvW+fghQjFXfGadGR0aWM12BBkeK2s+\nq9/b\r\n=Jy3z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"91ba45159c35cc398dc9379359f7b95a08af015d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","dependencies":{"fp-ts":"^2.9.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-30424f4-1612365022004_1612365233046_0.628504836861564","host":"s3://npm-registry-packages"}},"2.2.0-canary-f9ebbda-1612548396362":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f9ebbda-1612548396362","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f9ebbda-1612548396362","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"10870c12fe3ffbe3cea9a92d0f64e81ccc5012e4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f9ebbda-1612548396362.tgz","fileCount":26,"integrity":"sha512-7NgIFBZJ1Pru2Np/L5gUZMFaEDOby1qYK15tgvCfuFFxiOL2cCBcGKRAfBjDbdpuY1eVhtG4jNpVM3x1230KEg==","signatures":[{"sig":"MEYCIQCyHptrEgtfv11lyLPp9LbXZ9MOhcl9efqWYx5zJ9LbWQIhALRSqpvyh5iK8T/lY2hHBlih1lERi6al5SfebLmWCot2","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHYl3CRA9TVsSAnZWagAAO6sQAJXU7I/qa836pnSPnzPO\nLVj3PApT35zWOPfdKml0id/fhIHuSCgxcfMgERBQhcsiaUaaOMh94V1so/D5\nINh830sh5gA8RkVIjUpz4/HtJxR84Sw281d6OhYsy79M3Oc9X63jwp01liB7\nZG4v/AGvvTZPF08cy4lLQEFniOv4Ykj9t0PSgTooCVK7HZLQ3/1EvqmajJIb\ncXfEGdEFK+lCO+r8BHaeF9m73fcfziKOE+0KEDhk7HL4EbN/WWz6AMfbd3XF\nt/uaVLSOaKXR23uCjkxAlWA2D9kKjyXXUzWxvNSYDF+G4Jbb5ncVq/6/cBjk\n6Gr30itpFzfuOnBL3iY7Q+KV4k1aEn4Vdrk8DNMHhOek17c8mAzhJp2wyEXe\n7CsWYT11rCRQFxZ6IdPVBSSA148o6ZK0gPiV6HbfAxU1VgBFfExQqEJ3TuNn\nJm03HD6d15t+mImEr55fOkGtqpZHeUwjYyxGraITMos6GUGELd92FEkEWewB\nSyeKROoL0hiayNHGCu7wBqq/WecLwJaVFb9Xj/4A5dtoyAz8BFKjiLDFvnhU\n/1iEip8mmbqthWz9OmrKfcDrU1HEQ5VsFjtkFrA8hLEFAvy5SrIWbKqt6TZq\nRH82J71NxQdrQ1EfqgQQMtN8adethZypsn1coDobUOUB5F3QaiJPy7ywF7gi\nFvVd\r\n=65SJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"cf7ac30fe320bab4491df5da3767e6b84fa1d887","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.21","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f9ebbda-1612548396362_1612548471350_0.6716896023531262","host":"s3://npm-registry-packages"}},"2.2.0-canary-35f44d8-1612628918941":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-35f44d8-1612628918941","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-35f44d8-1612628918941","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6e59b9f1f9644c62595a351365fadbb7322b1f65","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-35f44d8-1612628918941.tgz","fileCount":26,"integrity":"sha512-t5Ntr5ar6XJ9lzHXbF2OOznerz/8UBnvqYz+Niyx/QORVKdWV80Lf1MAfhiQm1gDwyT4fooF5yej1gyoKFYTqw==","signatures":[{"sig":"MEUCIQCKXA4Bh+CqPgQDwmied3E/1GL9sMiBQlCdcjFyFUzr+QIgc6glYttPIlrnevPuPBd8k0xBRqEGJdcoStbxy5tELEg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHsQDCRA9TVsSAnZWagAAJmAQAJdHz5yry/3utGZ3nDsB\nPYkZQbYXLGEXxUuTnyCJrc2QsCA5g6iYKG59hZqO5kWVGG7f50aBc8Ew6RuU\n6xhA3b9rMjFAEViVzYHPolsqO1YU3Pv3XtdGET/28VqXlhduLtJCoU+MGGNw\nDthpaPKgc04XFxST2NZ2cGvsZQEfRhDzIdpIJ+M/sS03HKc9gnRTHikQYwkN\nuUw6uE8GlP53n3UbH/ybNkI39mb6p3/a11l1I0wURRwMT8gxnOHYUrYy9cbf\noG2UO917w1TQLBu4pQa7nwCZ0/1DbV2g1Nnl48Zc6je8IMNXx+9GK4qbxmAh\naF8aE3fCAPzaYu7oMOil5EPU4Xou6DGl6GVKI+oYQeJ1j0hqBVUa8jLXoDri\nYTPxZK/ojH7vthdYnagldvJ/Ipyx+msAtUfVEnqGrK0nZsrrKhCRUCUFRCu+\nGZaSCal2zHMJool84WiNowezUQ4ssNi9FsvhJ7bUFsHB8aC+lOZMGN/bK/+1\nYq+jaaauAAiJ6AV4JkYqd0xe9bur/YdyJDcvIei9BEuVRVRrhjW1cbwk2sM1\nGVsG2iYRU8q1AB2s/9h0THZTwUSnqU5LwkcdFtf33p0OYgzDJIy1MGnzb9yD\nzKKSL+ubGPsTdCXQ7ZjfCdH3WaTRQ/TsMjncXT+pgl8jGxoD+8QqyKCMuHnC\nVSpf\r\n=d005\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"08fc005a9c35a63ff9c8b4264afc232f7480ec3f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.22","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-35f44d8-1612628918941_1612628995041_0.8104212605262271","host":"s3://npm-registry-packages"}},"2.2.0-canary-3b45dc0-1612652123363":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3b45dc0-1612652123363","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3b45dc0-1612652123363","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"3404059ef81002fbb1d6690c5232bc524c515d6c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3b45dc0-1612652123363.tgz","fileCount":26,"integrity":"sha512-TottytEWT0KNt0HOy3OnG422ECn9pnyr0DdTFHkCyU7t455JC8JZUqaQ7FiwQaFEoWJ/iuKGw2oomBde1BGf0Q==","signatures":[{"sig":"MEUCIAZNWJssDbTc6/mU9UKolHvEKMnilbxIngpHRHzb4xTXAiEA0vhFl0qGczwOl0fMzCX4HGqw67QX25lr6Cv4lEi83eQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHx6fCRA9TVsSAnZWagAAV9wP/jyP70Pwu8kQrY8KEJmP\nSyBk4/EehmAHpUoCoD0VItoWcEV06s7/NekE8KYnfCd8BAqs+XxeO2Gp/2e1\nbK1ne5t1lVKCX/MR9IuSKv4HXEz8VZHi4ZsFsoRtXgIqEAhmtQ7x+zs+B1CK\nUBxS0aGemiwUYNE2NZu6cxj/DC8k75KFSguKzdIqPnvG5wsL3Gfm5hQGsdTu\nakt9vSQ7KT7oSiK+RvnU3JpOCn0m2ZXlvWioYXkIqcX0zxMXPN3ygg7I8vvC\nPtrEa5hyjZ613NhS3GnEa5SJz30pWY7r7eQlNYFRJxgkOLNUWeYDc+Jpb86D\n8geBv+sZCb+cTMbFE+MJzE21nEj+3VDQbkkhmFfr84aReFe6c34wnGqpEqn1\nMhYoa3fO/AyQ6L8IsHE0s1oi06Oh8i1HFNU6kQ5S1IFN3lCOai4BbgXw53AU\nm9QYQ0AzGRV5gyU/MSJRP/pJDU1cdy4T1lVKZcW/fcfUvOdoO1Q3fbxaKyu9\nod0bRxa3ychjDfjcKNJCBLJgN4N3bIIJUEJonpqL403WV+WLN4tH2qv/pb8d\n9G2sIJSTTaHQjwb/8grxTOdIZ0Fc9SxJ9xnEDmrD8OEpggQj0h8ae7yeUJJ0\nlK8LUeXL338Pgd1XxtBMulGM80mFLo2sJpCHqED7XNmVcVuysGv7go6z9x6W\nm0iq\r\n=y0NN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5e701f323825168e450338f18b27344b4dcd91e7","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.23","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3b45dc0-1612652123363_1612652191400_0.7734361588556271","host":"s3://npm-registry-packages"}},"2.2.0-canary-46c85f6-1613014649080":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-46c85f6-1613014649080","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-46c85f6-1613014649080","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"d32d320475a082757611bff19d8442fe1c7117a3","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-46c85f6-1613014649080.tgz","fileCount":26,"integrity":"sha512-mJAdEtAXdyjTjDTbCBOAQAvCyGTtHb7YEP9f2OXoodhmdc7ZMeP+TQ4GR4V3j/nMWaXGrUXuWXCKL37AsYuhYQ==","signatures":[{"sig":"MEQCIAxYckcygRx45zGkjR0SBdYDEXrapS0Nb1iJ9/k1jHznAiBJwCG7dKPIYjTmdPtQ/eL5buC0kwOA1nUWM8BvdowKJw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJKa/CRA9TVsSAnZWagAA7IwQAIS9P6I5xUyP9fcpVdv8\nhX+aUWxaMq0ZLG8p/xemdVgfqlFtKsSmZ+8kH4rCSHtfEqRwMSieL+8zZbXQ\n+O6yZbKFtIYDsRBXfQJWtBtBUFnqg+PWyTRrzkcM3SbHevhaNrKLeW9Yl5lf\n+altUNK0O3vEhBd3V91teMya6fsUfSUXyNGRX18sjm6CdZg4VPqHvqgBtJQJ\n6Ga2KhtyDUc/qxOlcxXjh98syM3gG6dqASwvgo4pOMVNPoYP1ch47KbeC59y\nQ+rwUVwEZ3LXR14Tapzgrv4ZjyL35WKT2y00wo+GLm+KKRIIkBGXlDFcLyQB\nvQGj/W2UtUSpUX0WFnXFneBrmqx8nap2Q4wKXVzLHljIgVotupyxY/3QmUtu\nzoTYFRIbTD19l3/CYwVeP8QISepKin6yKxh3Wjqqpg6TkwEc0u3JBr10CKYw\n07WTYL0zXuad41OmFFkW1IsRz3/vvBsD7VdRzlGsR9szrCfV+8nPTsn1rt44\nooSOkVWSpq7kSC2NUViwoKI9936JEQY9/RBfYuXqEjtvVp0d1GF9bVxmCo8w\nNxf8afcDxsXm7wjqFtBwDOb0+epC91XGI9P9oVcs5iRDPlCq4+0Qcgxmn6WN\nuoLKSQGlwQBMB4Fl5Y04lkJLsCxylDXwvVCVBOkpInHxJlxqMV8DJjTz+gW9\nmDQg\r\n=U2G6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"64ca9c94a50a0c5fdeb7e20fe947c159d633bb37","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.24","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-46c85f6-1613014649080_1613014718374_0.002803187236440019","host":"s3://npm-registry-packages"}},"2.2.0-canary-c1377eb-1613360907645":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c1377eb-1613360907645","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c1377eb-1613360907645","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"81c6ec422485ae7d7b51eec718dd4b3e1b32fa26","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c1377eb-1613360907645.tgz","fileCount":26,"integrity":"sha512-3hSWm7WZiWnVoKTgKA90DYj69ik/BcZOYLCJt4kJFYu3NXNR7neodA4zlA6ONf24WYZ6G+5JBDjjMeIzunlBBg==","signatures":[{"sig":"MEUCIQDyHXP63JyQXbqOiQDAVNYMijXUyKukB6GG+s0gsy8hcQIgeuHCloxjNM9YwLYJ4kyGjuGTjHKGJwwoRQbvFF5Q4Jw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKe9fCRA9TVsSAnZWagAAdPwP/3VysVcQp/ywUFUtAuVI\nKE6lIePP5XxzRwjK6h/7idfQUOXiv1FEMXBvYaYTJUDkGNu/IEM+5ZJnZcwH\niOMqVR+si5s7SY6Jm6Zx99cXn18s8lD6mESTQ/zcHooVAQQSFOQ5VMoTWOXR\nLsjgk1UE5Yiex1CwjkDYI7u2Pkx3qOyjY5T6fQVJ8pUBQCXiyGuNqPwCEDiD\nQ8lQSosSYXb+OOAGdsXqCeQZfU23rIuX6pRQ45HcXjYNpl/uIlEfD6EUL1kC\nMvB56VO2E/P2kfE08FQkX/QnY/APN4NUKwGs+Pqu49vW+dyOhGTYcK0vJbal\nqILl28k5WmqxugWRz0LDTZY89TXafnpr90wY8Kr9XopZOZSYKS83LmZJzP/t\n1F2MTedkmW/iryLNoN/50RP4fYzhbPsUaEyrvaeq5UFfi7BAu4AnQS5QCHC3\nFxK8EfWxOPyRQ+Ko8qfxj79H89LjatbXqRKGBKRRmIhjEF8XnfS9kV+CY5ug\nHy6Bm4rrTd7q76A0CTXIZl5kJscWxQQ7yrdTZ0U/ARR8niz5rB0EpegnzilR\n8aSfr5VKhZO1LKynoqZXNktOoL5STYKbNLIxr55PFo91ezEwt1zcDouBM2Iv\nk3tsXgi51ay2Ektqg63J1ami26uxObTLNZEYkCo+qAv86H+vbR9Srv6+NrdF\nE/tJ\r\n=Z267\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b745985e491863400279c69345ceb301b895c0ef","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.25","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c1377eb-1613360907645_1613360990938_0.4820628839044856","host":"s3://npm-registry-packages"}},"2.2.0-canary-256de64-1613791336345":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-256de64-1613791336345","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-256de64-1613791336345","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"02a1249dd613334e660c8993e73dea3f59c1b686","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-256de64-1613791336345.tgz","fileCount":26,"integrity":"sha512-5fQVU+mEjHF+i9NNp1qVzs8Un9QtRrQGGbVAeL95b3bPUxs3b017vj0teqlOPgpzcU4TGupzst2VMIhsJdYA4w==","signatures":[{"sig":"MEYCIQChN94B38L3vL/YtYc8DvQK4ULwXN49BHQ2bUevI04tPwIhAO3LYDGm9BWSuPe5K5e/y+3a7KZ637nR9kfFstY9SqWF","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMICyCRA9TVsSAnZWagAANjgQAIS5DjuUzTgNm+E/1Fbj\nAp8FAhDrLqFKzUjk7HemwdpzmwVQl/SHy9Ts54qs33kIPwsvwVjRuDTwfYd+\nNt5SmKfqveIuGF6GQJeuPi4slb2dBB5C5LtdAibCEXlGVgvWVuYb8eQk+9OG\nxTHgQURo8pG6nk66N1HnOARH7b4WFKBDYXLq+FqN28kfqlDgSgECES5TRYmF\nqQs1zCY9xAh/YJFa4AN5R6jR9sosN8eL2211kkRV//5Ih86NNQkf/w65TNWt\ntWcwYlJzT36cYydqOxj2Xo+zC4vKpNm+RDSwWalCEp1leHGjPEZ+/tgPCODl\nV+Us4P0X4lnfEPs1lqJP3QzsJocwtjDrCvKiaulNPkeZZInZSSv0mE+O/y4Z\ngQaQjstBI5EMUEeIFSNF0ukv7AsJ0vuPXJlXjmw0DV+bXrEo63WbzaTXOdQR\nyfdV6gMa+lbDy201MD7aIqbOuF4p3YpVpg1cGYJE3FIVec451LYX2k3RUBVI\nRHM2zO1fLVyh5EzVcSVGJovYcn26J52nJZPd2yin1iKss4YsVd90prowlK0X\nUS+y0skeXut1rqkNHJRHKsMLvrrnlnKNVVbq+FUvw8kb0vU/3ijZ3D3oUfBH\nhoihk4TuGKGR+vsJ0zyYkIgOfAf74OsIGqJ7/bxYExkrdmlfmfRhShIndj8Z\nf6+e\r\n=00kt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ef537afe2b552324abe0cc724c564cb0e95a3b8e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.26","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-256de64-1613791336345_1613791410309_0.024755434409500454","host":"s3://npm-registry-packages"}},"2.2.0-canary-b31ddb7-1613865691863":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-b31ddb7-1613865691863","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-b31ddb7-1613865691863","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"4fd056fa8208de5f9b52aea9c6bdb6c3dd60e04b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-b31ddb7-1613865691863.tgz","fileCount":26,"integrity":"sha512-LaZrMUfORtmxtqnmHXfpH5kIRxYlILt3mF0Q7zHjKy8W/YUh0VybqktWHQzCoOox1q+oZJPStQqbOzQU0kHCdg==","signatures":[{"sig":"MEUCIQC+jhvjrb7vf3QgR0PIBefYh2NlX6U8ePE1Esqlwc710AIgP5wloKARCvQBZMjq80oussmwGIYiCLghtST7UyqIl2o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMaMsCRA9TVsSAnZWagAAC/QP/1nQv1016DPNhDuIZwYn\nwOJoehUaNzqTVVwKqYFiSXHJhBDwelv8KFwpETebzHHEdtoybU4zzDpBHq2w\nFTxrXTEmI9guGKj8PA+uQjpUtLCInhUpoOfXk0/hkBEIIMDgkZBsG1NcOWFo\np7I9v1jyX04YMI7DlQmJV8gWPH2Mnh0xqj+fdzd7IJ3PJPMxuwTew07N4qEI\njnamExbGjndUCwrCh6vS8TCU9y0kq3+UP3Zf4Ud+xfmmS9JzZNsgRvz1FmVt\nn+VyhKHhIHTlXUZGRILlxZCvidm9C6yWdTzxicb0VMzNRnUt/WEca0+B2OQj\noaz+TvGKiWVnn9HEf8ezu+gnwKYh6BUjQdQOnJB/dE+nccSCsieBBfF4WE0r\nkuhg3UwgR4CLh1o3kjxeulixoqQjqEuq5RYGs5z/8F8kpZ0EyDUf24nUVXif\npuBPC0HcPtvHJ0GLOQxvTgUDhCl2agOB5M4Enx9BoiVAdHZwXUSUjRMcWGjE\ncHVXgZfQujLGwOA/ASL4dTeYC7LLOg0/SoLaaimLKY9lFlIHvYFjzYScPRj8\nQwK7pbW/HS5stPlZ8et9ONu/WCKtCbkg6qvaiQOWH1q3Tp41Drgdw0FKGSch\nlqnd/zFga+ONovnm6hJaL10dIXdwaU+s3BXIEreVj/XH0hGuEEbiXALVXr9i\nvPVe\r\n=wGdd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"0a1e651e36ebd1e60347fbe6ae247d47808d52dc","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.27","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-b31ddb7-1613865691863_1613865772116_0.664665735282598","host":"s3://npm-registry-packages"}},"2.2.0-canary-f26bb6c-1614045955609":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f26bb6c-1614045955609","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f26bb6c-1614045955609","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5c9c2e337b71403ce4d7053c4c876fbe502d0881","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f26bb6c-1614045955609.tgz","fileCount":26,"integrity":"sha512-xkFkzflteWWsZOyPZJ/j/vNa1RfSV65gMvb99QStTzGGXgORgEnJnyKwvnKsWeKSnlnQWWa2F9O/kZfEHs59KA==","signatures":[{"sig":"MEYCIQDQCbyGV8cR14ly38orI1Fh1bPsSjvilTaoyw2V4o3tAAIhANGFVDy25beuM2n+fj/j19Nb8vlK7Z61gq/kkbVroaYv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNGM/CRA9TVsSAnZWagAAfaQQAIgWiIcQkf0tJJ8mwb8N\nBESlgQhsvTlIl/m5PlNRTk7iEWEISoRkJHuUe3wvcAVLDIREJjuMIMjWr4M6\nBHQ0feYGtQQqKFcNxiHDcQQtBG+J2G+IfNKsV660uU6yt0EV36LPKiicVoAL\nFFC76PqbTy9EgF8ChZ6yfJo9LYBuX+sXhnn1Un/gcuNJAWIAoxLaKQBJtTPy\ndil3OYg67qjSGI7aPhSeNw0mQAXqO3xtLW2y8rdHGyxFxbWPT8KHVjaaUE1E\ndZ1IU8Hg3Y5zy6IZB/s4/QvDbG22+ap4Oyo3fClvgaqdKlAOq636/dPOfgCQ\nnQAv3ZzX9FiZ4bv6dQVAlCjKSukffF6MXLc9nMheFxjSiJZ1H0iiBm9wlqbZ\nV04Ojyi/JbudLpblwMjEa+tvOSR/uZNwohp/XTkG+qqum3IlElCZ7yPaThAR\nRTe1q77UF7of4hpP8+bScDQ+rpUBVaM3ZhtDr1jddFU+s0gy2psnC2hCk9j0\nna99eXuuskQbGOFvUqFlrxhuAgy4KCk06cvLUa1y/Q7/F+FqHrTT6zodoMW+\nMSMYvObhUVgUrVKuPhzjcfh7sL0nSSF0kRcLAvcQQ9Rhs+MONzQkoAsofnG3\n4tfV6Kdf5nrda2wH9qDtPTDsBZFmFKxCXaoOZUrbusQEm68U1jUu6H69N4ea\n1TKC\r\n=rgxt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"9ff5b42ec0652adee331e9dd1ec227dbd1ca6f7f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.28","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f26bb6c-1614045955609_1614046014822_0.45590693281033623","host":"s3://npm-registry-packages"}},"2.2.0-canary-5b778d6-1614835210295":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5b778d6-1614835210295","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5b778d6-1614835210295","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"a0ff93c1c63de0bbd88f6f8b06041b3682290be0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5b778d6-1614835210295.tgz","fileCount":26,"integrity":"sha512-QzJUiWHNpS8YP9c5i9NnRU6zS9bHtODwNtzp7MLXWOSQNwWJLPhPzg1Rny7uIizDtSXSqBpjhbUAyDy3IcJKnw==","signatures":[{"sig":"MEUCIA5V4vQEqsQVYPzzWSNVHSTycjGLJoFpXW1JMqKA0WEIAiEAl4U0cufMYZjTaYmQ1tN2FPTbevLLacrehERcqS1hjwo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQG5NCRA9TVsSAnZWagAAmRsQAJ8/4PvLZQWKyWAnTdoI\nafyVrVhPjIf92AWHY9vwIPSPDeHISTRco5enCaVBgUWxV7KAy2BePsaaLOUs\nYnJ48eijHaVg5HH9f6KO9qAAi6g+s8b1F8RiEB61vENLPYxu8Rvwd5jJdFvr\n7pNZ/TTN4G4YlX3jQgKD/BY3RcPbFjs7lYwtulnGSa5FYwuqB4gUMRN8sDFo\nQuOoCVbffBmctgvfctoMgm3DBoURY70JAKBd1ewwSCiIWDWEpnpWQaowS8si\nFJvr2ue+i04KXrDUVlFs8EHAPGz3T06rPsIcwfobQ3d12zSTSS9rrs+qQ3mD\nShM6i4GB1y588A9zk27roxRPChzxPLiZuZu0y2Vq7j6tYf/L0+B3UQTWy3Ss\n5+WGR+BNIA8s48k9wTOTgW0nDdu2rgCOswgNM/MNYQq4WOHuv+G1/SSQz0nC\nfKKS/R3cd1c/G2n7uG+41s7wMK3mn1YbLmStYptPbSwZLUjXuQq25KC+GkZv\nbYXiTjDLozW4QZkA5BtB9xjdjvPSjLjaIno8H0lXRurB+yTFPn63YTQlPJ4j\n0dXcRiRYBaUpRw+pR161eI8Ue8oCzMHVaXBxbkGIXb54GQZ+BtcizwGsxETu\nqRsGlVN84beWPpPnOmNFwzAGNvZ9xK6z6l8MFSbsSDKdzUoV6ukV2zz9PiF0\nK4rD\r\n=xwgM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"43a7b44b28e61d2ff48abfa96ea96e9c56497b85","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.29","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5b778d6-1614835210295_1614835276688_0.5219482245889566","host":"s3://npm-registry-packages"}},"2.2.0-canary-29ac99e-1615048126690":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-29ac99e-1615048126690","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-29ac99e-1615048126690","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"df004bd2f77ddd91341c8e2e2d7eef91774f8c37","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-29ac99e-1615048126690.tgz","fileCount":26,"integrity":"sha512-yrAnQCWh5zAZfuZV8eVVvHGW57GXw5aLv4XoSTSbC1A4TjXHFgUoCqhjy8AxKsSRxdGXA0Ve7kLZ8qTuK+K8cQ==","signatures":[{"sig":"MEQCICFQlV9+2/V0KviJwh5fzKYFLFTMBn+e4Ql4Hnci/OhgAiBN9HCKA8Ik/A0LtqqfxBkusRseC8UbgZtAx8/RfukBwA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQ64BCRA9TVsSAnZWagAAbN0P/iYfdBVojDUpOslzJj96\n4kRSWCxDb/lJ95j0dSn6YjT6UbdtX0FsGz27X8BvEBhK4WiJczvFUa3rJMtk\nbqKZavI845WAGMDZ7tX1nBz1rgQ2CC2+QwqB8EYKTpHcrd4AdVB/6P4JzwKg\nhX7ODD7XlqZibNekPorvaZ5IHMorimNVprvB6K2v09f7WQxiCLJtWNoDejPp\n1ZQfo0JQQMDW+ZaRI2gj9FyTC+muyjEoxzVkChXjoCJ1zN3iELD9NH3Neebm\n2F6Qt2Ffh2t4OpUihQbtuZHggROulSoTF533k+tJpuLR+7oZ9sBnUNrbQ/oK\nh0DTxIX1hXVwBBRbLSp2Q9A0pmwGgaL3tnNGLcRkgb9NVpDcJA5GIfwnHEqD\nx6RCDPgu6G6dWBzZvMJ49Itpl9Hvcdhgf7N6g+ONMYCOcJnn81YoIGAUKv6R\n/2DB8SUvYFS7d8HoyIcN2xkHQwKC6Qpy+Ug95Ri09jvfM7ZZU1m7e9st8GDN\nb7kN0sDoyVOSi8MPokQieVMdI1RsDyO1k0fXjO8Nu6+VAe3UhfzjwqTxsBD6\nm76GbrIJQ8H5cni/lUfcs1iIUxvlyos7B5rY523lrlvjEJrNzOVO2w9E+6/y\n0op3PjCuDhV0xnraHP7Fjk4YbFl7LL2wSynMd2FYt1PnzJ9asSiGmwt/2ll4\nFBDn\r\n=ahhV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3fe19061a47ada75a595b84af3f49c6858a7bbd6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.30","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-29ac99e-1615048126690_1615048193489_0.0687852821395385","host":"s3://npm-registry-packages"}},"2.2.0-canary-2513454-1615504600091":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-2513454-1615504600091","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-2513454-1615504600091","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"7168f5876ff7833d9da67b3a62566449b347011b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-2513454-1615504600091.tgz","fileCount":26,"integrity":"sha512-YIT4MjCXkpHZNZKJcj1f06TQAnkAwWeawJgyZSTZaQsyV0qtfZ4Cw1Y4Q0mhzA+7MVgZrJKnEAiW+mqIl41GHQ==","signatures":[{"sig":"MEYCIQC9AD3hEnpH3ZAmDEOS6kdzAgGvGY85dGzHv03qu3Os5gIhAJQUNQgF4+339sC3yw4kEVGSBpJ0jL+Hyww26SnvX18f","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSqUYCRA9TVsSAnZWagAA+IwQAJk9PPEQRxJfliIwel4v\n+k8aA1zmZxOavHEXfTzqgcKje2cFu8uzQ92sZEBtnByZVnVBtG6dn7moQl4O\nvyzN/jwbJiuDr8U7eIAL/jhKY2pnnpmPIETJtG0SQ4gYWnGRrH7T8mVUnc5p\noqBhbQtqdQAN0PzEYaRl5DenET6Ok5tLiJd9dz62DdJrE7kKVl35sRSVz/2w\n+nxFyZ4Hl9QwqeJWNfrcw+UjJyDZ6Nvu6BYCMHdHwiwi9AigBvlz5uUaXAiP\nWeFUZUHvehLYLrXULIM3+StalAESGOhTeGLxWQ+gjGYTxY2ftpaAomNpjtr3\n+WoXAA8qqozkB0tVHUd6KJo1jrspIzhcld4fcCNDiv8w1V2LT5AAfh0B+4qe\n/0EVOsu5LpN7K8j0wb9cY6xcMRjMie3MXV4WcdSvfNXP2mSNv4opia0tRans\nlHIeyRnFqvgT3TpPES6dzV/RwWmZFfUkLneldtr3++yxNlSKKbrPqy8cVmz2\nPjirC8eahEY4UOoDiPKgwX36UM0fvcthGw7WTolaPJFi0UFM6K7l24zDPkxU\ne1mArGoL7tTZ/IqK96qnnE8IYsmvbn47DdezIig9NUH4DZqy5j5zLEmvQniS\n/NH8DRSKILEub6560uK+pifNOJuxRZ+7oqjp6FsjdZ3z9LwGRW1uqg27522X\nTNQd\r\n=8mKX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"232deebe1b4b57c462a1448e0bf0b0c3d4dcd4bd","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-2513454-1615504600091_1615504663834_0.2330502980277518","host":"s3://npm-registry-packages"}},"2.2.0-canary-d9a038e-1615694071013":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d9a038e-1615694071013","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d9a038e-1615694071013","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eff07b11f0a7e1c143715cac0e1592271ae2b84f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d9a038e-1615694071013.tgz","fileCount":26,"integrity":"sha512-it6/jUL2Vh4U2AaORU/IFiMqj+FPJIIxnKTjFEsO+//pR0UG+o/aHdOsghVZzGrfKCFYI/juAfCyM3P2LDBGbA==","signatures":[{"sig":"MEYCIQC61JuXPI1dABMJ6lD8WZ6JTPTvpmTwe4wlIWCUqMvo7AIhAKKZIN8BkqnEPn/kuOLvnLZHXA7B/CUm4w62sUTJ4LaU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTYk4CRA9TVsSAnZWagAAYSMQAJYo13c1iGW8liYtMpHN\nBW0wiMBmNyyKV7DGWkOrabnxSpzY6EyabwiV5C9tqM5ovSJwnebHCzcnvCP7\nsKMuLni0VWqhJn/80o2VGQqT7XahgwoMyYijQBaUvC1JHIHOEMBDuByzpgh8\nnDh6EZohnqZp6CewYEqln8c4v0dHSl3OG/YFDkx0pwUhta96uZdxq9XF6qHt\nQLDIOKJGbL3rsqCLTZUZ7VOZKflILI4sbMzFnS3v3CcKdd5WAu/+fMgUgcfE\n8pTkH1ZryE8jBdUWRkM5xB+1skImBop9uk0HGH/ibjNl4LI5F5UUy21oumt/\nW4VCHIHkszV67dBgCJTDdGs1tM0IeCVBhMiLkfUVDy24aVLed6ls8w0ULCLJ\n0DX2a0geu22ZN9BXrSU6g7hgnQeeQfFpUr52nFKVX3L5rXgztSu2c8Ew6Uh2\nf9/4+VU6a36xcFS+RPXk5dWvihMBEP5Ls5TLmXaFk0a/bsgxFfWiohyJR5uS\n1HNA32LW7ido8nzaZeyK5NPzgr+9BD4EJ6Y5Dwj1RSA29JXOGUMC/nN7KUd7\n0FA3EM/xWYYiiYUh5IuIWv7bMmsJz49KwGc1d1opBBdHVWJ8V32XCAPiAadb\n7eLnM/Mr2HawycDrCD45K1tQIT4FaAdJ+g6IoedbYE5RRppUEFZIKyWyvslo\nFGB4\r\n=AFZB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"27668bee4ab19c57432eae2771fcdc33a56ac22e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.31","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d9a038e-1615694071013_1615694135843_0.4117105701281343","host":"s3://npm-registry-packages"}},"2.2.0-canary-70de224-1615752334748":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-70de224-1615752334748","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-70de224-1615752334748","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"5b7463838098bac5b9dd197723def121d31653ae","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-70de224-1615752334748.tgz","fileCount":26,"integrity":"sha512-dkT2mvg6Qv5f9ZKpeiM3i3tjTUwiVQLNglqaojqORXv3Hh4XWVWPoEdvEJU17ED5jVkwwl9GSi1Mn/2eP2UiJg==","signatures":[{"sig":"MEQCIC2vG9sVeSAGLgRe/iO/+Z9el1ksUy3mdQ5+z8XJYc4LAiAKuBz2KO7q3YGRxgO8hrAMvntO1rdpYkXT6b05SF7u5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTmzKCRA9TVsSAnZWagAABSoP/0Jxsg9t4tYAuxAupgbH\neezj1KT7AwtbOzcTeAT+zNUYu6hPStSZxdPkaatbKC03Ye/2zWYxFVwFFIk5\npO00DMg3KFJ3OzuTmAsA8QRPigaJ+GaD6fo1Zx947QSUQ+PGyocDz+LtfLs/\nWvgn2IY1DgzWi0ty89ZAxt9AQanAEt9y+5aKkfkw6PwZiGeIO4kS+fMqT5Wv\nB8nFDy74ykDZ3MiBOWjiTBR7iSF69bkwNOhbb8HEZzqDs7A39onwAF6rpHjc\nb4gdW2qweUDrkuuDoHRzRsfBpc2UpOWC2g+ThcPNZB54+1e0OWKT4D85VZwE\n7dZS+hqpdE41NzQlq4mMIZYHSqgMX7ERzgIMYyOjb5IxSj87jigyTHrtz5nn\nhIvCog2W0s7Dyr62Pqvxw13yLnr1bU8nXAVSdhCZGSu7wmY1nv79R7PZ9SaH\nVX6KgmvD/1eCr9ZGEarUjY8asu/1jkVlLh6GviFDByKR+GAJrG9uQi0BQa+F\nQ7YlsWT2+umPiAgcmaIfNOuSbua53l4An0KO5uYMC/Rtn8JYzDXleLwMaSeK\nVvBGzAH9nD0hCatfD2B/qa9gL7rNjyqMBIh+MdsuhoX6XB4E+oPbVY9fzUie\nic1Aahw1RgZLlBfEmWSQq/tM0D08STMudvEvLanjd1+ZHnymhCrUeEPI7I2w\n0PJE\r\n=WwKE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"dd47ef7d17f78b01d8d3a27eb5eea10ddb2a5039","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.32","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-70de224-1615752334748_1615752394240_0.4418848953149124","host":"s3://npm-registry-packages"}},"2.2.0-canary-8f0b3f3-1616376550832":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8f0b3f3-1616376550832","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8f0b3f3-1616376550832","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"33e111558370f504911bc53aad3983e5bb09e907","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8f0b3f3-1616376550832.tgz","fileCount":26,"integrity":"sha512-fRNev8Kw7a8tAUojf/BdpwhjuRfAOAh5B1dJEwFd8GAIsX18Llhi4f1fHF+iv2pizZI1H8+v+4qjApEyDeNqwg==","signatures":[{"sig":"MEUCIQCQ+PfB2cRbXELSMGmSm/930zMoIN7RIS/EEUVD+JFiiAIgN7jJ25UT5wK7uOOn27+t41oEhXr1z4FziMQ7XOS8puo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgV/MuCRA9TVsSAnZWagAATS0P/0gNxp9PgAPUpOPVUrah\nxXQrpZnMzbNtfPwe0HMIB35e+/DhCkfI9RavygrjVs0NGp41Yz+DqwIrV/+r\nH1oiXz8AoNmwrVubU/E0nCVHn2fsGA9+bFMUTartI0nV/KcmMIPDcFOFHUrp\nYbzoNyW4Kw0rA/kE9l13cxr6JBj0F73PVPzo78KQi0WVHxAZydkkjZGtaap+\nmb9if1puUgZI4gQdzFXq4EW7F4L7GJwSvdMC8r4ZRqBCv844Tpo6PQeRuhn/\ndTJVpTViJ6VWFyuUncjJvWcxfYp2YgmfSn48H2zdiWllvVgJfazh00vghWim\n8KLlRo2SjlxlrkbUn8mys2xopT1SjeMQCebzwEsszZear5U0VjfIdcTiFofR\nFJhdzk0KY8wW3Ie8mroWCZGrvNRrtykouDpyshaXxTbp5hDGuvLOg1VuTF2K\nLp1NczFLK5CodYdeVSWIkNoj+S024SDZqSJ7RGhY0PJecuUWYSM5yZArkMmy\nyxT4sP9tuaPryVIc1VCVs3siSIspYvLFA/MkkqTMnc8L4+1d3Q3FSqAWl12p\nfY5Ayvk1ltI8V6hiXDEjjEWufF7opd9TvvuKV2vaqWJ2CL5n+76R/VU9RV0v\nttmjZ51VaCBjeIgdVMQ+s4E7aYe1SxzW8iIMvn8B2Bac0WhlvX1ZDm+r25Ik\nOnBH\r\n=G26A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"1ea7fca72b1675e2ebd50b1f65d151da99f38b4d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.33","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8f0b3f3-1616376550832_1616376622229_0.6563767778967231","host":"s3://npm-registry-packages"}},"2.2.0-canary-a89c80d-1616643435843":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a89c80d-1616643435843","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a89c80d-1616643435843","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"80c66bdeb78968eb49a751801ad387b78b0787e5","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a89c80d-1616643435843.tgz","fileCount":26,"integrity":"sha512-9lFaPLVtYw5MX4nCd0eFxxsQtl3V6w27ZyVXVqXpxTmnT4Dfep86oyc+NKLjqKg2iyDgm55Itv8c5ibjgvZOGg==","signatures":[{"sig":"MEUCIQCdAp47pM/iu/cu4PMJmZ5BgI+B4RmWjQjPz2A4NXHyLwIgOS/9IFeIB5JkBtS8+SrcWyYcTr5xXCOe1rq/X4KAths=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXAWzCRA9TVsSAnZWagAAb5cP/jgPUd7F2pAZ2am4U7Vz\nFGiQRIPLotQ37RbThf9phTEvp60zYgH8Xe6UfMtOwe1fEO1kmZuMMQmygfrW\nHWoa2rhr4DXvD1QWE1eDqwnlz/zyKv106zQyxqDJ3XMYDwBKm1nWtOyMJqxa\nNYSV1jQu4D0lknqmzX3PZQ/+PuAq6hBa8qmOHHSI5Yyw6HFR/FQmrED7TtgQ\nskIHbfU651CuTW742Pi9J9ySoByyNfkDQeX527agxhexN8CdwSkk1bt+oZCV\nwNU8W6b12Xf7Ccb6qHaSE4xSSCsH4MtwdXnEEXKjaGbDI8Y/Myz6HjaF4Wzv\nXphx0jdxyKG0CVNAyZn9WwbC9lfki69y2hG18Vas02CZNQqX5GQK5TuM5wmC\n8xCCDJJJDkZW5wQsCMs/DZNagvRmXSRRtken8uEukHPzzqNgOEjs8gsq7H8G\n23wygvjWlqBnyUh49f69FNoeehwLoDhBiwEmwkc+6+olpZURsvdxJNF6T1xZ\nBBvu8MTtg4nJ3Ke5W7G28oCAnI2Z+JswNfZQ1fPdMzatVvFzhGhfamrw8ROn\nVqY/iqbhw5x1npmFwyIWYswlpfGTdS3Qu5zGREhDeOEJmLEKFIHPnruCmrny\ntZwLVFyJTL7wsXo27HpTg1Yh9LfIkiKw/L9AeSEVTE8IzpUPHM2HyqnXasyr\nSXF/\r\n=PMFe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5476f4b3ef105a70d01d1aea84391426a688a26d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.34","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a89c80d-1616643435843_1616643506707_0.9500461237695124","host":"s3://npm-registry-packages"}},"2.2.0-canary-c367dad-1617042142885":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c367dad-1617042142885","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c367dad-1617042142885","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"742540ad0dd7658cbf8f473560c6e24f8d07b231","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c367dad-1617042142885.tgz","fileCount":26,"integrity":"sha512-en2OK5qP+AJhd6SlNLBGGIR/+EFsEfFO8vRh+11Y3hir6pwR0LmTq/lWgScXZJAyjmtEIatdGX0Zf0DNKcY/1w==","signatures":[{"sig":"MEQCICowhRwfPutqapKDf9NCFf34rTRMYQlbouVRRiV/d8AfAiB3Z0f/j6i3PUU4CNPljk10uHEIXGSecEidHdI7L6r51w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYhspCRA9TVsSAnZWagAAUccP/A0VazzSFIlFoICRtI0Z\nmTdcICIokRMdi1d417+jofRO/r7bX5CN/Soo7u945Orvrw8JyOoz/E0FnCz0\nX6wCGpoA2jW/pgvCxwz4Oo+sIwi6SrBE3MWn2eY9BlqzxLbzohrwrQv0G8lW\nkLUZLtZj8WljycrAj9LzKBySiOXcc0S1NdZYTp8Ff7B0cVmSvpFnqi11NPLD\noo38olH2WAHbO4NKBUxCYdayqr6O7Jpb4c4KBAgNFosbP8pA7iVaQahibx5q\nUsBYN9apKWnBGj12lqPO5QbRLsl+ZIlAgZhazKoOYbmMWlxRNrEgJkRkw1oh\n1c53NCVbHZ+JkS4tStT6SqyO3lNQvVrTlnk2zlhr0o3uCQoxJQnPWFAB7E27\nzvFLzbVbxhk1hhXPsaplWVZpGpMWezw0LuVXprmGiLolRn0VjN3a1HqYePqD\n6mz2ljwca80381spcPNdGJ2n4u/6dpsE1lxP0JdXrvPh57quMD10TwpBbTB3\napmYGqxiqTnRoz2hZPoXeskBwYHmSewbFCXGA7ylGD+tH3TTi7cjlUPTCpKr\nF4jAkGPzfHCJSIhy+q1hbWGtZKnt9VuiLwk7GTD/dJO1KD2Oo8DF4qzP/9Tn\nMZCLNfoJXsPPdZL5GKXO/iO7vilQXK1IDgteeplJQLW+XcjFgvQLfSpx3oA+\nXeME\r\n=nEhh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"353ca3e311ca021d8c8d4f0e820c77be0572439c","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c367dad-1617042142885_1617042216776_0.8765920782109975","host":"s3://npm-registry-packages"}},"2.2.0-canary-eb1d297-1617481021285":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-eb1d297-1617481021285","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-eb1d297-1617481021285","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ec57570f6c5ba76d09b6b2bd0f8994d6b47aa7ce","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-eb1d297-1617481021285.tgz","fileCount":26,"integrity":"sha512-cAhN0Sc7GtzJFPZZFuT938yHmG88D7oJtu+4yl8PEX6rw2HGGflNm7UkFEM7gHMAwov7eRWePaD2E8suC4RRMA==","signatures":[{"sig":"MEYCIQDSi4QAtvEpf1AIdQblPVcZuPXRAbrmL2ylzFekmGx9bQIhAInMQaW7mWOvXIZ5JmFWKYwGYY9y9X01//8DdDkl8xHZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaM17CRA9TVsSAnZWagAAe/gP/A38mFKf673kqpqR7DjO\nY2rbsHJ5JeLnfCgZeP3L2qQj/xotZWdcpEPc/Cu/0AWUp+/+HT2AMQO7WLsP\nv9SWUxpVSIv2oWHk1QEJDUJQbaklBBcBDg8IPCGORAJGWm5ACKs9BtGhnn7M\nHKmAkQxo/fMP7QXlRsguTHMjqQrTu+Edank8roNlwmG+312IfXKdDXC5U1nk\nYmuA4/RnyA+qL/wugbUeiMZQ89g1QyZ65atcWZNRjPFP7MkwSMUDhRlVRDD9\n/B8WAZwspWnB8MYY/MtLpMU/R+5eVCjOVGAqG7WfXHNtFtVHqBWJ7dqA1IxQ\n0SV8cdUx9SKP/NSUXhpk+Ice+PbwZCGcKRgTNdxV68BTZhDwvhPp5LSRJZUf\nKr+n21gKRRasf9sNB5OL0V/RgLWU+JA09zzc1XODoRK1DSvv/Wn5R7JWeJ1r\ntXHPeK+5AQ9bSi3ry3JgOPuhVeGQ2Bgbu2Ung8ecnbXuu1BkZPv2S6T1SH15\nPFPp2Imwcp5yU3fuUsTbeAulLUT8q/B+nrI5RfXDifbRPYQGJDixgr+EvrMP\nq2PhfdsjI2fCffqGXTP9UK1zX1FGDznMHLPqsEjK8CqrV6PGnAfmLXTkRicJ\nreLV1wwPILvsz/JxxuzRoxhiIT9r5PQW4UoEJHPFW1puH1uBoVIsqQTtvjoF\ne1Gg\r\n=5/yj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"f99bb313fdf7dcd560b0316a2c3174a49f78832e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.35","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-eb1d297-1617481021285_1617481083033_0.2852778874800985","host":"s3://npm-registry-packages"}},"2.2.0-canary-ae79651-1617833650983":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-ae79651-1617833650983","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-ae79651-1617833650983","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"444a0a45c3af5ae26efe0e9a85724f56d94a27f1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-ae79651-1617833650983.tgz","fileCount":26,"integrity":"sha512-oYxkj1Iv8x6krEMNISr6U17yKCwQNwEoKXCzjKTKgPEAAVT7U5VoBtr0de7v0vE3oeF13/7Wy8pcxhtJUTI1rA==","signatures":[{"sig":"MEQCIEt/dcz2S2ec0rJdhtR/vseTc/+wvyVk3f/Mkjzx3jeYAiBgs/4ZRec4HM2R+3nbyVnfRWs+BAMyY/pSLCB/4Euecw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbi74CRA9TVsSAnZWagAAXhkQAIQTmMaYij1YCJ8rt+tj\nd7ifxXDZEvBXxSEPvnE7kQSvB6siUKwdH18jOZiJqBMRLFkPZQPzWbh2Vd+l\nho1KhTV66qjcImwIlEh0n/JI3ZXvceWtXX7cI5IhBLTeKHDQPqsm4QoUDfQR\n79lZ3OXLXDRTzse1wF56ZWwgXsyHkUrkO8Vh2nGoXdblIZ1Beecq6DyrbZKq\nSx5M1a1WCwX8SND7VjsMw5kELBlwgghdXR6G+xSYIfKTOFTEuI02cobABkOl\nmsux+5dCNRSpinbIY0tOD8K5CpJ5YV0DZ+XC+1y2qWLCEo2dKtarLdYtK2Fd\nGUORvbDXkErlM4QU7mhoUtbWbYun6ioCIx9zUy8C/pzJSUl4CZD9dEyTAxGr\nRNMuuq5wOlRRh/RTZOTciE7xl5Qp2g+fd8rxs+io9Hai9zfrjIRz/gWgT6C+\nlOJ3ZdyAsIMEO1QMppJJX7wSrD/8nmSiwUcHD0aX+FaNBAzofPfm6QeNx8Zz\nu9t0eHHNBHYsYmfrNTT4ewyGom91u7EbDH74nRuylNACS+S0jbLUY1VFaqvr\nLddfnCfXThQEGsjCazKsIg5yWGPZiFhgQC3amE+eMW8CrDGqCPp8hVOXUD46\n0p2ZhYRTkIKaMzu2q+ND4qDG29Fo/UpfmIX7WVFU4L72tUUUxVR14K6uakqC\nqzyc\r\n=h3Li\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d32e18aaa2d84d0d408d1751b157750b281e8192","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-ae79651-1617833650983_1617833720236_0.1555357538631148","host":"s3://npm-registry-packages"}},"2.2.0-canary-71f85a5-1618395738992":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-71f85a5-1618395738992","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-71f85a5-1618395738992","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"6f3791708ee182098e9c02561e033a919bac590f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-71f85a5-1618395738992.tgz","fileCount":26,"integrity":"sha512-Rlrmj7pWhAQFroA4HLEjxG1IEsnZ8Aq8KrLcXQt6jUD5xTKLYCpPzwKSZPOuSwOVM4MyTMMS87jN0gAs/1rIVg==","signatures":[{"sig":"MEYCIQDbflWW3xjATm5lPkzxNuOJCWle8ZAR5ytZ38ZKCQqhygIhAJHJ/CPQunyDjHJKV5WJh7Zw40WjhKhEKA1kogzNUAbn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdsKfCRA9TVsSAnZWagAAV8wP/ROvT1JzYLste55bQ+9u\nq8yVNFb4t2Kg2p2QZvSdTH6vgnfsvTAzyrLn2wgEf64wWWSZtPG4mulTJZIg\n94iKXJQQdNxyRCrMdeWCxOumve3BXf/ScSbigsYS8jND1KWAj7bPyzIFx2mp\nXLhY8j2vtZxtkt71as89Su6fqT3MVmYyJ1eDOiaW2Ol96Fsh+jIk+SyNRq9b\nBfYd792mOMitQdM4I61tVaqc+Ncsd9YCNRF+HSMpfe3rxhl6J0c0nxkcKsZJ\nZDiLFB1C0q6f7wnfVkg0/LFSQXhEbUkGTcTjxQ1561H/ITUx66DVhQ/lLaLq\n6WN+s8740xYwB6Blu5tau9a3AL7SeOU0uznZAiG9oH8d1fwe2ZXBhs4RwcB0\nmkdCYqKElPrsST9Pp8RFj03ihFDbRNSbes1BggOFDPJ+uXp2gneIBN73RKPM\npZUoIGeHWhde0fHMyrQzZJAtHnEubnELf29c5YEVNNZKzRGqAWH8HUKsHH6z\nAysdOkgkrOhL5pfz1zuULBYZywvIGqY4dQWZLtyXuzwb9+eg/PJcVx7zConk\nx4VH9ieDjqtNIu0Xdw/R14INGanQw5mCgvKQIcUSX35MwB40tGFt/q9Oft4+\nOPdTJtTAvojeuB+RhZ1uQ5IzgRIszh8oWlYOEHQoPXfzZNB0uSkm/YsR1iz0\nIY95\r\n=h5Xj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"736ed29ad8b3ba25494014da919735a18809f01e","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","dependencies":{"fp-ts":"^2.10.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-71f85a5-1618395738992_1618395806460_0.20830272875573552","host":"s3://npm-registry-packages"}},"2.2.0-canary-5aef52e-1618482936504":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-5aef52e-1618482936504","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-5aef52e-1618482936504","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c6c498aa98c26b7f3f3dc49d46d623bc8752ac0a","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-5aef52e-1618482936504.tgz","fileCount":26,"integrity":"sha512-GtFJbSDlEqitjhh0PXYA3BCRuMx8P7wtkKsczTaljuceSWMwlH211YjNNEYycvUM/Qmr7j5Mw57t60h7T3VE3g==","signatures":[{"sig":"MEYCIQCgapBEi4/w65geIwz6uuIlIO5dSlNdd4/QFfKCOalchgIhAIj9U+2j0wwoBRfGWZdFoEvNarHmRq+eTLEh4ZRLjsRU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgeBdDCRA9TVsSAnZWagAADIYP/RFLRVI/qubYWwFCLQ3x\n/4Goqx8NpjBvqQgpW48yt6SR7TfUt7tr0VyXqcdv86y5WV3y8EZy6ndHl1f5\nBcwQQPC3pX27hny0nk/s5yTZuz4d9/kPrAGroOAs3TmuuZY0cL8eAXocbrC2\nrB0iEroPLLdAjzwRVn8SoLV6zIEnwL8TjtC8TTIJXReqeLWa1EsrvxT2nz8n\nDEfDw/1rmdQqQY54cG5uVtc+h8O/WtV989kSiE0p65fPwXjQDwnl0JHguisB\n0yBJvxC1dR0vcEQ0hBclZV2ZFd8mzbCkNjwA/nxHyHSMq0Qc7UOPF7QOt9l+\nGrvNYwm0JJSeJehhD0L9BwjofsAERnuqF4htHvFuq80pgKAWmWmRumyaBmjb\niSLwr5joiuArU6sHQwv0OsMK7Ys4WXg3Q3twx9MaxKgijxTgNFFmyZYBmk4S\nhLLiQtgWo9elMEJfIetAde6GAXkvM/6e3cOMO3Pxkx1fTJ/mw7WeJUoLe2Fq\nYRBRoIX32ryIVURku1+e/cLvq4OntxtWMudMe7JNFdu+Ee+dZiU4ZOLbja9W\nxnqQUP6PFBRnjMDeFuevxRF7tAec+3/I3pDhV4yP0cvnmasu5xdWCqN/v0Cb\nCqcmC3QCubtz51yq/Zf4MohcWuvw3grH771WSeGP+glhemcE2BP/9gqWVq5w\nlubI\r\n=K+km\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"14d13d822418717d56aed4461998ee6002edac26","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.10.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-5aef52e-1618482936504_1618483010885_0.12691641681206334","host":"s3://npm-registry-packages"}},"2.2.0-canary-29a0468-1619119223211":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-29a0468-1619119223211","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-29a0468-1619119223211","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2c9736466054d337fe5de3bf3dded397ca5e105d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-29a0468-1619119223211.tgz","fileCount":26,"integrity":"sha512-Y2N9f41b8sAHsxJILSV7UVOjyWUHsly56OkbE9FcR/jX8aDTQdNctZkIVOFSkQinwzdC3TemTG/KuLmE1/P3/Q==","signatures":[{"sig":"MEYCIQCC4UHgpdUu/hxZ4ynQhv9W/C3GsUg5Ibt1uwgwxQzzbgIhAJAeaq1vHzzHfcndNz5ZpPRAiCTssQuHwGEflksd3RWW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggczdCRA9TVsSAnZWagAAql8P/iSaz6x8wssn7MxQOrZS\nNPfzWviZcALr8eIQaYDMkdSL7cor4PqUD7U0EqdrbDiDxfsfkHW+YJmVKqFX\nFQr4yrKu5YMrWzGsU5CNx0TSB2UIoVR5JRE5bWqpI0ZlnMU94n56odss5x3h\ncDePSfw1pR0jkxI29SnvlX0o9hccoAm45jqFzt8DeKVxAUsWqwYT19UZtc4Z\no0rS4qrh+E7AUjNj/gjpgoxlHx0KG8pZDdv1AHFntC9meUyHe51izVurKdWr\nb4lUq+Y2Qrgbh64bgXn+Aq7bz197AHJeWm6S26PywripHqXGbDodioaYkExd\njENnKbIO6DjCf+zNP16yRaXn1W7xvT2UADg+pk9sXjL0BZYgZTxAN12L9qQd\nCte6NmSP4x9/zFTSYIWJ8WbJa+iiRzlNU0Cop77FDl8SHh2NsYvZrCTT4zKF\nycHIEuH/dg4lX46LyB9BR1ZNWgEa3ohMfV5vx/dDoOOPbtOhDrMQiHJs8NZm\nF0eZcr2cfop9yCfJ8bFuNHb36R5f2RmWr6iaTi/xez+ajDwDGbNW1rgdFvSE\ndROpY5QvK1lGssuVyFgxvEXpRo4AdNw3LdZCReHLq/g9QxEpU/6Mzdf4hMgS\nnJpSLlPw0OCwYRCFW5SyizOIu0xsPcPefH5KmugqfPssF4V97Lq4uxORF4+c\nQLFC\r\n=7RtB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"5adfa8cd01123ee7f7582a7b9154114d34673fae","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.10.3"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-29a0468-1619119223211_1619119324468_0.3632313764458226","host":"s3://npm-registry-packages"}},"2.2.0-canary-d532bcc-1619146278394":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d532bcc-1619146278394","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d532bcc-1619146278394","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"31953e87c58491954ab7c33e522cff3b6be957a0","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d532bcc-1619146278394.tgz","fileCount":26,"integrity":"sha512-9ShKDVpQ1bOrnZwasM6yaPxwPByxedtE6KKn9VFg+HDrGfJfmGCLvN/KgH8l22K4a2x7sKAmLXhtahdYdkK/FQ==","signatures":[{"sig":"MEUCIQDDj/7ZKB5B6M/UIDCxbh/bBbpl/u9Bg9NcQ5f9StcDywIgSCrRKNOfCKfmxnyLDDXN0zUiCVkMnh+XHNNiDhAhcqM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggjZhCRA9TVsSAnZWagAAiRYQAJai8Bfq/pU5yiHFBue6\nvmcM+FNxBfzESksn+1OYcVznMV2U6IiCTpmtFhW23bg/UO7qUlT++K5gHdUM\n8EoKi1gWOoVsR9ES1vgSkY0Ncg/yGwoMQ6Ub67pVjD+iiUXZ3BRG5qaN3PUr\n2Y2xLqt2hgx+D7yXYCQyjCfariBaUKyNvsSoATPo2qbS36wH5YYrSR1PFlsM\nK3RdlIPgeJAXAjyqMruohtscCVYYG6r6OlTW6pKF5lp1bUjXI/SrVqqVgwks\nR7FfhKjQ+nnDh5Egr+zaNljw7BTOhn9gyF2EWcQsP8W0WYlgzM6HtY25mgsq\n45oJrD0BMGgqcJ3huaMPpcC6XQfi6CBtU1wgNCvE3K0adSvi9OCnNRDl4fX+\ncbGDT45x+aA5MEouNOSw88OhU1jNwn7w0F3sbBxlUDpXBM6myVtSgfxz9lgy\nrEAb4Oi1lzsXMet+73919D03tEPrVKMw+AdbNEs9AiI8FFmC8axV8mzJ3ao+\nYewfw9qp41uvIJUOzAHHKuDyXPimNLPnxXFXcInBK6a7dGIAK3PtqxO+cXpL\nrJHweVf7O+Dmjs/osetQxPnj2nvsy45syyXituH/7Fgc2aaQyis3TFsRBTJp\nvS7uguEDhUK+6wU29fB2yRX/FNLhQKIVUXmDReY3eilUEZv5S94qiFVsyjuH\n+ttF\r\n=P9WC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7b1394aa2efaeb1c8511c4c94beccbe92ffbb9b1","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.36","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d532bcc-1619146278394_1619146337010_0.718621344474242","host":"s3://npm-registry-packages"}},"2.2.0-canary-0c45632-1619730309288":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-0c45632-1619730309288","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-0c45632-1619730309288","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c36df51f1d505226a5afbbc4a189a8a8a9dacf0c","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-0c45632-1619730309288.tgz","fileCount":26,"integrity":"sha512-bkPiBREISc3ffk4fosV2Sr8SRaeM+dR+CgMMCDEkRoglqg3N3Y2Va9X//tk0gtMA0clJsTNwwyjxvpVa5nzLSg==","signatures":[{"sig":"MEYCIQCe2YH8dvROGx7tNIiEEeFhif6Te6rpjcavRhtAYKm7tAIhAK1VsAgOq70R/wVKk+eRhApNEEXsBs6DtD3RJNRvh2Gp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgix/PCRA9TVsSAnZWagAAMmMP/j6snXGnxin7sjRr8uub\nqaVU0Vn1pXv6FsuDI7LcUxp6iTIC2Rw3Xn70LxvqV4ToZFuN4SyIpiPqHl7T\nUMZufDCGZn7YXMQfuntrzT9t7dcMB7ujTnlXTIb5JUjYqLQ99TYyxl3Wq1AQ\nXkHmR9EjFTwq4m7epUueO/FrW+70d0Y3S6aTLIRLunzGL/QhMvivGkDtkQ7/\nRKRX60GRZDRrhunpLKEkWYb6qUneKS76Jgngj88/D37fMmgLpguHC37pbS8a\nCR5r22+Mzb0uAup6TJAlEEZw2Xb2Ylg4fM5VneXcHlW0MbUFA/mjg7xYQB98\n6HjWWO/cnVA7nvw5R2Ls8AKoEkY4zWi0F3qR21j1oE5oNZC5FkiBrrYbj4/D\n/gbASGh2ZTfN0c/FRzDzM/L+2O5uchi0lSRR5lshc16XZ/ORMwrfKRRDScUA\nws5cX2Gu7v/v0It/LJjSmuZuWVORpq0DU1aLZDELOeI+xjkHyIlFvZKpGFBv\nYwBnHwAbt8lg/loHUTCz3ws4BC9dPZfj9uG4Z1N5MyJHM5b2e2+tlF8bbglC\nWitgt2iBSOPhe/IKt7s7ZZoDyOyNzYiWcszM7ZBRyG0GHE0o9FkrtiPZX5mo\nasrXOAs4lJ/zwlf1xuPh21RNJu/vyyjtq1fgF8pMgVnNHnMtT3Y9nwE3LJhg\n8bUr\r\n=VLKe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"eebdaed3b644089b4a020979479f433100f63044","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-0c45632-1619730309288_1619730382801_0.24481055062982504","host":"s3://npm-registry-packages"}},"2.2.0-canary-36faa4f-1619801372643":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-36faa4f-1619801372643","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-36faa4f-1619801372643","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"cf453239ab919364a0d9c00de893c7d8d16b6ae4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-36faa4f-1619801372643.tgz","fileCount":26,"integrity":"sha512-Vv3mZrIv7ESKJ3hfpAEvUIIvKWNeiS6Hf2TunYsSB7Sv1XJGNSDp3yAt0V3vNR3kkniVZQQs6i6PAEaoOfPC8Q==","signatures":[{"sig":"MEUCIBvrKRAcfrwGj7VOtvovqVxs2Pit6eA6hc4IFDG9qlBZAiEAiBajHQEagK5eqNQvQ9LRbyj0slNUhIUghG7CRCbnvKM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjDVjCRA9TVsSAnZWagAAqXMP/3fBO4fNYKtXLxMJBbKU\nwgzUgVaFEvd2uyWV1uK5drbDxh5tT6cvl0Qv+av4NALpRunm5ES+99ffBY4G\nNuv1s/bUCpdTh66upO9Nb8LDwwTWA382qQSXq4q7Ab3geoJbo/QcCN/TMSql\nzXUurNHafEAIlJyVqS97z5vvePXqGCFEqKC4pHPYXXDf+pe2upyGFAMsNxQ4\nH6uK8tz1EtuOpOfq3O6mBGflTTVuQhkLmwSwEBNbDUIF8ZkQ/vJ+NUlB34pv\nGhy+KRnb8QeLuyIDLqZNsGqPHlaqsnBEuXoNhFKT0mACg355vOnW9Bea/YaP\n4Zr7TIbd5y4uXwphzCDw423lYMsHuSQXq2XwJy/A+ntVx6P1OKdbZGzwMQhI\nStjkovtTIlG3M6cidogEzogOC//+lSBdzTWyPOsRNUap3qxqU9wyNRnWSNxZ\ndG79hCA1kaPNaAHmxEsFr784SmFzMxSlPbuuzZ1sikE0RVLWGcegRASq3y/S\nyh0opaC6GVKB/2yOVqdF0O5hR5rY4ZJ842hLdNnXFyRDPmKORYOpvpspIyri\n+Mit3sHVPyecbfia6RvMv1RVTrZcgm/6KEvFURqskKjTViaQsTt/ve+omjKN\neB6vNV1IizTYv8Nusmgd+6+nvBd0J9euyLBudvRxWKG8N3A1okKaKgruTrwG\n4Gn+\r\n=6KBB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"e47ee8d1947b4b222ec37a42775b7bf3a543953d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.10.4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-36faa4f-1619801372643_1619801443062_0.9566805718332552","host":"s3://npm-registry-packages"}},"2.2.0-canary-d07768b-1620027891379":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-d07768b-1620027891379","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-d07768b-1620027891379","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"eb3b5a1a1b8040a2fcee1ec60c9e5464099cf5a2","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-d07768b-1620027891379.tgz","fileCount":26,"integrity":"sha512-Hye9DcXzpJtPFQJMiKb1rxXwbp09VhUmmQVBl0fD79F3QxsDk4vf2cVbSt7OXzsoXpWU2niN+zc6qj3lIp8TQw==","signatures":[{"sig":"MEUCIQCA/4nRul6uRp9gdaRJXdezzQx2J0eSx1VfDSfEjCNvgwIgDiKZjVv7PL+JnHHszyt0uSu5Sa8TU86DEH7s9+nOqc4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgj6o2CRA9TVsSAnZWagAA35oQAJLmI70WGV4wMU4MXljd\nZGoRumecGnBe6+6CwI3L0ud62pMXVN5MDd32/6vv3Fng/rKSDKnvcr7Qi0Al\np1SZrvpJApZyhBDq4CO0kYf/Wk1V3+qwr2od618RseQtJJU/qBAQbJbgZ313\nu7mrQKXH+UR3CWybq5vifyZdYh5PDgjrxV8duEGsNggqc/rhS5UvurMCZ+sp\n44/3zJjfqsvbYzxJ2xzV+pLrFTOXsygj2X5ZWATkbOSTTOirOvp2ZeGRV0DN\nuNSX+amIV+7h5TwgdJxaK3mLDwq94jq49NhrGxIPexJbbS8hRUi5Pkem0cvo\nQugSrS4aS3MiGNQVJKOJtQw1CWqCcntvtWIwjM/HUEB5fvWPrSrtwwHQJRXR\nrXX3S2hA8xEEm+4Zs7QojZ/S7ZXX3yPse8pgwB2LFMqLd3wVkZo3CzBgFZGI\nlKkTjO8FgdYiXHx2ebuVVZnqzqqtvY7S9D1n91i4afUJLvTMeLmYOgV/WDpz\nfNuWy4Lx0o9YORGMNUI1v7GbbqncrXJpIPwfO3fzmzDAZog0K1sQtc7Kkt/3\n6ubcBtBJxec32kob/6RdO4zmw2+Rjkw8vl4C5At/WTUxlYIWT8/+W+lanB0J\nwlGPGh6J5fg2T+dguX4M0Ol5g4QY+cCZwUg0r46CaO4d0AD5y6MPOiAmcbAn\n35Og\r\n=yyV3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"d030e0d08b326ae80ef2124e887fc373241f6e4b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.10.5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-d07768b-1620027891379_1620027958173_0.9335441414648178","host":"s3://npm-registry-packages"}},"2.2.0-canary-81f63bb-1620319295257":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-81f63bb-1620319295257","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-81f63bb-1620319295257","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"99b9a6baaf7ef6a33ae9a3e9263da2cbdb2848b8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-81f63bb-1620319295257.tgz","fileCount":26,"integrity":"sha512-EG9V+CLLE0wGhsJAnkGiTInbtF2Z5P2QUMivou2UQZLU5l31htWl2DVToApHLK39iaT8mqaWOONVZfzymp+xjg==","signatures":[{"sig":"MEYCIQC/vrwzEduPoVLIoadAlJ6DfJ2oeARWNC38MnA8XzizgQIhAJgI7wNH8xt/qmrL/FiSW/S8mfkNxHSPHkXUEA995CZA","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglBx7CRA9TVsSAnZWagAA+ooP/ifhvebgXD9vIJhUUpvb\nwQvD3J77P5IWXAk1uzFIsoB+m7l4pAUSQ2k64uA4oFBzHIahBFWIz0uqeLnS\n57VMUJv6958m8NHJ6B0rVfsV9eJcaXcDNxVyhirZRZs+8/zN4nLyQJTvOpka\nnPRgOtKUJOEhm6R6ARP2A6/4A6DZnzGcA94nBSMMaie/TBdyVTR31yKKXf1c\nKZ9xK+NT3E8oIxmf0gCwMJqFyVe7xan/Durrz+C272sHBpyHTVr+LNnne3Gb\n3fq0xAFgHHE21B6zHeizqIAgZCbSuBWBmmMOsv9Sbyi0ZgT/df4Ts+4MRGRG\nPcq5s807hqWmDzIOdamjA+SjwS8S71dvAil2At+uiPLKHSe0cDIK9x/J144W\niii8Vp0f5W6eZjVVWbuNbf7bm+FWFVxiaGtEFAzSrVT1dA9nTYav/3m1kwam\ncePTn8AvDzOH9UUTqwAq91Y8NcpxLSfLBzuarxewA7sEsSym2cqxl4RThU7W\no0qywwbvrlwHqRBL2TkuTzY2gNC+Xhg7SdgpRS4dTat1+MSU5Z+LqCy+dDUh\nMVJxxBUfO720N597eStJXFfULKDTueEAiSyhFaxM/5ShhMu3C1y79z58QKiS\nn6NG/gRcAruAUGsAiCLuw42YsUtEBUddG1NFZIJYetUBxFo+7QO13t6SHwP9\nspdp\r\n=1RUW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8e8f9174d97b129e13fd70b2868b8ed936527eab","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-81f63bb-1620319295257_1620319355032_0.28880101254911583","host":"s3://npm-registry-packages"}},"2.2.0-canary-127b16b-1620327188957":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-127b16b-1620327188957","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-127b16b-1620327188957","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"54637abbdbadcb72d76ce159b877c243c9d18c12","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-127b16b-1620327188957.tgz","fileCount":26,"integrity":"sha512-2Hm4r/h73rQi2rLwzoYGIxAmUuo0ejIB0qVCmL7KVMOapaUY/TmxfT+dIw/GBzcQQcUIYxvXOccmPxFwmT/4Ww==","signatures":[{"sig":"MEYCIQCyZLJ7Wls6pfyPLcNl/Wpu440E2fo0D30jCyECF0Q1WQIhAMaogZeNcAALNeQubPguTdaWqR3Lv8iP4t/t3w61lHOa","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglDtYCRA9TVsSAnZWagAAKQIP/3Xk6FDP7jOUgsu0NW05\nLZaTknaR+VCD0UEmLMYoE2CgS255muk9BTHms8ZjXo1wVHbM9WWIjpicH1W5\nnhYP/8K5W+9g6QyzW3RQRe+yXrqoqInlu/xF0d9E0JiQIIPSoHqkjxX6UGcW\ntNbuolILp4pmnVcKo9Pwz3FG+VgX+iMbPxZ8XItTB5b7IyN52uYnaOwDSAlY\nCAHVoELCG5NJpz+hf6RmqkkDCILCSuskolgVy6gwIAd55fT2Zoxd1vT8R25T\nUjltGWkiKb0NNTiTct+fvAtDcsHVbHHOAG1SP2fuEEcF3KHsaLxrAUAnUuHh\nDsxvMfhyBmI58UEtDhxkvEGvCQmUFTtX7OuV4HOPWiZaKM7t0saZmjarx7Zm\np0aKwqzzgDqJB68fl7eyZjR22CaU4cGdq/yI5feOco+qUFQfHpt/HRG2lLJY\nqnWqBSaBAk/2Q8b2kG1MHwWwwaC3LyOMdYQQysshqwMUVAkzPg//hVCN649+\nCHpHXHQxq3LQnWgKwir8KOmM1oMvv9p6vE72C2ZDMLjCIzq5gNL5SDq1Kql4\nbiRbj3oaoPAFfk9Hns1A4ZoF1VGQs8S5Y5AcUmrUyNAxNd2h2SHFqPz7NtWG\nGLEooaXWMT2DMow8qFdtaHAk81U/ZukP8pTDBDFN7jRIfQK7FAVr9K7VlvaV\ntnUY\r\n=olAr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"116304c70207fa75cc59667b1766de8382f9b209","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-127b16b-1620327188957_1620327255549_0.7663610532539127","host":"s3://npm-registry-packages"}},"2.2.0-canary-10a8e8f-1620412847644":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-10a8e8f-1620412847644","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-10a8e8f-1620412847644","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"2ebe74bb52a4c01bdea0fdb6569c60ad7198a0b8","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-10a8e8f-1620412847644.tgz","fileCount":26,"integrity":"sha512-GijJ79qRVpjum1H7oDbZipXq/pBZN4uVVDoCdlQb+61RrrqskgYNUxJ7/Rcg0D6wH+JqeiwCx1bvQBxRdGN2tg==","signatures":[{"sig":"MEYCIQDHuE3Zp2uoSORr5xTwXurp91T1Z9+t7IFO2RHvkfj4lQIhAJ+VDXoEgTy8GkEu+TXWmCKNde32AwmB1Wh+KoJupOBH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglYn1CRA9TVsSAnZWagAA2soP/AnegD3iDuOqSYMqSnlj\n+NaE4YhvhZca2Lr6OWKsG7Ka3vIN8b+IOdmlrtUkhDHE4pJBH/bqR88ZcbcO\n1n9W0VSL1k5xgG8nZ2btHF3xgXtqzYQHCL6At2qBv1MeNNI76cC9eGSOGWoE\njr+SBfhk9OlLASKRnaHvVUkrewGNadwjEH616U702JpFB2D5Gi7RRDIdmIRI\n7Zi5c5xlPlSK0rXTjBosMuIPph8ZvrNNBtFOEjIfER61AYHgq81WlhMEzbM/\npHHkxnoZ9IVDUC/H3rzvHlwzFk2x2VOSSSVLniTAbflYk7UnGPcvzUXxUNKW\naILcZBX3Z4oScHaNZB5KvYd4O9KzELdRHx+UU63OSKWZnkgP5b7WJE+fZftV\nTHNS6fBfwQeDVruFUcKXZv9TobX+LQFP8F4tgcbAXlWCEWzKgUtso8GrA367\nztJZem7X8MiM3/c2lT30xrzaqwNsLRJkfvN8YCaexmOtr6w00Q/oXSKwxQ1a\nGu6HHEbyLWNDzob1jC9SHNM5MXuUcq7m/WqizZvfyWaqNBPSmPYl/b48PuOk\nwH3QKcpvhEDx2oVkjt6J0Vs2pCG6O2dSnNPY04/5INbJ0n/GreHGmcdXkows\n/l8cs0kalqkUcINfpnA8b4vBe/eERmwMcW/NsWF5Zr0iE6szP1oaF3H8nkQl\n4cAR\r\n=FgOg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"7c1a1685157b66b1074b1b100443fb7f751e537b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-10a8e8f-1620412847644_1620412916453_0.9533328420995759","host":"s3://npm-registry-packages"}},"2.2.0-canary-c6e2fa4-1622413518151":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-c6e2fa4-1622413518151","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-c6e2fa4-1622413518151","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"bbb515532ca1320ec791ad6aa3a5691cc7f535d1","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-c6e2fa4-1622413518151.tgz","fileCount":26,"integrity":"sha512-8KECDztWr/kpcXE7hGA+8k6eFjXJ8HBYPrCLdT+j6bUGmbjzN8JRUgG5YrPJXd0ebUm1p3mpRRLTWwSPPMJJWw==","signatures":[{"sig":"MEQCIG0eEXNUySJxQp/FuKgIh1Yz+PPNIeDytDDrilvDtBgRAiAtj0MFDrz2guSZWuJsUA+hJX1uefyyOK+vb0YmLmbGVA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtBEOCRA9TVsSAnZWagAA7DkP/1QsLXJx/Res/NJSfWF6\ngzEyWCChYtH3pOwYXv2Kq/kd6UR7vmLtWXymtuq2KJhMfZDbgIviroLkykRI\nI4vUMRMWvxoPtQUgd4BXtHHReG9dwYOqMVjQSqWxo/ShRUEaEUTQVJf7RZLW\nWpwYXlx/YI0l6JMPjUFy+6PxAM7cbM3g07L5HRz3P/thQPJ2g8gXvBReIXF9\nqmXC0ZU9N9E6QQuGGTnyoSxnOD6Wv+0bB3Db+hTmlJSPFcXlOd8fC8xr+/r/\nL+ivSXJCG5ysikePq7aVyHVQvVkf22VD0V/fxbKI8aCAaM14YUI7jqrT46Zi\nZvn7X94lWGMHfyHUWYB5mWsDRg9khP8/UykUXazC4sDXumgoTdvCWK08q2Gp\nae/3bXgVe2DceIqgOh0g2amun69YLZDJHBBxEdL1ynjN6/RVyfKHWwTqEHnQ\nHmeUo7Gnt0Djvoi1mU3kM5E5o1hdYn4m8oR6dNocZLYlclsVsA0SyzVLQA8/\nose7Wpn1ioXFIxHSnQKzWDODcn1rRJMk9TakgomsvsXlmnmMmIbv8FyjpruI\njbeNhi7Y5mX1bS0izyv/FyadGFHN4YEc5QO3knecgMlzl+RkZJ8AwW2qdlVq\nB5koSM6PJs1ax4hZvRcZvKQsqukdifj8GltsQnq7J13RK9itcNRorbZxLE59\nDTrN\r\n=3+qA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"afc9b6306179e06f10331458305d40d4bbc7be68","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-c6e2fa4-1622413518151_1622413582066_0.8373541451817221","host":"s3://npm-registry-packages"}},"2.2.0-canary-765488a-1623104179194":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-765488a-1623104179194","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-765488a-1623104179194","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"fd0494efc8b420f04adfcdaef13e57a6cdb655dd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-765488a-1623104179194.tgz","fileCount":26,"integrity":"sha512-MCp9SklLO4/nwLSQX6jmM9qDqsC+4zHTeij8h/eSUmRrMhSJTLdNqpYlmcYaBNr6UEr0ApWiHr9OMDspIJI0Ug==","signatures":[{"sig":"MEUCIDe0ahJIt72HuB2HCv3rycy9D1b2faRApT+T4SG6DKS0AiEA8CEzyCj6DHFLeCvXa+hWuisdxgeXxaIcwLXX0wViEQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvpr1CRA9TVsSAnZWagAAM1YQAJIaO8DrXxX6iuEhOXAk\nc2c7hG7YCspLbq41JIjS1nC/C2BoxaSzKOyex41/CAdBvpuBlXBH9wJPuTGB\nVScQ1aZrvblCgrJmVjMK915tggjG1acoqLnQK1N5uUstwbMdDoKGdh7hHfBq\nJn4EssNcYKQbl0wTm/GIXx8+AVwYNUarFFzAJznZrQ2D8JQ7dfiou8FUOwlE\nLfaY3ai4WFoBE5y02kJOZh58a7BsSMDbmZS1R5Ky7/gCxBELusEoJBPP8qjF\nBaXvw9XTp63QwjZG1ta7lK5rhMb6EaRKcm17rhBIklaQSossAvOeK+lIIpae\ngnCFLEKFDcCa2nrWwTBwq0oxx/4t+jkBE5ftd6nyGAZWLLZV6EsgOQb84Fif\n9JgJVjkHOLEJA37JXJS0MIA4wt+lXXQp9FqS/eI+4N3YREuflchIgn+7rBCv\nKAaArXOtevYtb87ciGytihdlWqzV1dOEV5jZqdYwaZzj65NamaI7iKD4Ovj3\nB7rNeUn0qddhn78tD54fPSUN766IhiyN/742GTGpQ5abWY5SMz3MUz2kAors\n+ffmtBR4vpMKc6111i7vqktyTf2QQpabwrnTAWi5VuVdoaW8gp0x58xsC56N\nTZ70Mf5phq2dnbmXL3o5CA088TVDq31uf2YkAb0abxAE644olJ4BPEgy2ZmX\nKaNa\r\n=JfXp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8712f410c1ffcdfd45d236b233d5976ba4db85ed","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-765488a-1623104179194_1623104245778_0.5510431973878516","host":"s3://npm-registry-packages"}},"2.2.0-canary-f4188f1-1623190564730":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-f4188f1-1623190564730","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-f4188f1-1623190564730","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"88665bc10ae659d7c84a3d223d57bc234023a75f","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-f4188f1-1623190564730.tgz","fileCount":26,"integrity":"sha512-BNhJ0ld4hj9LCwLR9fAT0YcUtDx6Ildsj3Y8csNVzLVd/oYEk5xA372DO8lOF0K+2QsEdCNwxNJuHKh5O6TLrg==","signatures":[{"sig":"MEQCIE+0ZmSoCfueQsbnI9Wo5z7Gz/08iaAaiFFm/5W+RgCYAiBAQQzbUU77714XE1QZ5bVzIZBX9FyRyaw2thXnpXNPRg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgv+xbCRA9TVsSAnZWagAAka0P/1H/ozxLTUPSf7011UZI\nVnpQXwdRMV/52LCYwLngkipAzMrQMb1RQUL+9WGPPy8rKx8JrXJN/55zlSnz\nxu2Pnjre310HgN7fD8TTSjnH23OP4CnoP2xXK7YCbGSlrr/YYLUM3S4cZJDY\n8c0IckPL0KnrtaOlTVnP8Lxo6ggVLFfuFvQ8vwPXKTaih1VAXW3PRFbwYEq5\niJz1b1oKcPsVh4B9iWXorLQWonsRSXIQc3RtoRgPZs7qqbNjHlMj19zHCL4j\njIRxWZZPAvFhuygjc3V43yc75AJojcuiD1CjuDfvGkZE1RmFmuR+8lRlNUXJ\ngE+u2g53KGiZV5tJXFc1DWJDOA6FK0NuqfuZgN9vWBxdESYEAtW+nUS4aITn\nKaIhOzYsHAAHi/qAbiJc+pV5sfBnxuHmSVNSRG74P61Q3YUkw+zPQAo2FYly\njknHWAFIhQGSDjTZo13szRyinq0GgwCr7eQW29NcXzs0DOe2EQryJhF4vt1C\nOTc3oaxZxZ4xABuX6tMHbrSGxwLzIgUXFAKY/78RmbcdQSPPCM9XWwLvqi6U\njDu21hV4D4Qwzog3Nc783xQUDLZdnnvnRoPnWuGUD/DR0KLwKb+bf8Pj7uli\nkMmmLA1PK8DCsOkG1+uIcSpt26wYVk5WgnaZHbtJiHg7k1I0CJ05J2Gepmcl\nK6qq\r\n=turH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"33ff83e778614f4e2f07474e91fc1b2ba52ac17a","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-f4188f1-1623190564730_1623190619403_0.23581386722746056","host":"s3://npm-registry-packages"}},"2.2.0-canary-16cd6da-1623276890212":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-16cd6da-1623276890212","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-16cd6da-1623276890212","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"64411855d4181f1582f0c9cdf1f153a9434d1c09","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-16cd6da-1623276890212.tgz","fileCount":26,"integrity":"sha512-/7rH2YFiQJeiQ5u33R6+rgkFemutxVsxUzdYvg4ngBuNF+xYyZT7Aip4xI96lbao1/AmXzxP6KcIzXoWUqmbTA==","signatures":[{"sig":"MEYCIQCfq1gubDm9Eso0Bptg8pSjC89MyG5zqsqAEmEIzJNuFQIhAN6pY2g86s6SY8VIMf3LksixnpIEIbzl0HIloFtDCgC7","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgwT2TCRA9TVsSAnZWagAAJlQP/jKqj5T561qCUiOTDHm9\nLl4ZAHDnC5tQ3cdcOzUWGCvlFh8DojkJYXeOGWy4zT186DGY7FjHWF3uoZJL\nErstC69bpy9Q4dx/dTb/ZwCy/bQeVNgFttj8MoUBwxeepNPADhxgFZjTzK3r\nnFES0McrGsMTPZmcuV47NnRz6sV/es3Pk9KruZTpQfheYIQO6zQa/vDR0XYG\nYmkEykRag1D34b8yBcjImgQ55gtKxzPLxqjfXbfAR2JqFLg5UoH9jJ3aacjl\n4IYSM0ZORgS3fPgNb4ROySGh4DOZ3TPtq/vNjhpTq1ihXBI8mkb6NqRwaktr\nFIOvvlW66lv9mlI6DxzPzF6Oc3mp2tSNJhTD3vZ7JKmi2lZjsQlnCIZThCb/\nyJBfRdOg70IGd5cFJ3vkJBFUhD37gp2+y9N8ekE9J7t/pjj05SfWlpdvUkzU\nfO96HcC0hnSviHO3WaqaOWLNZ/2wbcEDy24JDz7xZfrWHqNKUNE9Rl7Lyszi\nJDyal2+V5KELivbfiGvZ+asdG/4tFyck6z5N2bvzIXhQQ1y5wkQ1a1qxaxwa\nN8hzCZ6+kcjo5MbWbVtRK4YwH2RvRkHgVV/dCoMGojWq77G+xnu6G1f1dNyE\nLdeUjonKLkhfKiq/pvquzt/DFyz20MNUXYnUjDnv+KZdgq7uyYWGDIm99HWv\nqulE\r\n=buV1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"734266450cdb7342568c69e49e23e3145ea7e80b","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-16cd6da-1623276890212_1623276947250_0.42017746881270646","host":"s3://npm-registry-packages"}},"2.2.0-canary-7e703e0-1623881824404":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7e703e0-1623881824404","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7e703e0-1623881824404","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e549309575fda875e2590892cc152ac11bd42487","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7e703e0-1623881824404.tgz","fileCount":26,"integrity":"sha512-Lm7Po/MoAVx9miFcNi/h7ML2q5qlXEZEGJBrer0B8KKUJfIOj2yDoc6OF6EyJOj3ll8C+WIoTUnsiesa3quesg==","signatures":[{"sig":"MEUCIQCGjAbku8k4B31LTwsrPDB9Jw37jDXsFpLztdWlhbPN/AIgTAw6ir3iVEH7lGFMsVmlVlV4/WE2JrPqu74wg85cJaY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgynijCRA9TVsSAnZWagAAbscQAIT+bWf3KUImVQIbKM5U\n4apgowDDrGKBVg4jATjc7NmDY/HG5yX9jRLt02s6JqfcA94wj6j7gm6I4k2h\nFPjhM5kjuaDPdrmcNpyLCKMsu8GiZe13ye7l4ImfJ+uxReKqxhrVp6tiZ9MV\nJJxP1Js6DOMOAQgnDCW02ZkMafcnfQNyBg+Xkd+z8vxH7zggjAv5pBq6YoRR\n6fgPVOsVGRKkMi6iD2Q0kdMLWtXM9Gwzo/m5HbMojZZBDUWDz5qHL4r9xfho\nEHkZDUtz3UyrIRgncK5mT70cN6AXoa0GFTxEWPRlAuJ8ySfZ8uoR2zC/y8ds\n49HrwIGaxLOwN+uTVMyqnhh2AGS5M8U7GLuDNUQhxpFrjhgTeojkEyHwE/0d\nt8EBfAgMuzXP49vhRNNYPqqeaxMNngHptexSvii8qwEaz83lx1eneFaWMW8n\nS+MxE4ufn7Pf2vsrP7Dv3cPvHZsmk6EbnmabjS9pReUy8f39dKjf518Jvzqa\nP8+JUWzRSAHmO+2DcGN3CrdpDdL4+b/APNLiM7STO5hWKJx8QZ8wlHjNzBsZ\nEwuFIGIBanYDggX6V9Cu99o+2Pk3Ege/ZZS2lz5eE/MrmQDfVymm5Sur7SST\nqK/Jm0hexdHPKNzo3w+71ptk6n7dFoa9ew2VR7dfmD6VVtq05QU1JAb3gkX/\n2aw8\r\n=HqBI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"ecd648992abe105603044d37aec323e9b6193923","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7e703e0-1623881824404_1623881891332_0.6894441651059882","host":"s3://npm-registry-packages"}},"2.2.0-canary-e4df928-1623887123897":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e4df928-1623887123897","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e4df928-1623887123897","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"0b1a4774feba752d46e73b8785584fe97b58abe4","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e4df928-1623887123897.tgz","fileCount":26,"integrity":"sha512-cL8ETmfGMYCAAy7XzWr9l4RQ/wBJhnW9N1URR+zAtgkapZsBue3736luIIRag4ZEBHlvoE3lgacN2DgiaoZvSw==","signatures":[{"sig":"MEYCIQDNsa9ZgOG/zuSDkWu0TpclkBzXDaSVX1v/oZLR2FH3wQIhAIr5fBYYnEO6wOBl6oXPlt3+3f8TlndtMlof4ssvvFet","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20381,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyo1NCRA9TVsSAnZWagAAUjIP/iKTgx6Oj5IVTctrVAq6\nPcTqb44wcuMW4w3ix28Ap1c85PuSodZQAihIWNsWiEmAhZOYkOuyYUyLnO+T\ncGH5OKMwb+62Ng4LfVeOS+2sxg78u6DvpjWqydakugN1fNq6yb0Q0tFPuoBt\nNWRD2ttw0nrii7KR3aZODtWiqIgoCCv1tfOGSpESUrnqTZgnId3Wpkb8JGS+\niv/2F6jx44NfylcO0LOzJrT81KytSx7ylCDk6TvFmi730fa2LYZbd9caAtGd\nEp8Ji0aL/9AIfM/C8zOrJlCMpzxK0o9g/kYFEn4QN6Ag4W4j/4z2FEfDndFg\nNDf1gBFmcJgeJ9kd54nxFdxduvMryG61UC2KXI4mYRe7yT5ymaLJfH8iYHT2\nl6oUtsHjwuiIRNDAUUjk/t6ucmdRHJ1XrKQdqEare1tP1PbVrnq5x1Bb8tCw\nKVVO950P6RbA0ylHeH4FUjg8rVMWiIV+JY6U/DLar3XysLbhmO6zLZXAbA7S\nDuk3L5jQONDxvIImisC6PPRAq8Jrs/u+Yl6JoChapsI6CexZPtQfA2T7GHPw\ngo1olN5+0+G5QKAfsc52b4fyi+lCAWAqNklrTILi0MR+UmOHwsnm+eujqQc5\nBlGWe2B/viGndSwkAAcAkMg/AoSp07aPkcYvJ5dzSiDsYKDgM77CZw1FLu2h\nicf+\r\n=CLGO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"dcfbc5da18d155fe63402e33b8df00be952d3f2f","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.20.37","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e4df928-1623887123897_1623887181242_0.06797390912950663","host":"s3://npm-registry-packages"}},"2.2.0-canary-25a9c6f-1623984619996":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-25a9c6f-1623984619996","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-25a9c6f-1623984619996","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"c562123427d132e3ea3044e0c1cd38748a5c827b","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-25a9c6f-1623984619996.tgz","fileCount":26,"integrity":"sha512-lFfnXs0TTXQhOxo8TeL1zUmjPOeqMwBgXIIcRIiqRZt+jQGIklQD5QUg/PWUVCCEc4St/JF2/OU+4fiNc/fHRQ==","signatures":[{"sig":"MEUCIQC15Bq2nCCd0hJkVPXFESCTfYJ1o7Be2BLkks3ftOeaHQIgcug1niSsxdO4yzBaC+mSyjj4XZ9FQ1y/hsCsDDMyWsM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzAo3CRA9TVsSAnZWagAA2cwP/iBFLl7zmtPfNVrIkdMv\nCxzBjHiOXupn2m3s4a//LdvEpSyt/AZUSKAEMl8RH/ljZMSGL9DQx5ZGjkgm\nd88equDcavjFz3iQZ7kIAN5Yfex9Gq+8Gu4QVy1DIu/+4l9ZJRSb4DaFSrai\nKHS63nooAVW0T+I69LX7gW3DBZGIcOxDID+UtmBWcphrzJCTWCpl1C4gjMN5\nZ/gQmjhYzPKtj7Z4uUjKvTlzWDntsQeEl8LwlQHtFGzWUuC2UdfCfPWLZjSw\nsKvgNsrqgBU9TeepXqoOPNutsfliBWXnMuSWokeUHyVFshOnuclAGejuQGBR\nuQL74G0nBSfUylWBm+wLUxzHzdKLYk0PuDQFyduoeHFLdHenxk5oHJputCF4\n/o9Xe5AC0UOIpD3ccFLtabuzQ8KxqCOIcvT9YDYgMc9YP2PY6VZ8EMBghYz4\nzC1/iS8DgKcb3vBJkSWuKNemNii/R45P0zE0U6i7LmfdeJVPuvWVgA/AA4po\nTv5nJCmJZB0Z8P+RCwezCzeNrmpVAlbg/J6IDFxf4kKN4h4FbC1Ul/UGBJIJ\n5SiCZDWwXY2Ct9WxZdtSnzKs8WGJhNlmkiVh/doU3ENrMdlo/BmZuzE0gSN4\n8FWph+wbYvXnZpOpShVwO/sgHmyndZqUAOO57phTjKgGiptM4rstR++QvpWf\nYRsL\r\n=PZu9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"95cdee0aec507137acd46c3bd6e098c3c02c1c2d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.0","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-25a9c6f-1623984619996_1623984695152_0.2568086110980896","host":"s3://npm-registry-packages"}},"2.2.0-canary-8fde444-1624591472307":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-8fde444-1624591472307","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-8fde444-1624591472307","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"30f25e891764d128436d9736569e53bc5403a923","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-8fde444-1624591472307.tgz","fileCount":26,"integrity":"sha512-Oi7Z3VCneoKpku+P7pVsb7XMUGlCHyROHpi4JH118+dmdm8+1lVrPvLe2YKqTNQgBrduBcLQNwDb3QyVUQjzOg==","signatures":[{"sig":"MEUCIQCc14lhi+Wh5KUTfvRaEkTfMXvL4LZ/dQguLBAdw2kmbAIgAPeAiFotsCwVIj3OwZaDwyLF4Bj8Ycg0fxkE1acURUk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg1UyrCRA9TVsSAnZWagAACJoP+QAiUtFpLVKM0FkPEgDN\nhHGNsH5lh46yeDur1+A4csRJNdk3TKFKMUbHp/sLZLffZ0v68qaGvp0YqzXo\nENYOCmeb5LlHAesoFGyLQrT5Ki6CF6Ee79UVrkFJAMl1u0aDrawnnOgg24Jg\nfh29IY2djwoQVsxr5btjt3H/8QPwyheIrUC2BskAS3Xt8dzJFkTLynRwZoA2\nR1LD40AmDRoCuTpPsict4UDi0GCfZ7Jd691acTdkhvoINVCBoNsxoyZSylT0\nrNqp9hy9URByXkPgrsNk8M4ptlyiOsLzWKIe6bVB1lmn9HVvcO2gGDj+ZjDS\n3Nuk7oZVhAY66w113GvZ0+rWseUIzS0xcvEZfu1MBurhU/HzaszINmCUEQKO\ncqRwnOvX8uMhvztTVfDIGmbakr6QcVqa/RyuC6YxpZuABdcpFn25QKKPWZfx\n43vaeZRc/MNNTjoYj1IaWG0dTWE2YiR4nxLnfwdyhqUwNspQQly8nrlvDC1h\ngVnFoyN+RqlZ1/W7MtSQdx3HM+pGDS0MTZ5fhXASSPwHXnAlxaf8xjOLv7Uf\n1aaJLk7057fSwQYClgSiOwkezi0r8KmvBdGrvJnmVxPF1zHKrtoipVD/dNxA\ntKNIm2ibe/Pv+cxfvgDkJO70hC7Bl40FrU8C9IKw7htkkw4/ELYf67BBK0+f\nADFv\r\n=NmC+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3c155672e26555a5f42de33e0ace1f0b4f6c4968","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.1","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-8fde444-1624591472307_1624591531460_0.5075007647769971","host":"s3://npm-registry-packages"}},"2.2.0-canary-a640381-1624761508981":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-a640381-1624761508981","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-a640381-1624761508981","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"be189312a376dc98ea55dffc98d9f52bb29a4db6","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-a640381-1624761508981.tgz","fileCount":26,"integrity":"sha512-EOkmQ79UeJCW5KlHfo+btvC2Q9tv9+mZQYG6j2xvRLDhKdUG+RAHazN/jwW9xvC9v9gmA65vLFiUzix51qhOUg==","signatures":[{"sig":"MEUCIQCl5owgfuFn8ic/AvUamIiFxUOXZUvmBnwcWa5pKtAHDgIgHvgmBLHVd00+QWf65k22XoIIplbO9bfvl6WLPZJh6dw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg1+TlCRA9TVsSAnZWagAAjugP/1/h1sMsRZ0hbBgXg0IO\nfK9Si5ZVKQxwJI8FIr4riWPoxQR8leyCPkotD6il8n1SsohEOJ55BGJeDAuy\nqgHE8wG4C4+KgKz5oJU7koHXgCyhWqY3W4zFl1mYmwx5udSM9krywFelbCcn\nRsQ9KD8Esf/VrOX4fL9PckD298Z6IVLqnvaNOOMcbOWddTsvZ/UX19u98oe3\nbpuDMPIcOWqzzH4mPfc8+K9XaB6op1d0vGhrCpnprJr5Ktr6hqo65iWILG8X\nMG5bMi725PZ9Xswh6lmX9+uFjzczlPvB2EtqUeF+MFJSiMsbtsjxHXfRuQI4\n4ikUBhQ81VwqiLQN5QG0SagtsOme0fPTXBmp5/zEWpXgMHYE+rroR1UGKLzT\nuwXIJv3Ou7/tLRiF3KSngf2Kwdx2K+zm4q5OaQzI+d/EXZPQM53m65can07S\n4QwFlG7qjlpIwafjXcM/N8UDMO2Yw5f/LB6WyuIJ0dKH2rZezmOMReSBlp9F\n1v7FZBvZQ9e21CHfAqtiEq9jkIkCFPtW5gE9hFRmJHmTSrotrDOn4uqzDSag\n3sezrHoc44ZdQaQObsVPYzOd/iYcza/SvYJS+a6LyFOmMJT2O7YsLwcRqSe2\nuyDeElo/15GWQ4QqYfraCd3YsRr3tSaTQmP5FBKQKyYA+8F7BJxc5TVVHw0o\nP4PH\r\n=uPFj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"095c33f250fb66de91792a1d34c7cd4e04991df5","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-a640381-1624761508981_1624761572710_0.04631717591685591","host":"s3://npm-registry-packages"}},"2.2.0-canary-7382957-1625005249074":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-7382957-1625005249074","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-7382957-1625005249074","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"122c50cb1e1e75c636e6a9e9bd9de54faf486327","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-7382957-1625005249074.tgz","fileCount":26,"integrity":"sha512-Yii+Av3YwFkDSHxF/vzokMce/4NBpnYSmK3ibqFl6bFVY10etUcthuZfHdwSi852W+RFO7S71ObVO5Z62I3C+w==","signatures":[{"sig":"MEUCIQCebPUyxr4OFLteCm4EsACuwrEhNYarpS7jZKo/NQABpAIgcSyjZr07fbOyM+MRt5toS9wobty0yWRevhKOZtim34c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg250HCRA9TVsSAnZWagAAq4sQAIc3nfnGupaRFJIZWjAD\nC45+Slaztj9Tp9BjdcvbNCTh1HjXjnjdvXT6B2qJ78A5++u6WQ8JtYuieFrX\n+q2zfdGjNvHkq2bslyNVs1/99aEFLmrCaytBtk3bazHerpj7xXZsA3oBBXEZ\nNlmPv28CJ3O05Co4b8lhe2Ol2B5EyOJP801m2r/DFhON9eTLRcInC3gEE7UR\n71tLZE/VWaX+RgMz6uHxpnhM36aMUgzTi4WQauejbTVh+7CVhgTv/YV6l7Pm\n12JPfKkvXgVtiBXQpp1S1Kzu2JDne3WouptwTZUZvRP8cyF8pJ7kiUjUCVxK\nHVafAkQgUFtnAPV/sltj7VTLxeqfx+T+8VKE5MV2eOl/cobbNCkkyPjMt+UR\nnjn9gHpgLYimMLEdJzjRjfp36wDNekUhUqsZ2e82+09A1IeQWvMP8G5UqnXc\nfNZrsimP+YDHTVpt+PLdJRvvx2NTkjpR6Ovdhp1T+8hM4q8O7mBoVpmmmdfu\nC4Vz/2IeOj55DcP/9brJlTIc0dTJq0i6Rxk9PPKOmB46li3NZ7KuoId7k1a/\nXGzkiW8GtlYVQlo1LXBFBqQRO0MkGZzrUlc8MLrVoQs5J1OZ7XdvASTFKTeg\ndKKAI/vvuIAsBYo4birrdViWznHiYPJ8myoigsUaGyVC7dgq0M3mHvUtDAaQ\nh0Q6\r\n=3c/Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"8bac02307fe12c47de9d675168835145efd1d181","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-7382957-1625005249074_1625005319058_0.6694639444386872","host":"s3://npm-registry-packages"}},"2.2.0-canary-998f404-1625442492287":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-998f404-1625442492287","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-998f404-1625442492287","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"193925214916a33f0106d06c3ae48254cc6bed62","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-998f404-1625442492287.tgz","fileCount":26,"integrity":"sha512-Q2Sc+T40NOfj68Cw89cjwKdNZ87edUrG1HVgX8GJ7xa1ILbwVMKj6oKZaH4IzuWT/DGxyxyvZJa78esqx+yP+A==","signatures":[{"sig":"MEUCIQC4fTAdI3XDVb3pfZNVxBKeHnqFuewxZEZgmg896usYuQIgB5DDw/F+V0C1tc8oAQBCcpx6hM0xI34aZccWxFjX/8w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4kkBCRA9TVsSAnZWagAAtq4P/3SlcuDKUNarmRL7VVfY\nvjT3WJM7MXuicj89nNoGar27W2aoomx67t2t6JVOGSkT7VvVIYvbMSiWpW27\nbjlqVPAwGKfRLMtS9Mtlh+nSmDuZ84IKveRqFhQlYNY/UqKgKLAVBEA6KJZ5\na5+MdLsswbfdN5nKxuudbzgmkByQaDb4PVBZxL4v4OwbYJcZ1iOrK93ExfFT\nDz6mdlIRR6VLT44MnTJYiqf//o7jaNnXtlrtOG2oiEZId9zs5ucfH5EatHHO\nuxiwaGLuxLoOEBHknku6HpfF9AyQsYY19BFaN96AppCkyNjtSVZGjcdbE9GW\nxK93d/kV9KV7EA18GTzmloYvwdJ2bNv+VjTOMnng2Zlk2OD1F3qV1fSVWYRm\nLFp/0vlZ3genGFGh+PNJRnptujLrlmARMwa+8JaStul892/dMS9lAQrm2WLI\nm2ePp8cRXbnFjWN6N3WbDvBFL0HGZ6j2j6XoYC85G4GF75yOKj50pOzVvjC0\n5CVkdnG8Z2sjHCpvvd71I3kXVMNMJH0ykv4eUMXcs9rCv8gAZj4moDbfMoaI\njVB/sD1AbJWjelVRv7eSL4EPF89q0kF+SD0P/lDhSEWOEcTYTDSpV+noe16N\nGEfClDAnuU+Oih4GNmXwb9PhoSqAW4fbIAXgKOaJ7BwuClhmkGvutF4V9xhY\nGsh1\r\n=TqsT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"65cabc6ca25ead82c7633f8272d52ee560995be9","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-998f404-1625442492287_1625442560733_0.8586123762829927","host":"s3://npm-registry-packages"}},"2.2.0-canary-24a1fef-1625946529106":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-24a1fef-1625946529106","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-24a1fef-1625946529106","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"66bbfd384bb8ba26bde840ea9645fc43b3aaff21","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-24a1fef-1625946529106.tgz","fileCount":26,"integrity":"sha512-KbXtiF08yere53cdNYMxdC2mCw68ApRkkfaHk0hF/4QbzWVBnMcA1R0te3HY4aN4X6FnMJLhDX8wHcG4Czii1A==","signatures":[{"sig":"MEQCIDmKPgWKGruMEh9SjPqQta8XIdIEF8edXohjC1MRjpnTAiAXPNw5eaczLn3QuHAVsJgOqmPk8BRTXqiSIWO4GJ1tyQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg6fnZCRA9TVsSAnZWagAAL0kP+gIrkZS9bMfloCpsJJNL\n04UcBzqh47AygNdIJOhOs8EpOtGEBhNPqxR7+M5iy3mGLl9MQx9t2gUUXLnp\n4PBG2hQC9WVXDYaIzYrijDvByldE96ol3KaxBzaytllaIhLOp7kGUZf1H/Qq\niIul5bcBrMDAGLegvdmAKgz3iLzfuWLqvCCXSIGh5wKDLOEpikEWC4VSqR2B\nDE5Xf/Jmq9BjBhyHmSeZc5MS/OMkVZ/69QSXuu29H5TbcobB2buGq0toQml4\nWIOtKHUf3WQzhZ1dDvaLfNPmanq1xU/0J4ZC8NQUV/o90t8Ag8pwPYzonb3g\nizKMeN18UfvbM62X37dvFgkNXjlJB/lvhYirDCa3fHOuipsmEF/CvYN7bYt0\nyUq4ysthcsE/K1rULRmpebXWEPb5AHURsxIFsWSbS4zWIDhrPnTr5ehNns2b\nNkxWVf81PEN/pff6LKO/iHqKtQ/o9HgBOSLc/RTYs2RSKig0Z9UcxTPEago9\nmADuCZAerp1GP5t4bCyfjt9rydoPMHlwsbEPsXE6s7L8pkZc5MbZ/nDk5F7R\nFlEgioXsqXYww/wc0HlyE7sNpClEJd71JY5yB03+PeAx8EI4ZMY0ekm3UQUd\nih3+TmCgbsTx8S97Z47kh5ScT3i3r02N1dNtsho4u6p6TOs2X874jhZpOggy\naSna\r\n=C0lD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"c714a82195ae6473717ee89aed721c939f7a8db0","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.3","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-24a1fef-1625946529106_1625946585383_0.9615573741192809","host":"s3://npm-registry-packages"}},"2.2.0-canary-76ad6c2-1626046903611":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-76ad6c2-1626046903611","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-76ad6c2-1626046903611","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"103e9bc05a9b12987c0fa732d096e90312ffec8d","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-76ad6c2-1626046903611.tgz","fileCount":26,"integrity":"sha512-cvIPlZMd4+hx+TW7LOY5jb78bWAL5J37jtzUHU9N5yTrIMXex+LYq0ZlFnwC/Djrt3Uyt2jVma7oVOG6zUUt1w==","signatures":[{"sig":"MEUCIQCPKMxWHiitZNHagaiuqiukXfxS0lMgDKYeUNOpGkk6sQIgB0WfWoJZBW0DLxuEMcU/V22Qqj5YpPbIQpRBTkiYjNw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg64H0CRA9TVsSAnZWagAAZhsQAISxewrXmzjT9D/EffEC\nAfXQRtWws0L+h8219gY+YW0/ef+v6IOKeKrle94Z54OM5EJvQQRl2q0/L8Sb\nz95wCQxu5BlmA1FCqRmoemrymW+kTGIBBcliP416QcmzE+Q+PxvNEhbCWPYn\nAQwm7p0mkExp3hRnSDm1zrdBUCMPY2Lnl6hDvqxC2WZZ+NJSyW64oqVkENgD\n2DPMMu5YluwEEgUKRtyJ8BsfrpX6X4p/JXGGFDZQXn5zXl4t80kVV4P2+NlS\nqa7cI+xgRmRgWTHMrJn92iVShaLkTuTkTasXtq8o6iupJPYo12xmnYYCm3Qw\njbpM1Hg4n6GAAhHNTAr0ACht79CyJnzoGBa5b9NhrdkWcM9lb3RolZZCaSI9\n3H2lLoOvmjJ0nHjnUcM2UabrZfau3WPiACPA/zxRUxxrvkJGIKb+5QNt1PiI\n2geE8tZyg5Z9jHYXyI7oJMqCT9cN3bujNaSait3tRCkV2LeczlldL19ld5tH\n2xa4wuIrs9hufX/vtPP85EFBgHlQhqHS1bIZQHuLSERJn3Szw68kinM7UIEG\nx3hn5OKtWTodfnCH7h9etvxyHL+ecf28D7JpHErD1mOnmzCDxjhT4Qa+0LIZ\nX5Fc3Ftx9F/Vqg5wVA02gVhogOre3H1T07nAg2+fOvCulE4fvR8dXMd6RcRc\nvHZw\r\n=DDvA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"b9c619ab43198af1821edc6897a3ca99b23de772","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-76ad6c2-1626046903611_1626046963896_0.16301979105939712","host":"s3://npm-registry-packages"}},"2.2.0-canary-1be33e7-1626053094415":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-1be33e7-1626053094415","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-1be33e7-1626053094415","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"e287a96b621d2b3152328378552406d33ebe0c90","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-1be33e7-1626053094415.tgz","fileCount":26,"integrity":"sha512-ncgxdQjEzCsWMGUK8RRVHanE4RrHSDVs6x/HASX0Dv5HNjgbF1uV3d/ElDCg0JPuEsPFGH2XUnD3D2Rul9gnpg==","signatures":[{"sig":"MEYCIQCpSZhVXDmGCDqyor+58tRFd8PGSfGP4vSaVrHGo7jO9wIhAN9vV3n++5plBosrwQrZErdFLlCaws6GmAIE0c792Xhl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg65onCRA9TVsSAnZWagAAyN8P/A07dRzTuj9ghPtZYlXe\nhpksT5JDQwBEMQKmOCQcVBze5eXgVwcC6qFnHcHMDKL1CrtaPqvxqlNVjwAC\nCu35uYCkD0h3Lu6n6d+XpWD0L9OFZzXMzuUrZXxvhAfTvLYOLV5lwrgS3GDg\nxO3Gkuj5lzdIjSY9gtbbkxbOdiTPlRAUiEX7d+sUB/PtvvERWdM0C+hlZA1U\n1PHpEh3tDffg360xWqPotAoy0ZY0mmHo4Yt+1crUL8JDvbJh8O/E2aZ7hImk\nsWVnHKEhriPdEYSJorvW/fSEe4cGUglk2RB1Qb15UkprYQtkV6IT9E+KyqXV\n/f8GFeYvgy+u8Hy2Hj2JW5KDO8Db7/JE7Yc55BvTG1TVuwz/3FtbvMZUBK6r\nySNv/Dp4yxES3mJfiY9DmGGnZhv97KxxAegHxCs1o2S4b7xD8D5BipP1Ik/l\nJRQYM24sPO1YOLmOWNknyPMtfs/31ZFMfV+oYxOYuPVAmfDWk4aOOKpbCdWz\nHm6n+me5vDanEy3jGNBOT/nT9ZZPSSmm7msDlh6ySEGqs96oZw0PlYtgKl1k\nkhB49yqULva7+/bA3uWji77drUGk9/9Cy1R3jTx1fUs0ugELoLyfJxcqk8nY\njfH9LcCfMDNVFh+p6hW7/uX53wblOaUmbreHdr1pgWCADyCsiYIGoHO3p1Om\ngY/R\r\n=URd8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"014d3c6c78eafae547e79979d42041679bfcd6f6","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.4","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-1be33e7-1626053094415_1626053159355_0.34282012995212807","host":"s3://npm-registry-packages"}},"2.2.0-canary-3a9371f-1627289711123":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-3a9371f-1627289711123","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-3a9371f-1627289711123","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"49f50d4f5669a932d8dac59703d5cd01c7c73015","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-3a9371f-1627289711123.tgz","fileCount":26,"integrity":"sha512-yJfU3UnmQGAP87zo738pmkU90Wr9n6BtI4CYLK36LpfrzzcGh9Z6+EPU2T+fCx1eIGqlXBq5FQQ/t9hgfAX3hw==","signatures":[{"sig":"MEYCIQCXRamU4sX+XeG02b6ZNrxKKMIu4a1hhUk9G+lSiYCu3AIhALKFc6dFyQUWzNxgPaPmyVQpk9dAPrbP8NnPknYIY/Kb","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20549,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/nizCRA9TVsSAnZWagAAOm8P/i4Q33KoISwufmI6cFKb\ne/hz/iC0weyXRjLfLQ1a2ObfciP4Ww1pR2wV8utHuGgN2H0hQriOh6ytTwc/\nTYB0ZqcIXHQRT4e64QWo5poFgKsrkJx2dEk0ULdZu5zPzea+o8uk0aao2/LI\nTQAa1VRtykcAEspIsKiQ/73TZoMWR3CsYfqoZ3Rx7jovMzo1ifdWhrKWpUlU\nJ/BrtJMJzcckcGAskARqaKWEF70SnN/Vbg4XX+8BV0fOwCOJNVrwjhIwRmji\nhV69E41BadnTd5AwHR40e7qt/oJcBtllD+ISx5K5hgd4IHziyIyplyIMNhd5\nrsBmNIqUYz1SYrmkrzCnxBYDI0G8+hgQT3FGYxRL28K+XQ6gJ2cJu1/kgn6Y\nQL326iOgzrcj+sQeZu2Jqf5UVyj/hBifupViPgcLLXXrw3V3m0XtygyZ+Z6r\njbz683lZlvTrTDNJlcuXXOtf60zdwTpq2v2wlksLHpCn+KBkFRrysXLE9OSy\n0Q0EmMZ4YUWid5FcfuRSPEROBb2hoZGyPbkmXSbvNqyrO34tnMOMb3sMt8zC\np+6ve+wPrK4qifYWqxBVkopzZMUsKwcM85a5qG8gHrzFfYteoBt9xXTLjDwm\nBqA9ToIzizBbv3Ss6sZdB94hB126+zKCi9gX6sbNJSTu8o7y0ZaqpLnxd6oD\ns2nK\r\n=BmwB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"db9db56883bf3f6f5a639dd640a5e7aa0865e077","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.11.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-3a9371f-1627289711123_1627289779487_0.2239219792096956","host":"s3://npm-registry-packages"}},"2.2.0-canary-e0ff522-1627470570858":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e0ff522-1627470570858","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e0ff522-1627470570858","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"ef6be30be3f40395cab31fb4d0e0d5765e9abacd","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e0ff522-1627470570858.tgz","fileCount":26,"integrity":"sha512-t/co47ogWp9c4CkgtIGzdqpU5bGUCaCSqAyz1esA+LPcAF802BXhJByAZs8rBxqsEDO1wSYSCujCYd5UVM/uaw==","signatures":[{"sig":"MEQCIDksRnLOc5I5UhnfzZaTqULPbHac2ZvonVp6kLB9HkBfAiBpHXWKsvVkchdTKMMo2swgA1lauo4wSJVjNW6bWkTO3A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20549,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhATssCRA9TVsSAnZWagAANz8P/A3abxatwi4JV0OnP+7I\ne2V1PJgZEeEWCL69bgKfHa8LfufvNiHQtBdGw1kBYZxWTYGmuHTsnN+2OgIU\nxbrLhuy/DGs/rn6fqUhJz6PtawrBmBTtvfR0ujkgPpKwlp7P4MPtMwjfM03X\n2cH5G9kn/91CMPuX+CmhV5dbQbtob3y7Nf5fIpClDDHGUqyBkdLlr9JRZM8W\nMLKXH41aAlZT3abI4C+x94xl6vsvDtI3kafyf4z3cBD7vU3z1r0F/3wScteZ\n+ZPR4wcl3MUJ5cYeIWTA1cO5wn3eENOkPmJIw3/opW50k0BfUZd1WkiS3kHA\n9o5pxUOfu2G78jJ1b0jNyDx11AjKbje0pi9TBy0r7SEriz0xI0j9X51vi7ee\n8nBXrvv6gpy0hnN3Fjt3LgJl5vL7QwclBC2rUzGP7nyooNG/39rNXTYuOq2W\nxLGFxNdfiQ100FuO4HyuYxxYjm5HKiLnfWOnE1FQtJ3/idG3yXKb6VOZU0+h\nMVKzNhEJMz4D2QJbg6xgacamIKj5ETMwHYwKQ5c97Qj/2Vbnousz2L2LBbDD\nNLdewCeI6En6gtDBTLrXnc9E/rIuZ1SJ0D/0ytRZX5C28oLh/uIeEDJOem9v\nu6kbcjhFKZiRJ9Tw8rnnbVQXIDUyj86xDpeLoZuNrITqEkoj/0mAU/6/WGVb\n2Er0\r\n=iz0G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"3cc5902013189b5aacdcb02da8dd8f6a73276a4d","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.11.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e0ff522-1627470570858_1627470636118_0.891719026991368","host":"s3://npm-registry-packages"}},"2.2.0-canary-e70bbbb-1627751535874":{"name":"@iadvize-oss/foldable-helpers","version":"2.2.0-canary-e70bbbb-1627751535874","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/foldable-helpers@2.2.0-canary-e70bbbb-1627751535874","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/foldable-helpers-library#readme","bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"dist":{"shasum":"8131c42074a7271589f47e32d84129bb8e226515","tarball":"https://registry.npmjs.org/@iadvize-oss/foldable-helpers/-/foldable-helpers-2.2.0-canary-e70bbbb-1627751535874.tgz","fileCount":26,"integrity":"sha512-5qquoVgSlHJmjN2KuzPBxSXGW6YBTsBsWujSQ0FqEVr4/aeuy9i2UDi03Lt1LuhsAVkBWEU45aq4UHNc4c8R4A==","signatures":[{"sig":"MEQCIAiCoO1HmZe981amhNiSzVJyecBSFpzJvuaAItZy39/8AiBwKJ/MJKQXFiJHJWMJ75zaMjfR7l5qJyOh0PrULvEMxw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20380,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhBYSrCRA9TVsSAnZWagAA4gkQAJ3O+TUJoDkbjVrLfrGU\n+ouNY98maQMh8HdARPVVfFoTO0A4IU+nTYcjDHZfHMChKXSZOvMGwYiYU7dy\nDw/Wcav4Ke2jdQzKZnwtL/qtnaOqHMuYcQG9NjWWgbGLw8NwKHtUHaALhGaj\nDVnhBKuJEcZT4Yxx4qRuA9GPq6+XoC7jPlIXVIEnw8USm1+YLqiKGnE0UFLS\nF+5r9wjH7kvE8QMuZlznVRDrUT7D2o0fr/8q5joRqte5POodemUZNpdbG2zV\nQnFxDMAErp6DIZS4IPs+mF6zjQKavQ4uQbv4Ai3BFUeNBTgOu+I/qLNhIBra\nau2WpMfscJW0l/VlW3f+Ha8xX7cQvfCgHGATCHk0d2BgeP1eZWdfHVn/y17n\nmGl61EVViVDzpTWdm0b/CcDhqCEmnRcguLCbq3xjmvsMN4eLSew/I1KC8plM\nZXWVLRg6dt8T2jxJLm3QWs2LlXLWAybX+uFYQ3n3JjM4Vi4LNZG4hGN+PzQU\n9JIE7gSB2sZsB//yhf4CWceSZ/DQddQ5oWzGHBqLsatdUAIJZ46mlXp0yQZi\ng7fd6wE0m4VQNfMoCkOLv9iuqmYmxrAcaiANrYHYtUSUCK/MCw4C0ITcc4ZI\nAjL4MG0rYQPJgkTVNLi8qNN0cy4Hjc7ZLvkfzTIwxXN/TyzrXp2aYGZfaOTc\nPAGV\r\n=XcaQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize-oss/foldable-helpers\n====================\n![Continuous integration](https://github.com/iadvize/foldable-helpers-library/workflows/Continuous%20integration/badge.svg)\n\n> Helpers to fold on things\n\nWhile we recommend using `@iadvize-oss/foldable-helpers` with Typescript, it can\nbe used in standard Javascript apps.\n\n# 💻 Usage \n\nFirst, install the library:\n\n```bash\nyarn add @iadvize-oss/foldable-helpers\n```\n\n[📖 Documentation](https://iadvize.github.io/foldable-helpers-library/)\n\n## Classic fold - `createFold`\n\nYou have a sum type and the type guards for each of the types. For example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a fold function to fold on `T`, use `createFold`\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFold } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFold(isA, isB, isC);\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT(\n    (tbis) => console.log('executed when t is A', { tbis }),\n    (tbis) => console.log('executed when t is B', { tbis }),\n    (tbis) => console.log('executed when t is C', { tbis }),\n  ),\n);\n```\n\n## Named fold - `createFoldObject`\n\nClassic fold is very useful but could become hard to read when we have more than\n3-4 types to fold on.\nBecause we don't have named parameters in JS/Typescript, we have to use\nsomething else.\n\nYou still have a sum type and the type guards for each of the types.\nFor example:\n\n```ts\ntype T = A | B | C;\n\nfunction isA(t: T): t is A { ... };\nfunction isB(t: T): t is B { ... };\nfunction isC(t: T): t is C { ... };\n```\n\nTo create a named fold function to fold on `T` without loosing readability,\nuse `createFoldObject`. You choose the name of each fold function by passing\nan object.\n\n```ts\nimport { pipe } from 'fp-ts/es6/pipeable';\n\nimport { createFoldObject } from '@iadvize-oss/foldable-helpers';\n\nconst foldOnT = createFoldObject({\n  onA: isA,\n  onB: isB,\n  onC: isC\n});\n\nconst t: T = ...;\n\npipe(\n  t,\n  foldOnT({\n    onA: (tbis) => console.log('executed when t is A', { tbis }),\n    onB: (tbis) => console.log('executed when t is B', { tbis }),\n    onC: (tbis) => console.log('executed when t is C', { tbis }),\n  }),\n);\n```\n\n## `and`\n\nWhen using fold you will probably encounter cases where a type is a combination\n(intersection) of different guards. To reduce the boilerplate having to write\neach combination by hand you can use the `and` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAAndB = (value: any): value is A & B =>\n    isTypeA(value) && isTypeB(value);\n\n// isTypeAAndB :: (t: any) => t is A & B\nconst isTypeAAndB = and(isTypeA, isTypeB);\n```\n\n## `or`\n\nWhen using fold you will probably encounter cases where a type is part of an\nunion of different guards. To reduce the boilerplate having to write each\ncombination by hand you can use the `or` helper.\n\n```ts\ntype A = { a: string };\ntype B = { b: number };\n\nconst isTypeA = (value: any): value is A =>\n  value != null && typeof value.a === 'string';\n\nconst isTypeB = (value: any): value is B =>\n  value != null && typeof value.b === 'number';\n\nconst oldIsTypeAOrB = (value: any): value is A | B =>\n    isTypeA(value) || isTypeB(value);\n\n// isTypeAOrB :: (t: any) => t is A | B\nconst isTypeAOrB = or(isTypeA, isTypeB);\n```\n\n## `not`\n\nWhen using createFold you **need to make sure that each guard mutually excludes\nthe others** but it can sometimes be painfull if one type depends on another,\ntherefore we let you use the `not` operator to exclude a guard\n\n```ts\ntype TypeA = { a: string };\ntype TypeB = { a: 'test' };\n\nconst isTypeA = (value: {a: unknown}): value is TypeA => typeof value.a === 'string';\nconst isTypeB = (value: TypeA): value is TypeB => value.a === 'test';\n\nconst fold = createFoldObject({\n  onTypeA: combineGuards(isTypeA, not(isTypeB)),\n  onTypeB: isTypeB,\n});\n```\n","gitHead":"280d7f7930f55e892d2ccd08cfdc12a7b1a29820","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/foldable-helpers-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Typescript helpers to fold on sum types","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","dependencies":{"fp-ts":"^2.9.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.18.0","rollup":"^2.38.0","ts-jest":"^26.4.4","typedoc":"^0.21.5","typescript":"^4.0.5","@types/jest":"^26.0.20","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","@rollup/plugin-node-resolve":"^11.1.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/foldable-helpers_2.2.0-canary-e70bbbb-1627751535874_1627751595462_0.3053505238417116","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-02-10T20:29:07.472Z","modified":"2025-10-22T09:22:11.180Z","0.0.0-canary-b8b75635c1838a7c1665453dc626a198ef7d4593":"2020-02-10T20:29:08.049Z","0.0.1-beta.0":"2020-02-10T20:33:32.089Z","0.0.1-beta.0-canary-aef513bc732481f00a8fab2d74e0f6a1534f5ab7":"2020-02-12T00:34:50.131Z","0.0.1-beta.0-canary-0b7fde013057b6b12def432d4e396331c0a23b08":"2020-02-12T00:35:15.980Z","0.0.1-beta.1":"2020-02-12T08:00:05.176Z","0.0.1-beta.1-canary-67ed471b42e0af2d26c4cb59336878d9cdabe43f":"2020-02-12T20:41:20.962Z","1.0.0":"2020-02-12T20:43:45.272Z","1.0.0-canary-db0bdb18f7263b3f8e2d4fef39bd44b5ff3648ba":"2020-02-13T17:12:29.530Z","1.0.0-canary-6468375518117c3818f0b18721d3ac02512b5637":"2020-02-13T17:12:50.107Z","1.0.0-canary-fbf447418883b5eb77046259f44a4bf4f7d74145":"2020-02-13T20:14:02.259Z","1.0.1":"2020-02-13T20:16:32.826Z","1.0.1-canary-b15cb1b0c5e55f24f18e66a2c86897cb016698bc":"2020-02-14T07:42:14.273Z","1.0.1-canary-b49bff6242e97aa24f15d0b1de3cd248a7611405":"2020-02-14T07:42:33.254Z","1.0.2":"2020-02-14T09:56:38.960Z","1.0.2-canary-d09ef09497db1309deb6fe02e1d1cea73dee4efd":"2020-02-16T05:14:47.044Z","1.0.2-canary-9d41cc2fb4eee68082c0def0a95d2b83a65000a2":"2020-02-16T05:15:18.904Z","1.0.2-canary-327b87fc8a4961b2f72f5f7849ffbc0f47ed980e":"2020-02-17T08:56:44.428Z","1.0.3":"2020-02-17T09:00:26.104Z","1.0.3-canary-81bd91e-1582100757595":"2020-02-19T08:27:13.585Z","1.0.3-canary-91942ee-1582100782242":"2020-02-19T08:27:34.403Z","1.0.4-beta.0":"2020-02-19T10:27:40.712Z","1.0.4-beta.0-canary-37990f7-1582141808574":"2020-02-19T19:51:22.963Z","1.0.4-beta.0-canary-5611e8a-1582141839470":"2020-02-19T19:51:50.287Z","1.0.4-beta.1":"2020-02-20T07:13:51.090Z","1.0.4-beta.1-canary-694302d-1582219494663":"2020-02-20T17:26:04.088Z","1.0.4-beta.1-canary-c0ae3c4-1582219516973":"2020-02-20T17:26:34.567Z","1.0.4-beta.1-canary-1bc84e3-1582234206513":"2020-02-20T21:31:14.833Z","1.0.4-beta.1-canary-1614b75-1582239093146":"2020-02-20T22:52:48.258Z","1.0.4-beta.1-canary-b56c68d-1582239130679":"2020-02-20T22:53:22.619Z","1.0.4":"2020-02-21T08:41:23.448Z","1.0.4-canary-a393f33-1582533298714":"2020-02-24T08:36:21.455Z","1.0.4-canary-46c577c-1582533404313":"2020-02-24T08:37:58.784Z","1.0.5-beta.0":"2020-02-24T08:39:20.497Z","1.0.5-beta.0-canary-4918602-1582578422422":"2020-02-24T21:08:15.677Z","1.0.5-beta.1":"2020-02-24T21:14:04.243Z","1.0.5-beta.1-canary-d81ab07-1582618395405":"2020-02-25T08:14:34.113Z","1.0.5-beta.2":"2020-02-25T08:24:46.129Z","1.0.5-beta.2-canary-5ccb1fb-1582662109793":"2020-02-25T20:23:00.172Z","1.0.5-beta.2-canary-033c634-1582662477182":"2020-02-25T20:29:13.227Z","1.0.5-beta.2-canary-665be44-1582662500778":"2020-02-25T20:29:37.165Z","1.0.5-beta.2-canary-e2d5547-1582662771238":"2020-02-25T20:34:07.754Z","1.0.5-beta.2-canary-10da221-1582663163591":"2020-02-25T20:40:49.802Z","1.0.5-beta.2-canary-da09837-1582713835321":"2020-02-26T10:45:11.643Z","1.0.5-beta.2-canary-631c20c-1582714034110":"2020-02-26T10:48:25.307Z","1.0.5-beta.2-canary-91a8621-1582716263480":"2020-02-26T11:25:31.910Z","1.0.5-beta.2-canary-3032278-1582790954544":"2020-02-27T08:10:19.101Z","1.0.5-beta.2-canary-78e8681-1582805286545":"2020-02-27T12:09:29.467Z","1.0.5-beta.2-canary-813d6fc-1582806426579":"2020-02-27T12:28:17.207Z","1.0.5-beta.2-canary-eac6866-1582806429279":"2020-02-27T12:28:28.748Z","1.0.5-beta.2-canary-a4d6502-1582806451066":"2020-02-27T12:28:45.435Z","1.0.5-beta.2-canary-4da5936-1582806719082":"2020-02-27T12:33:20.194Z","1.0.5-beta.2-canary-ff6bc27-1582806886798":"2020-02-27T12:35:58.152Z","1.0.5-beta.2-canary-408a3ac-1582832230592":"2020-02-27T19:38:18.877Z","1.0.5-beta.2-canary-ba61eff-1582866432404":"2020-02-28T05:08:44.380Z","1.0.5-beta.2-canary-8c3b0c2-1582866612780":"2020-02-28T05:11:11.238Z","1.0.5-beta.2-canary-908f2ec-1582875554986":"2020-02-28T07:40:29.068Z","1.0.5-beta.2-canary-1c3c525-1582877195028":"2020-02-28T08:07:44.352Z","1.0.5-beta.2-canary-9b876b1-1582928452729":"2020-02-28T22:22:06.626Z","1.0.5-beta.2-canary-b8922bf-1583140297230":"2020-03-02T09:13:00.033Z","1.0.5-beta.2-canary-15c0677-1583190863208":"2020-03-02T23:15:28.180Z","1.0.5-beta.2-canary-f598663-1583223418154":"2020-03-03T08:18:07.342Z","1.0.5-beta.2-canary-71bf3df-1583224262079":"2020-03-03T08:32:12.098Z","1.0.5-beta.2-canary-43877fc-1583373907356":"2020-03-05T02:06:15.562Z","1.0.5-beta.2-canary-9ed3693-1583373905185":"2020-03-05T02:06:47.072Z","1.0.5-beta.2-canary-565a7e9-1583397689607":"2020-03-05T08:42:39.102Z","1.0.5-beta.2-canary-cac29d1-1583487541788":"2020-03-06T09:40:11.227Z","1.0.5-beta.2-canary-202c16c-1583546364639":"2020-03-07T02:00:47.511Z","1.0.5-beta.2-canary-d1ab09d-1583782623241":"2020-03-09T19:38:18.213Z","1.0.5-beta.2-canary-0060be1-1584025901785":"2020-03-12T15:12:57.143Z","1.0.5-beta.2-canary-6dba21c-1584136226784":"2020-03-13T21:51:46.512Z","1.0.5-beta.2-canary-ca809ce-1584314494871":"2020-03-15T23:22:41.407Z","1.0.5-beta.2-canary-0c309ac-1584504485325":"2020-03-18T04:09:30.709Z","1.0.5-beta.2-canary-a1852b2-1584719264748":"2020-03-20T15:49:05.111Z","1.0.5-beta.2-canary-22417d2-1584719675321":"2020-03-20T15:55:47.177Z","1.0.5-beta.2-canary-3ed2737-1584831863290":"2020-03-21T23:05:38.161Z","1.0.5-beta.2-canary-2bc282b-1584852475515":"2020-03-22T04:49:00.740Z","1.0.5-beta.2-canary-de55995-1584876889520":"2020-03-22T11:36:05.355Z","1.0.5-beta.2-canary-fb10cf2-1585159376250":"2020-03-25T18:04:11.673Z","1.0.5-beta.2-canary-20acc27-1585160151291":"2020-03-25T18:17:15.437Z","1.0.5-beta.2-canary-22049bd-1585215546778":"2020-03-26T09:40:21.611Z","1.0.5-beta.2-canary-65eedf6-1585215559050":"2020-03-26T09:40:52.314Z","1.0.5-beta.2-canary-06ca790-1585217152823":"2020-03-26T10:07:18.305Z","1.0.5-beta.2-canary-f57a314-1585240398562":"2020-03-26T16:34:46.449Z","1.0.5-beta.2-canary-7e51d27-1585255190518":"2020-03-26T20:41:04.551Z","1.0.5-beta.2-canary-b50da59-1585255214091":"2020-03-26T20:41:36.378Z","1.0.5-beta.2-canary-2a1d00d-1585264443746":"2020-03-26T23:15:24.244Z","1.0.5-beta.2-canary-cf4c2aa-1585296548801":"2020-03-27T08:10:26.707Z","1.0.5-beta.2-canary-13544ef-1585510991707":"2020-03-29T19:44:30.615Z","1.0.5-beta.2-canary-f27a7fa-1585511312402":"2020-03-29T19:49:42.776Z","1.0.5-beta.2-canary-38a6c8a-1585560814723":"2020-03-30T09:34:52.105Z","1.0.5-beta.2-canary-d07ec44-1585565607459":"2020-03-30T10:54:46.701Z","1.0.5-beta.2-canary-abd454d-1585824420627":"2020-04-02T10:48:22.087Z","1.0.5-beta.2-canary-20548f7-1585824456055":"2020-04-02T10:48:49.254Z","1.0.5-beta.2-canary-258da2a-1585828153485":"2020-04-02T11:50:33.037Z","1.0.5-beta.2-canary-a3bbe97-1585847743237":"2020-04-02T17:17:06.701Z","1.0.5-beta.2-canary-622d3b8-1585903929967":"2020-04-03T08:53:27.651Z","1.0.5-beta.2-canary-7d053e3-1585926920262":"2020-04-03T15:16:49.683Z","1.0.5-beta.2-canary-fd0400c-1585947752457":"2020-04-03T21:03:49.839Z","1.0.5-beta.2-canary-fd0400c-1585947758261":"2020-04-03T21:03:57.018Z","1.0.5-beta.2-canary-71c560a-1586141191227":"2020-04-06T02:51:15.777Z","1.0.5-beta.2-canary-f99bd31-1586161660329":"2020-04-06T08:40:12.742Z","1.0.5-beta.2-canary-a0c87dd-1586288335850":"2020-04-07T19:40:16.399Z","1.0.5-beta.2-canary-8c3a4f4-1586358319419":"2020-04-08T15:06:45.157Z","1.0.5-beta.2-canary-18353c0-1586359928782":"2020-04-08T15:33:29.257Z","1.0.5-beta.2-canary-0ce0140-1586657527134":"2020-04-12T02:13:22.694Z","1.0.5-beta.2-canary-b28dad5-1586658058251":"2020-04-12T02:22:05.817Z","1.0.5-beta.2-canary-1370da8-1586714237205":"2020-04-12T17:58:35.367Z","1.0.5-beta.2-canary-e4ae4b8-1586727912181":"2020-04-12T21:46:27.806Z","1.0.5-beta.2-canary-03f8a47-1587117925886":"2020-04-17T10:07:22.869Z","1.0.5-beta.2-canary-57a252d-1587304604912":"2020-04-19T13:58:15.634Z","1.0.5-beta.2-canary-b92bff9-1587305609676":"2020-04-19T14:14:50.717Z","1.0.5-beta.2-canary-b644acd-1587334257212":"2020-04-19T22:12:42.264Z","1.0.5-beta.2-canary-0ef4d7d-1587335275206":"2020-04-19T22:29:05.314Z","1.0.5-beta.2-canary-551ed8b-1587499091290":"2020-04-21T19:59:28.297Z","1.0.5-beta.2-canary-45b3896-1587502641849":"2020-04-21T20:58:37.167Z","1.0.5-beta.2-canary-a5c42b5-1587582512965":"2020-04-22T19:09:56.348Z","1.0.5-beta.2-canary-89f5183-1587879169541":"2020-04-26T05:34:04.514Z","1.0.5-beta.2-canary-3071526-1587921375286":"2020-04-26T17:17:27.572Z","1.0.5-beta.2-canary-499eb5f-1587949978182":"2020-04-27T01:14:17.083Z","1.0.5-beta.2-canary-4701cb2-1588019545936":"2020-04-27T20:33:50.933Z","1.0.5-beta.2-canary-158d3b7-1588103616078":"2020-04-28T19:54:57.640Z","1.0.5-beta.2-canary-636546b-1588104551336":"2020-04-28T20:10:27.160Z","1.0.5-beta.2-canary-993f6b0-1588166144699":"2020-04-29T13:17:06.011Z","1.0.5-beta.2-canary-0745690-1588168158764":"2020-04-29T13:50:38.445Z","1.0.5-beta.2-canary-a79e1f3-1588186871146":"2020-04-29T19:02:53.287Z","1.0.5-beta.2-canary-f5c6b90-1588187508003":"2020-04-29T19:13:04.932Z","1.0.5-beta.2-canary-d07c5ae-1588188712635":"2020-04-29T19:33:05.211Z","1.0.5-beta.2-canary-9f154c9-1588191427373":"2020-04-29T20:18:30.239Z","1.0.5-beta.2-canary-3de0e47-1588199358898":"2020-04-29T22:30:34.304Z","1.0.5-beta.2-canary-c866fb3-1588273269619":"2020-04-30T19:02:36.478Z","1.0.5-beta.2-canary-5d419d0-1588285226250":"2020-04-30T22:21:42.370Z","1.0.5-beta.2-canary-2d14a03-1588407908612":"2020-05-02T08:26:25.786Z","1.0.5-beta.2-canary-9579a72-1588629511435":"2020-05-04T21:59:50.054Z","1.0.5-beta.2-canary-8f35144-1588689904843":"2020-05-05T14:46:25.823Z","1.0.5-beta.2-canary-edfe6a5-1588722130828":"2020-05-05T23:43:37.387Z","1.0.5-beta.2-canary-915c5fd-1588756377129":"2020-05-06T09:14:24.964Z","1.0.5-beta.2-canary-cc637ab-1588769963663":"2020-05-06T13:00:43.194Z","1.0.5-beta.2-canary-dbbb825-1588831937318":"2020-05-07T06:13:40.648Z","1.0.5-beta.2-canary-89810ee-1588853070676":"2020-05-07T12:05:42.900Z","1.0.5-beta.2-canary-b53817c-1589014737025":"2020-05-09T09:00:04.117Z","1.0.5-beta.2-canary-0bbbfab-1589108638680":"2020-05-10T11:05:21.569Z","1.0.5-beta.2-canary-9e2a9a9-1589199762525":"2020-05-11T12:24:04.206Z","1.0.5-beta.2-canary-d429b78-1589207038522":"2020-05-11T14:25:20.886Z","1.0.5-beta.2-canary-a95477d-1589307139620":"2020-05-12T18:13:41.530Z","1.0.5-beta.2-canary-4cb6560-1589311738827":"2020-05-12T19:30:18.901Z","1.0.5-beta.2-canary-1a1fde6-1589320775026":"2020-05-12T22:00:48.785Z","1.0.5-beta.2-canary-326937b-1589350237906":"2020-05-13T06:11:53.326Z","1.0.5-beta.2-canary-a4aee9c-1589352376286":"2020-05-13T06:47:21.152Z","1.0.5-beta.2-canary-6ec4e83-1589352655220":"2020-05-13T06:51:56.990Z","1.0.5-beta.2-canary-12b4d2a-1589396248595":"2020-05-13T18:58:45.061Z","1.0.5-beta.2-canary-b46e8e9-1589411464927":"2020-05-13T23:12:15.095Z","1.0.5-beta.2-canary-a6e911c-1589485887209":"2020-05-14T19:52:45.841Z","1.0.5-beta.2-canary-3e0ffb2-1589523577762":"2020-05-15T06:20:50.902Z","1.0.5-beta.2-canary-d25271e-1589687931970":"2020-05-17T04:00:05.177Z","1.0.5-beta.2-canary-815c321-1589840893522":"2020-05-18T22:29:33.890Z","1.0.5-beta.2-canary-6007f70-1589844491862":"2020-05-18T23:29:32.762Z","1.0.5-beta.2-canary-233e11b-1589870298937":"2020-05-19T06:39:24.866Z","1.0.5-beta.2-canary-6e69371-1589924353343":"2020-05-19T21:40:33.530Z","1.0.5-beta.2-canary-c2577a3-1589956028157":"2020-05-20T06:28:13.974Z","1.0.5-beta.2-canary-4ab6771-1589958928113":"2020-05-20T07:16:29.156Z","1.0.5-beta.2-canary-f0685c4-1589998015622":"2020-05-20T18:08:21.721Z","1.0.5-beta.2-canary-b1ad45f-1589998172622":"2020-05-20T18:10:32.236Z","1.0.5-beta.2-canary-7ad7516-1590059711971":"2020-05-21T11:16:17.343Z","1.0.5-beta.2-canary-8ad21b8-1590128180921":"2020-05-22T06:17:43.170Z","1.0.5-beta.2-canary-4edcf0e-1590214094022":"2020-05-23T06:09:15.635Z","1.0.5-beta.2-canary-3f65a9d-1590228758815":"2020-05-23T10:13:49.874Z","1.0.5-beta.2-canary-9e48ca8-1590233006234":"2020-05-23T11:24:32.638Z","1.0.5-beta.2-canary-8e6c45d-1590302766098":"2020-05-24T06:47:15.461Z","1.0.5-beta.2-canary-6594d5f-1590359171584":"2020-05-24T22:27:13.976Z","1.0.5-beta.2-canary-c5557b8-1590530828017":"2020-05-26T22:08:05.736Z","1.0.5-beta.2-canary-bbf25c1-1590531607057":"2020-05-26T22:21:22.424Z","1.0.5-beta.2-canary-a4fe5e2-1590585435360":"2020-05-27T13:18:24.736Z","1.0.5-beta.2-canary-c597184-1590611557015":"2020-05-27T20:33:36.878Z","1.0.5-beta.2-canary-21d62a5-1590623145112":"2020-05-27T23:46:51.018Z","1.0.5-beta.2-canary-640d168-1590624206671":"2020-05-28T00:04:56.664Z","1.0.5-beta.2-canary-e8a4bf2-1590646985820":"2020-05-28T06:24:12.185Z","1.0.5-beta.2-canary-f019103-1590870386373":"2020-05-30T20:27:36.256Z","1.0.5-beta.2-canary-768032f-1590871295630":"2020-05-30T20:42:34.392Z","1.0.5-beta.2-canary-82ac238-1590900361556":"2020-05-31T04:47:12.721Z","1.0.5-beta.2-canary-080a0a6-1591132013942":"2020-06-02T21:08:18.743Z","1.0.5-beta.2-canary-6ad4d6d-1591215224235":"2020-06-03T20:14:51.420Z","1.0.5-beta.2-canary-a69b7ff-1591251306699":"2020-06-04T06:16:26.564Z","1.0.5-beta.2-canary-7bf0eeb-1591304634904":"2020-06-04T21:05:15.768Z","1.0.5-beta.2-canary-2f5f22c-1591569594163":"2020-06-07T22:40:53.830Z","1.0.5-beta.2-canary-1a0c653-1591657432696":"2020-06-08T23:04:53.665Z","1.0.5-beta.2-canary-24104a6-1591741307343":"2020-06-09T22:22:56.371Z","1.0.5-beta.2-canary-7fe4cb4-1591827987591":"2020-06-10T22:27:32.036Z","1.0.5-beta.2-canary-7dddfab-1591914034446":"2020-06-11T22:21:41.528Z","1.0.5-beta.2-canary-17da0a1-1592176135470":"2020-06-14T23:10:06.158Z","1.0.5-beta.2-canary-8d61cdf-1592347002946":"2020-06-16T22:37:56.360Z","1.0.5-beta.2-canary-be0679a-1592430793046":"2020-06-17T21:54:54.134Z","1.0.5-beta.2-canary-5b767ac-1592678297787":"2020-06-20T18:39:23.223Z","1.0.5-beta.2-canary-9000b08-1592678417059":"2020-06-20T18:41:39.459Z","1.0.5":"2020-06-20T18:43:35.680Z","1.0.5-canary-32e20ac-1592861509158":"2020-06-22T21:32:46.905Z","1.0.5-canary-4636fcb-1592863621775":"2020-06-22T22:08:01.110Z","1.0.5-canary-b78ac30-1592883534968":"2020-06-23T03:40:02.213Z","1.0.5-canary-de0b6e5-1592963549632":"2020-06-24T01:53:18.503Z","1.0.5-canary-25e7cc9-1593010379951":"2020-06-24T14:54:03.589Z","1.0.5-canary-350c961-1593010402121":"2020-06-24T14:54:24.666Z","1.0.5-canary-c09e3a0-1593010533835":"2020-06-24T14:56:34.847Z","1.0.5-canary-d660af3-1593010765828":"2020-06-24T15:00:38.070Z","1.0.5-canary-909a7e0-1593011381761":"2020-06-24T15:10:52.491Z","1.0.5-canary-ea65594-1593012850440":"2020-06-24T15:35:11.826Z","1.0.5-canary-6a55326-1593018323507":"2020-06-24T17:06:23.034Z","1.0.5-canary-c38878b-1593019709613":"2020-06-24T17:29:44.076Z","1.0.5-canary-4d8e14c-1593025324104":"2020-06-24T19:03:08.584Z","1.0.5-canary-59f9161-1593065385094":"2020-06-25T06:11:05.099Z","1.0.5-canary-63e3f39-1593065501640":"2020-06-25T06:14:31.882Z","2.0.0":"2020-06-25T08:27:45.092Z","2.0.0-canary-79940dd-1593192408613":"2020-06-26T17:27:55.194Z","2.0.0-canary-dfb1e38-1593200912080":"2020-06-26T19:49:38.968Z","2.0.0-canary-ff6a964-1593348284068":"2020-06-28T12:45:45.514Z","2.0.0-canary-ea9a968-1593348545287":"2020-06-28T12:50:10.924Z","2.0.0-canary-0aa2a29-1593348661611":"2020-06-28T12:52:26.196Z","2.0.0-canary-4d5125c-1593394293929":"2020-06-29T01:34:34.627Z","2.0.0-canary-93406bc-1593425572458":"2020-06-29T10:13:58.210Z","2.0.0-canary-ac29b7d-1593434181624":"2020-06-29T12:37:15.652Z","2.0.0-canary-e1d50e7-1593434776199":"2020-06-29T12:47:29.426Z","2.0.0-canary-af5fb3e-1593555230575":"2020-06-30T22:14:52.449Z","2.0.0-canary-eb437fa-1593586852128":"2020-07-01T07:01:56.551Z","2.0.0-canary-620da2b-1593636940777":"2020-07-01T20:56:39.456Z","2.0.0-canary-36f73c9-1593664103503":"2020-07-02T04:29:49.485Z","2.0.0-canary-6b549fc-1593808118630":"2020-07-03T20:29:54.558Z","2.0.0-canary-b44228d-1593927745558":"2020-07-05T05:43:27.810Z","2.0.0-canary-b793f98-1594019130179":"2020-07-06T07:06:31.245Z","2.1.0":"2020-07-06T12:59:03.889Z","2.1.0-canary-c882586-1594080079649":"2020-07-07T00:02:25.428Z","2.1.0-canary-b9ec059-1594084903067":"2020-07-07T01:22:49.743Z","2.1.0-canary-27f1211-1594159848912":"2020-07-07T22:11:52.757Z","2.1.0-canary-560d47f-1594165432995":"2020-07-07T23:44:43.411Z","2.1.0-canary-56f9ce0-1594188141427":"2020-07-08T06:03:20.060Z","2.1.0-canary-9fd73eb-1594587716004":"2020-07-12T21:03:05.598Z","2.1.0-canary-e1a94e6-1594587866926":"2020-07-12T21:05:32.612Z","2.1.0-canary-35d3d2a-1594594042023":"2020-07-12T22:48:46.610Z","2.1.0-canary-240087c-1594664264571":"2020-07-13T18:18:54.663Z","2.1.0-canary-8670835-1594695343831":"2020-07-14T02:56:53.420Z","2.1.0-canary-2019038-1594857573727":"2020-07-16T00:00:39.807Z","2.1.0-canary-6487eeb-1594930649226":"2020-07-16T20:18:22.405Z","2.1.0-canary-0b743b1-1594967040060":"2020-07-17T06:24:56.010Z","2.1.0-canary-d66f277-1595047581397":"2020-07-18T04:47:26.833Z","2.1.0-canary-22939fe-1595088570923":"2020-07-18T16:11:37.612Z","2.1.0-canary-6d7eb7f-1595100999351":"2020-07-18T19:37:32.994Z","2.1.0-canary-77727d3-1595101738971":"2020-07-18T19:49:54.841Z","2.1.0-canary-d99c2a9-1595398999147":"2020-07-22T06:24:26.381Z","2.1.0-canary-d1c76ed-1595444289177":"2020-07-22T18:59:27.121Z","2.1.0-canary-f5e348e-1595527457942":"2020-07-23T18:05:27.971Z","2.1.0-canary-aff1b09-1595530783006":"2020-07-23T19:01:10.661Z","2.1.0-canary-4d48c66-1595531037257":"2020-07-23T19:05:02.141Z","2.1.0-canary-2abcaf6-1595533071623":"2020-07-23T19:38:47.869Z","2.1.0-canary-ba822a3-1595536631724":"2020-07-23T20:38:07.378Z","2.1.0-canary-324f6ed-1595550667660":"2020-07-24T00:32:03.960Z","2.1.0-canary-919433b-1595576076140":"2020-07-24T07:35:36.158Z","2.1.0-canary-59d6478-1595588889523":"2020-07-24T11:09:07.547Z","2.1.1":"2020-07-24T11:12:40.761Z","2.1.1-canary-5143c8a-1595589218620":"2020-07-24T11:14:41.027Z","2.2.0":"2020-07-24T11:19:43.362Z","2.2.0-canary-258220b-1595945949511":"2020-07-28T14:20:45.843Z","2.2.0-canary-dc23fe6-1596141893413":"2020-07-30T20:45:53.687Z","2.2.0-canary-5210260-1596173872047":"2020-07-31T05:38:49.978Z","2.2.0-canary-601bffd-1596249128194":"2020-08-01T02:33:24.425Z","2.2.0-canary-6963d9a-1596280113158":"2020-08-01T11:09:31.133Z","2.2.0-canary-5b8e8bf-1596585499618":"2020-08-04T23:59:18.044Z","2.2.0-canary-3ecab9d-1596674469964":"2020-08-06T00:42:25.686Z","2.2.0-canary-75215d2-1596752032564":"2020-08-06T22:14:51.532Z","2.2.0-canary-31b1130-1596754604496":"2020-08-06T22:57:40.027Z","2.2.0-canary-d97a3db-1596829192321":"2020-08-07T19:40:55.752Z","2.2.0-canary-ec56f20-1596832343677":"2020-08-07T20:33:23.759Z","2.2.0-canary-9a64aa7-1596934254885":"2020-08-09T00:52:02.556Z","2.2.0-canary-bf8625d-1596978501083":"2020-08-09T13:09:28.842Z","2.2.0-canary-65e41eb-1597013508308":"2020-08-09T22:53:03.722Z","2.2.0-canary-c3923f7-1597044121851":"2020-08-10T07:23:04.305Z","2.2.0-canary-fc7d0f4-1597044126801":"2020-08-10T07:23:20.794Z","2.2.0-canary-a209a63-1597044376107":"2020-08-10T07:27:13.997Z","2.2.0-canary-aa934d8-1597096892040":"2020-08-10T22:02:29.605Z","2.2.0-canary-e3fe3c7-1597181180954":"2020-08-11T21:27:26.455Z","2.2.0-canary-c88e1c8-1597288407560":"2020-08-13T03:14:31.079Z","2.2.0-canary-79722ad-1597359216509":"2020-08-13T22:54:29.418Z","2.2.0-canary-0dea971-1597362777750":"2020-08-13T23:53:52.218Z","2.2.0-canary-6e8fb4b-1597369511392":"2020-08-14T01:46:14.385Z","2.2.0-canary-80d19e3-1597388961050":"2020-08-14T07:10:26.556Z","2.2.0-canary-4f93d32-1597388976435":"2020-08-14T07:10:31.161Z","2.2.0-canary-32d7d9f-1597389206847":"2020-08-14T07:14:27.770Z","2.2.0-canary-5d10095-1597400775506":"2020-08-14T10:27:34.474Z","2.2.0-canary-f692689-1597454237775":"2020-08-15T01:18:14.714Z","2.2.0-canary-9f7f124-1597454832290":"2020-08-15T01:28:04.732Z","2.2.0-canary-dde4aa1-1597467250690":"2020-08-15T04:55:08.145Z","2.2.0-canary-42f3ebc-1597553710869":"2020-08-16T04:56:05.748Z","2.2.0-canary-21c8dae-1597557827451":"2020-08-16T06:04:51.266Z","2.2.0-canary-5d5e098-1597607676253":"2020-08-16T19:55:41.275Z","2.2.0-canary-c7c21d8-1597832665653":"2020-08-19T10:25:28.563Z","2.2.0-canary-c3f35c8-1598079876707":"2020-08-22T07:05:35.492Z","2.2.0-canary-8285496-1598101962927":"2020-08-22T13:13:47.544Z","2.2.0-canary-e9e20bb-1598345113815":"2020-08-25T08:46:10.614Z","2.2.0-canary-83a036c-1598508052260":"2020-08-27T06:01:45.597Z","2.2.0-canary-cdf4456-1598510794424":"2020-08-27T06:47:35.893Z","2.2.0-canary-0ea6a9b-1598592452430":"2020-08-28T05:28:36.698Z","2.2.0-canary-cd42db6-1598708271708":"2020-08-29T13:38:54.423Z","2.2.0-canary-800f0e6-1598710210847":"2020-08-29T14:11:21.871Z","2.2.0-canary-d5d7bfa-1598712128332":"2020-08-29T14:43:10.360Z","2.2.0-canary-75a8d70-1598814392584":"2020-08-30T19:07:47.287Z","2.2.0-canary-961bd00-1598912112078":"2020-08-31T22:16:20.926Z","2.2.0-canary-a2d9528-1598968796196":"2020-09-01T14:01:14.749Z","2.2.0-canary-08da3a3-1598975270543":"2020-09-01T15:48:57.287Z","2.2.0-canary-b518123-1599031436461":"2020-09-02T07:24:56.833Z","2.2.0-canary-ec257c6-1599067281309":"2020-09-02T17:22:25.241Z","2.2.0-canary-ace7e2d-1599145596390":"2020-09-03T15:07:38.972Z","2.2.0-canary-eefb756-1599330130341":"2020-09-05T18:23:19.603Z","2.2.0-canary-5816317-1599339862432":"2020-09-05T21:05:27.052Z","2.2.0-canary-d5361a6-1599936618101":"2020-09-12T18:51:26.939Z","2.2.0-canary-9a34bdc-1600350606914":"2020-09-17T13:51:09.710Z","2.2.0-canary-cead4c5-1600527308695":"2020-09-19T14:56:14.805Z","2.2.0-canary-75545ba-1600599376904":"2020-09-20T10:57:23.503Z","2.2.0-canary-e0ccf02-1600653945860":"2020-09-21T02:06:55.529Z","2.2.0-canary-9906e4b-1600676418407":"2020-09-21T08:21:19.472Z","2.2.0-canary-8082b00-1600851515768":"2020-09-23T08:59:50.943Z","2.2.0-canary-64988b0-1601097049923":"2020-09-26T05:11:56.237Z","2.2.0-canary-1357c1c-1601158597097":"2020-09-26T22:17:48.062Z","2.2.0-canary-424b205-1601460320654":"2020-09-30T10:06:43.318Z","2.2.0-canary-3a77e9b-1601949813195":"2020-10-06T02:04:41.601Z","2.2.0-canary-ff02a2a-1602085084447":"2020-10-07T15:40:14.191Z","2.2.0-canary-0d89f0a-1602101056776":"2020-10-07T20:05:26.259Z","2.2.0-canary-8ab439f-1602243060040":"2020-10-09T11:32:18.687Z","2.2.0-canary-ba2d476-1602418459382":"2020-10-11T12:15:39.052Z","2.2.0-canary-c641b9a-1602422666051":"2020-10-11T13:25:33.288Z","2.2.0-canary-b871c48-1602439602982":"2020-10-11T18:09:50.477Z","2.2.0-canary-ca298cd-1602573899954":"2020-10-13T07:26:19.990Z","2.2.0-canary-6a364c4-1602694630568":"2020-10-14T16:58:31.604Z","2.2.0-canary-7c44693-1602796810890":"2020-10-15T21:21:23.506Z","2.2.0-canary-5c73c9b-1602797935260":"2020-10-15T21:40:03.998Z","2.2.0-canary-5e852ff-1602829398077":"2020-10-16T06:25:02.967Z","2.2.0-canary-712304a-1602919186783":"2020-10-17T07:20:46.201Z","2.2.0-canary-0aac144-1603030968316":"2020-10-18T14:24:04.796Z","2.2.0-canary-4a36791-1603178101982":"2020-10-20T07:16:09.694Z","2.2.0-canary-7aca84e-1603293979478":"2020-10-21T15:27:54.142Z","2.2.0-canary-f99fa2c-1603355675240":"2020-10-22T08:35:51.607Z","2.2.0-canary-987965b-1603546411932":"2020-10-24T13:34:43.270Z","2.2.0-canary-ca8e2ff-1603616437859":"2020-10-25T09:01:53.028Z","2.2.0-canary-90428c0-1603634447421":"2020-10-25T14:02:20.054Z","2.2.0-canary-0cef614-1603647150372":"2020-10-25T17:33:36.132Z","2.2.0-canary-e50bf87-1603829485955":"2020-10-27T20:12:27.415Z","2.2.0-canary-fb9d200-1603838891344":"2020-10-27T22:49:25.320Z","2.2.0-canary-88c573b-1603845450423":"2020-10-28T00:39:38.097Z","2.2.0-canary-0bd52c1-1603846782502":"2020-10-28T01:01:05.131Z","2.2.0-canary-fc11def-1603850667900":"2020-10-28T02:05:50.280Z","2.2.0-canary-ac56684-1603992700868":"2020-10-29T17:32:51.277Z","2.2.0-canary-38cc6bc-1603996977589":"2020-10-29T18:45:27.141Z","2.2.0-canary-0bac20a-1604048513431":"2020-10-30T09:03:05.382Z","2.2.0-canary-e1dbfe8-1604107228691":"2020-10-31T01:21:33.029Z","2.2.0-canary-b5be44e-1604213897553":"2020-11-01T06:59:38.797Z","2.2.0-canary-9e2a0f3-1604272980265":"2020-11-01T23:24:24.856Z","2.2.0-canary-09e0d3f-1604309936781":"2020-11-02T09:44:26.352Z","2.2.0-canary-34e1ff9-1604310758182":"2020-11-02T09:53:46.916Z","2.2.0-canary-d001d8c-1604312736123":"2020-11-02T10:27:03.036Z","2.2.0-canary-fa065f6-1604315359592":"2020-11-02T11:10:32.372Z","2.2.0-canary-602762c-1604322508665":"2020-11-02T13:10:01.621Z","2.2.0-canary-b820ed2-1604480543519":"2020-11-04T09:03:54.036Z","2.2.0-canary-91e1d78-1604714937620":"2020-11-07T02:10:00.114Z","2.2.0-canary-4c0ec6e-1604847720075":"2020-11-08T15:03:34.941Z","2.2.0-canary-649f92a-1605296697390":"2020-11-13T19:46:09.682Z","2.2.0-canary-0269d70-1605363907248":"2020-11-14T14:26:19.315Z","2.2.0-canary-3a58960-1605689035938":"2020-11-18T08:45:09.071Z","2.2.0-canary-2818c27-1605912879450":"2020-11-20T22:55:38.685Z","2.2.0-canary-abf1fd1-1606127243448":"2020-11-23T10:28:48.901Z","2.2.0-canary-e5f8a49-1606630334463":"2020-11-29T06:13:21.281Z","2.2.0-canary-1a19017-1606761742477":"2020-11-30T18:43:32.744Z","2.2.0-canary-03ae7cb-1606761947043":"2020-11-30T18:47:05.429Z","2.2.0-canary-a4ef415-1606808719187":"2020-12-01T07:46:25.064Z","2.2.0-canary-4657432-1606841187149":"2020-12-01T17:13:36.101Z","2.2.0-canary-34f02e5-1606855294419":"2020-12-01T20:43:19.686Z","2.2.0-canary-4c47c9e-1606950885027":"2020-12-02T23:15:46.548Z","2.2.0-canary-2a58588-1606983746775":"2020-12-03T08:23:40.605Z","2.2.0-canary-0a39bf3-1606987459278":"2020-12-03T09:25:45.400Z","2.2.0-canary-8bfac07-1607102133763":"2020-12-04T17:27:31.937Z","2.2.0-canary-0fc3a27-1607111306546":"2020-12-04T19:49:34.282Z","2.2.0-canary-fe4a88a-1607156320137":"2020-12-05T08:19:59.135Z","2.2.0-canary-f0d04fd-1607234492522":"2020-12-06T06:02:48.528Z","2.2.0-canary-d7cba96-1607405150510":"2020-12-08T05:26:57.303Z","2.2.0-canary-ee6c443-1607461356691":"2020-12-08T21:03:51.917Z","2.2.0-canary-030ae72-1607626069233":"2020-12-10T18:48:50.534Z","2.2.0-canary-571044a-1607640295951":"2020-12-10T22:46:14.013Z","2.2.0-canary-8ac9166-1607945250186":"2020-12-14T11:28:39.511Z","2.2.0-canary-6579ec3-1607957930068":"2020-12-14T15:00:00.417Z","2.2.0-canary-f6c8ff0-1607958461953":"2020-12-14T15:09:17.124Z","2.2.0-canary-8c83479-1608328920954":"2020-12-18T22:03:06.377Z","2.2.0-canary-5a8f1c5-1608570136226":"2020-12-21T17:03:20.861Z","2.2.0-canary-d1f6475-1608641936498":"2020-12-22T13:00:07.670Z","2.2.0-canary-eac3287-1609165037285":"2020-12-28T14:18:22.207Z","2.2.0-canary-7940737-1609181462419":"2020-12-28T18:52:06.941Z","2.2.0-canary-94baacf-1609219702885":"2020-12-29T05:29:28.601Z","2.2.0-canary-c9b88f4-1609244687313":"2020-12-29T12:25:58.911Z","2.2.0-canary-a4106d5-1609264839516":"2020-12-29T18:01:40.899Z","2.2.0-canary-d56044c-1609272411001":"2020-12-29T20:07:58.730Z","2.2.0-canary-eddc81f-1609286731039":"2020-12-30T00:06:54.963Z","2.2.0-canary-76f91eb-1609363008090":"2020-12-30T21:17:47.181Z","2.2.0-canary-1df0042-1609465244060":"2021-01-01T01:41:55.299Z","2.2.0-canary-1df6210-1609491543593":"2021-01-01T09:00:03.733Z","2.2.0-canary-c94b676-1609541250701":"2021-01-01T22:48:30.337Z","2.2.0-canary-d9a7289-1609557116418":"2021-01-02T03:13:00.590Z","2.2.0-canary-f64d2bf-1609557285429":"2021-01-02T03:15:53.883Z","2.2.0-canary-04c35fe-1609564213563":"2021-01-02T05:11:22.240Z","2.2.0-canary-b3f7e59-1609638935934":"2021-01-03T01:56:41.289Z","2.2.0-canary-205fa23-1609715615953":"2021-01-03T23:14:53.301Z","2.2.0-canary-f32f36c-1609715656088":"2021-01-03T23:15:26.697Z","2.2.0-canary-6acafef-1609791562033":"2021-01-04T20:20:32.059Z","2.2.0-canary-d2580ef-1609806752672":"2021-01-05T00:33:50.843Z","2.2.0-canary-f24c29d-1609854120453":"2021-01-05T13:42:55.287Z","2.2.0-canary-0ee39ba-1609854319648":"2021-01-05T13:46:24.197Z","2.2.0-canary-7d91076-1609889808530":"2021-01-05T23:37:49.607Z","2.2.0-canary-f8fe98b-1609890000444":"2021-01-05T23:41:08.910Z","2.2.0-canary-3601b13-1609910540328":"2021-01-06T05:23:22.367Z","2.2.0-canary-12c6a04-1609943996350":"2021-01-06T14:41:12.998Z","2.2.0-canary-eabff73-1609944262255":"2021-01-06T14:45:30.517Z","2.2.0-canary-4ea6e24-1610012193119":"2021-01-07T09:37:46.756Z","2.2.0-canary-451f336-1610012363027":"2021-01-07T09:40:28.159Z","2.2.0-canary-dd30db0-1610061377557":"2021-01-07T23:17:40.994Z","2.2.0-canary-bb4b421-1610061417167":"2021-01-07T23:18:03.229Z","2.2.0-canary-d0756f5-1610061447005":"2021-01-07T23:18:37.806Z","2.2.0-canary-d09cab3-1610223918629":"2021-01-09T20:26:27.652Z","2.2.0-canary-d12f7bf-1610710690993":"2021-01-15T11:39:20.035Z","2.2.0-canary-4c469ce-1610710857588":"2021-01-15T11:42:05.056Z","2.2.0-canary-a8c4dc0-1610752676343":"2021-01-15T23:18:55.694Z","2.2.0-canary-92d2633-1610752858597":"2021-01-15T23:21:55.703Z","2.2.0-canary-7702c87-1610778995736":"2021-01-16T06:37:53.811Z","2.2.0-canary-67ca37c-1610779176035":"2021-01-16T06:40:33.605Z","2.2.0-canary-42d0b11-1610820742268":"2021-01-16T18:13:47.494Z","2.2.0-canary-adca190-1610851064591":"2021-01-17T02:38:55.198Z","2.2.0-canary-fde3fef-1610925935584":"2021-01-17T23:26:42.973Z","2.2.0-canary-12ae02c-1610925967170":"2021-01-17T23:27:07.868Z","2.2.0-canary-3fe7b14-1611045800944":"2021-01-19T08:44:35.524Z","2.2.0-canary-961e2ea-1611045978677":"2021-01-19T08:47:31.665Z","2.2.0-canary-c171b5f-1611145520301":"2021-01-20T12:26:24.092Z","2.2.0-canary-811a2bf-1611145720267":"2021-01-20T12:29:52.258Z","2.2.0-canary-b87d435-1611270868270":"2021-01-21T23:15:34.051Z","2.2.0-canary-2ae1c10-1611270905893":"2021-01-21T23:16:17.581Z","2.2.0-canary-8186b41-1611333161103":"2021-01-22T16:33:45.041Z","2.2.0-canary-4f2b0a5-1611333330663":"2021-01-22T16:36:47.924Z","2.2.0-canary-2c8f18f-1611433272384":"2021-01-23T20:22:16.105Z","2.2.0-canary-6476295-1611517165323":"2021-01-24T19:41:03.559Z","2.2.0-canary-71403ff-1611586337939":"2021-01-25T14:53:38.302Z","2.2.0-canary-3e3bf94-1611591136236":"2021-01-25T16:13:28.612Z","2.2.0-canary-c5b1c8e-1611616463756":"2021-01-25T23:15:31.956Z","2.2.0-canary-685ec6f-1611616501032":"2021-01-25T23:16:14.679Z","2.2.0-canary-989c4bc-1612125201183":"2021-01-31T20:34:26.257Z","2.2.0-canary-3ba294a-1612355534064":"2021-02-03T12:33:15.653Z","2.2.0-canary-30424f4-1612365022004":"2021-02-03T15:13:53.152Z","2.2.0-canary-f9ebbda-1612548396362":"2021-02-05T18:07:51.486Z","2.2.0-canary-35f44d8-1612628918941":"2021-02-06T16:29:55.167Z","2.2.0-canary-3b45dc0-1612652123363":"2021-02-06T22:56:31.537Z","2.2.0-canary-46c85f6-1613014649080":"2021-02-11T03:38:38.553Z","2.2.0-canary-c1377eb-1613360907645":"2021-02-15T03:49:51.111Z","2.2.0-canary-256de64-1613791336345":"2021-02-20T03:23:30.466Z","2.2.0-canary-b31ddb7-1613865691863":"2021-02-21T00:02:52.240Z","2.2.0-canary-f26bb6c-1614045955609":"2021-02-23T02:06:54.975Z","2.2.0-canary-5b778d6-1614835210295":"2021-03-04T05:21:16.876Z","2.2.0-canary-29ac99e-1615048126690":"2021-03-06T16:29:53.614Z","2.2.0-canary-2513454-1615504600091":"2021-03-11T23:17:43.976Z","2.2.0-canary-d9a038e-1615694071013":"2021-03-14T03:55:36.055Z","2.2.0-canary-70de224-1615752334748":"2021-03-14T20:06:34.448Z","2.2.0-canary-8f0b3f3-1616376550832":"2021-03-22T01:30:22.410Z","2.2.0-canary-a89c80d-1616643435843":"2021-03-25T03:38:26.846Z","2.2.0-canary-c367dad-1617042142885":"2021-03-29T18:23:37.104Z","2.2.0-canary-eb1d297-1617481021285":"2021-04-03T20:18:03.147Z","2.2.0-canary-ae79651-1617833650983":"2021-04-07T22:15:20.392Z","2.2.0-canary-71f85a5-1618395738992":"2021-04-14T10:23:26.581Z","2.2.0-canary-5aef52e-1618482936504":"2021-04-15T10:36:51.012Z","2.2.0-canary-29a0468-1619119223211":"2021-04-22T19:22:04.621Z","2.2.0-canary-d532bcc-1619146278394":"2021-04-23T02:52:17.186Z","2.2.0-canary-0c45632-1619730309288":"2021-04-29T21:06:22.930Z","2.2.0-canary-36faa4f-1619801372643":"2021-04-30T16:50:43.221Z","2.2.0-canary-d07768b-1620027891379":"2021-05-03T07:45:58.306Z","2.2.0-canary-81f63bb-1620319295257":"2021-05-06T16:42:35.168Z","2.2.0-canary-127b16b-1620327188957":"2021-05-06T18:54:15.693Z","2.2.0-canary-10a8e8f-1620412847644":"2021-05-07T18:41:56.614Z","2.2.0-canary-c6e2fa4-1622413518151":"2021-05-30T22:26:22.207Z","2.2.0-canary-765488a-1623104179194":"2021-06-07T22:17:25.933Z","2.2.0-canary-f4188f1-1623190564730":"2021-06-08T22:16:59.512Z","2.2.0-canary-16cd6da-1623276890212":"2021-06-09T22:15:47.400Z","2.2.0-canary-7e703e0-1623881824404":"2021-06-16T22:18:11.461Z","2.2.0-canary-e4df928-1623887123897":"2021-06-16T23:46:21.366Z","2.2.0-canary-25a9c6f-1623984619996":"2021-06-18T02:51:35.311Z","2.2.0-canary-8fde444-1624591472307":"2021-06-25T03:25:31.581Z","2.2.0-canary-a640381-1624761508981":"2021-06-27T02:39:32.838Z","2.2.0-canary-7382957-1625005249074":"2021-06-29T22:21:59.201Z","2.2.0-canary-998f404-1625442492287":"2021-07-04T23:49:20.903Z","2.2.0-canary-24a1fef-1625946529106":"2021-07-10T19:49:45.520Z","2.2.0-canary-76ad6c2-1626046903611":"2021-07-11T23:42:44.012Z","2.2.0-canary-1be33e7-1626053094415":"2021-07-12T01:25:59.490Z","2.2.0-canary-3a9371f-1627289711123":"2021-07-26T08:56:19.604Z","2.2.0-canary-e0ff522-1627470570858":"2021-07-28T11:10:36.308Z","2.2.0-canary-e70bbbb-1627751535874":"2021-07-31T17:13:15.593Z"},"bugs":{"url":"https://github.com/iadvize/foldable-helpers-library/issues"},"author":{"name":"iAdvize developers"},"license":"MIT","homepage":"https://github.com/iadvize/foldable-helpers-library#readme","keywords":["iAdvize"],"repository":{"url":"git+https://github.com/iadvize/foldable-helpers-library.git","type":"git"},"description":"Typescript helpers to fold on sum types","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":""}