{"_id":"@iadvize-oss/opaque-type","_rev":"482-0504f44a27682291ec6e5716dad6e188","name":"@iadvize-oss/opaque-type","dist-tags":{"NO-TICKET-add-CODEOWNERS":"0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08","NO-TICKET-doc":"0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d","dependabot-npm_and_yarn-rollup-plugin-commonjs-11.0.2":"0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce","dependabot-npm_and_yarn-ts-jest-25.2.0":"0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374","dependabot-npm_and_yarn-types-jest-25.1.2":"0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577","NO-TICKET-update-README":"0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.26.0":"0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d","NO-TICKET-first-minor":"0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f","dependabot-npm_and_yarn-rollup-1.31.1":"1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050","dependabot-npm_and_yarn-typedoc-0.16.10":"1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a","dependabot-npm_and_yarn-ts-jest-25.2.1":"1.0.1-canary-93ccbe7-1582100793815","dependabot-npm_and_yarn-types-jest-25.1.3":"1.0.2-beta.0-canary-c439b76-1582141844980","dependabot-npm_and_yarn-typescript-3.8.2":"1.0.2-beta.1-canary-e2f7616-1582239148334","dependabot-npm_and_yarn-tslib-1.11.0":"1.0.2-beta.2-canary-8a7967b-1582533367835","NO-TICKET-add-eslint":"1.0.2-beta.3-canary-5773226-1582616158710","beta":"1.0.2-beta.4","dependabot-npm_and_yarn-rollup-plugin-multi-input-1.1.0":"1.0.2-beta.4-canary-f3baa1d-1582618348828","NO-TICKET-remove-unused-rollup-plugins":"1.0.2-beta.4-canary-fccf77b-1582663254431","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-0.0.5":"1.0.2-beta.4-canary-66f1691-1582714072420","dependabot-npm_and_yarn-iadvize-oss-eslint-config-0.1.2":"1.0.2-beta.4-canary-f261b22-1582716244261","dependabot-npm_and_yarn-iadvize-oss-eslint-config-0.1.3":"1.0.2-beta.4-canary-cec2caf-1582790970733","dependabot-npm_and_yarn-babel-preset-env-7.8.6":"1.0.2-beta.4-canary-973c20b-1582806446205","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.0.0":"1.0.2-beta.4-canary-9f13efa-1582806711779","dependabot-npm_and_yarn-babel-core-7.8.6":"1.0.2-beta.4-canary-fcf1c67-1582806840760","dependabot-npm_and_yarn-tslib-1.11.1":"1.0.2-beta.4-canary-3027e21-1582832223725","dependabot-npm_and_yarn-typedoc-0.16.11":"1.0.2-beta.4-canary-bc6bf3f-1582866476413","dependabot-npm_and_yarn-rollup-1.32.0":"1.0.2-beta.4-canary-9bd64d4-1582877000927","dependabot-npm_and_yarn-typescript-3.8.3":"1.0.2-beta.4-canary-9e008dc-1582928488626","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.0":"1.0.2-beta.4-canary-61701b9-1583141015960","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.1":"1.0.2-beta.4-canary-c3c8d4c-1583223011922","dependabot-npm_and_yarn-babel-preset-env-7.8.7":"1.0.2-beta.4-canary-5d9f1d8-1583373815517","dependabot-npm_and_yarn-babel-core-7.8.7":"1.0.2-beta.4-canary-b3511f8-1583397702323","dependabot-npm_and_yarn-rollup-1.32.1":"1.0.2-beta.4-canary-5822793-1583487565496","dependabot-npm_and_yarn-types-jest-25.1.4":"1.0.2-beta.4-canary-1a6ef57-1583546259677","dependabot-npm_and_yarn-rollup-plugin-terser-5.3.0":"1.0.2-beta.4-canary-67f56a3-1583782697351","dependabot-npm_and_yarn-rollup-2.0.2":"1.0.2-beta.4-canary-c03e7bc-1583796076250","dependabot-npm_and_yarn-rollup-2.0.3":"1.0.2-beta.5-canary-073ecc0-1583827567037","dependabot-npm_and_yarn-rollup-2.0.4":"1.0.2-beta.5-canary-70d8677-1583989794731","dependabot-npm_and_yarn-rollup-2.0.5":"1.0.2-beta.5-canary-3121565-1584002949437","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.2":"1.0.2-beta.5-canary-ded2299-1584025903922","dependabot-npm_and_yarn-rollup-2.0.6":"1.0.2-beta.5-canary-29a0797-1584085771246","dependabot-npm_and_yarn-acorn-6.4.1":"1.0.2-beta.5-canary-9c44638-1584133638444","dependabot-npm_and_yarn-typedoc-0.17.0":"1.0.2-beta.5-canary-e82e35b-1584314543180","dependabot-npm_and_yarn-typedoc-0.17.1":"1.0.2-beta.5-canary-b340863-1584504499281","dependabot-npm_and_yarn-rollup-2.1.0":"1.0.2-beta.5-canary-29c8eba-1584518489585","dependabot-npm_and_yarn-babel-preset-env-7.9.0":"1.0.2-beta.5-canary-a7adb04-1584719250948","dependabot-npm_and_yarn-babel-core-7.9.0":"1.0.2-beta.5-canary-c875153-1584719510030","dependabot-npm_and_yarn-typedoc-0.17.2":"1.0.2-beta.5-canary-09c327e-1584831868407","dependabot-npm_and_yarn-typedoc-0.17.3":"1.0.2-beta.5-canary-024cc3a-1584852484945","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.1.3":"1.0.2-beta.5-canary-a2a8e1b-1584876898818","dependabot-npm_and_yarn-rollup-2.2.0":"1.0.2-beta.5-canary-7dad17d-1585065999095","dependabot-npm_and_yarn-babel-jest-25.2.0":"1.0.2-beta.5-canary-58883d0-1585159380708","dependabot-npm_and_yarn-jest-25.2.0":"1.0.2-beta.5-canary-33fd1f2-1585160147428","dependabot-npm_and_yarn-babel-jest-25.2.1":"1.0.2-beta.5-canary-64628a4-1585215564804","dependabot-npm_and_yarn-jest-25.2.1":"1.0.2-beta.5-canary-f85fe06-1585215584641","dependabot-npm_and_yarn-jest-25.2.2":"1.0.2-beta.5-canary-5b50d3a-1585239960903","dependabot-npm_and_yarn-babel-jest-25.2.3":"1.0.2-beta.5-canary-4f85072-1585255148983","dependabot-npm_and_yarn-jest-25.2.3":"1.0.2-beta.5-canary-9956bbb-1585255171123","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.0":"1.0.2-beta.5-canary-a350247-1585296748232","dependabot-npm_and_yarn-babel-jest-25.2.4":"1.0.2-beta.5-canary-df43901-1585510987354","dependabot-npm_and_yarn-rollup-2.3.0":"1.0.2-beta.5-canary-efc3428-1585513774336","dependabot-npm_and_yarn-jest-25.2.4":"1.0.2-beta.5-canary-87f5d3e-1585549622185","dependabot-npm_and_yarn-ts-jest-25.3.0":"1.0.2-beta.5-canary-78da5e2-1585560770677","dependabot-npm_and_yarn-remark-cli-8.0.0":"1.0.2-beta.5-canary-8d68c0a-1585565474369","dependabot-npm_and_yarn-rollup-2.3.1":"1.0.2-beta.5-canary-16cbc82-1585597646849","dependabot-npm_and_yarn-rollup-2.3.2":"1.0.2-beta.5-canary-233cdfc-1585687816372","dependabot-npm_and_yarn-babel-jest-25.2.6":"1.0.2-beta.5-canary-dc20aec-1585824246940","dependabot-npm_and_yarn-jest-25.2.6":"1.0.2-beta.5-canary-494caea-1585824454592","dependabot-npm_and_yarn-types-jest-25.1.5":"1.0.2-beta.5-canary-6ad0f06-1585847004845","dependabot-npm_and_yarn-jest-25.2.7":"1.0.2-beta.5-canary-00da276-1585903938133","dependabot-npm_and_yarn-ts-jest-25.3.1":"1.0.2-beta.5-canary-07c03e8-1585926926584","dependabot-npm_and_yarn-types-jest-25.2.0":"1.0.2-beta.5-canary-2e3cd2c-1585947765082","dependabot-npm_and_yarn-types-jest-25.2.1":"1.0.2-beta.5-canary-a46d0e4-1585949290385","dependabot-npm_and_yarn-rollup-2.3.3":"1.0.2-beta.5-canary-59298c4-1586040691809","dependabot-npm_and_yarn-typedoc-0.17.4":"1.0.2-beta.5-canary-2e5733f-1586141282355","dependabot-npm_and_yarn-babel-preset-env-7.9.5":"1.0.2-beta.5-canary-aeff84a-1586289027384","dependabot-npm_and_yarn-rollup-2.3.4":"1.0.2-beta.5-canary-f03835f-1586293426880","dependabot-npm_and_yarn-babel-jest-25.3.0":"1.0.2-beta.5-canary-d7db17f-1586352724252","dependabot-npm_and_yarn-jest-25.3.0":"1.0.2-beta.5-canary-1a36d61-1586352745971","dependabot-npm_and_yarn-rollup-2.3.5":"1.0.2-beta.5-canary-12acd7f-1586467458366","dependabot-npm_and_yarn-rollup-2.4.0":"1.0.2-beta.5-canary-03c8e78-1586468958211","dependabot-npm_and_yarn-rollup-2.5.0":"1.0.2-beta.5-canary-b9273bf-1586551421684","dependabot-npm_and_yarn-rollup-2.6.0":"1.0.2-beta.5-canary-e76d25f-1586552014658","dependabot-npm_and_yarn-rollup-2.6.1":"1.0.2-beta.5-canary-b067bac-1586727799253","dependabot-npm_and_yarn-ts-jest-25.4.0":"1.0.2-beta.5-canary-ef529f9-1587112302340","dependabot-npm_and_yarn-babel-jest-25.4.0":"1.0.2-beta.5-canary-d397330-1587333301668","dependabot-npm_and_yarn-jest-25.4.0":"1.0.2-beta.5-canary-e9cf1dc-1587334338587","dependabot-npm_and_yarn-rollup-2.7.0":"1.0.2-beta.5-canary-d75adb4-1587498012278","dependabot-npm_and_yarn-rollup-2.7.1":"1.0.2-beta.5-canary-f12c956-1587502643213","dependabot-npm_and_yarn-rollup-2.7.2":"1.0.2-beta.5-canary-a7f94bd-1587582397601","dependabot-npm_and_yarn-typedoc-0.17.5":"1.0.2-beta.5-canary-65fd91c-1587919873189","dependabot-npm_and_yarn-typedoc-0.17.6":"1.0.2-beta.5-canary-9ef441a-1587949973107","dependabot-npm_and_yarn-rollup-2.7.3":"1.0.2-beta.5-canary-b231473-1588012900301","dependabot-npm_and_yarn-babel-jest-25.5.0":"1.0.2-beta.5-canary-2c17e3b-1588103412645","dependabot-npm_and_yarn-jest-25.5.0":"1.0.2-beta.5-canary-0f84c9d-1588103466646","dependabot-npm_and_yarn-babel-jest-25.5.1":"1.0.2-beta.5-canary-2c1627e-1588157983350","dependabot-npm_and_yarn-jest-25.5.1":"1.0.2-beta.5-canary-c424596-1588158013144","dependabot-npm_and_yarn-babel-preset-env-7.9.6":"1.0.2-beta.5-canary-79bfa68-1588185892953","dependabot-npm_and_yarn-rollup-2.7.4":"1.0.2-beta.5-canary-15e7976-1588186715813","dependabot-npm_and_yarn-babel-core-7.9.6":"1.0.2-beta.5-canary-8179d1d-1588187147368","dependabot-npm_and_yarn-rollup-2.7.5":"1.0.2-beta.5-canary-efe0053-1588190101851","dependabot-npm_and_yarn-jest-25.5.2":"1.0.2-beta.5-canary-992f400-1588197333350","dependabot-npm_and_yarn-rollup-2.7.6":"1.0.2-beta.5-canary-1f9fb09-1588273271465","dependabot-npm_and_yarn-jest-25.5.3":"1.0.2-beta.5-canary-a5513b9-1588285015103","dependabot-npm_and_yarn-jest-25.5.4":"1.0.2-beta.5-canary-889992d-1588407679745","dependabot-npm_and_yarn-babel-jest-26.0.0":"1.0.2-beta.5-canary-ecbddb2-1588615076695","dependabot-npm_and_yarn-babel-jest-26.0.1":"1.0.2-beta.5-canary-19cce0a-1588675647653","dependabot-npm_and_yarn-tslib-1.11.2":"1.0.2-beta.5-canary-52169e8-1588721273741","dependabot-npm_and_yarn-rollup-2.8.0":"1.0.2-beta.5-canary-0055846-1588748538997","dependabot-npm_and_yarn-ts-jest-25.5.0":"1.0.2-beta.5-canary-244d597-1588755806680","dependabot-npm_and_yarn-rollup-2.8.1":"1.0.2-beta.5-canary-37986c1-1588828986179","dependabot-npm_and_yarn-rollup-2.8.2":"1.0.2-beta.5-canary-0f6ff6f-1588841434488","dependabot-npm_and_yarn-ts-jest-25.5.1":"1.0.2-beta.5-canary-b7cc680-1589014630167","dependabot-npm_and_yarn-rollup-2.9.0":"1.0.2-beta.5-canary-1478730-1589108142075","dependabot-npm_and_yarn-rollup-2.9.1":"1.0.2-beta.5-canary-6f53112-1589190833506","dependabot-npm_and_yarn-tslib-1.12.0":"1.0.2-beta.5-canary-56d1eba-1589307147434","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.1":"1.0.2-beta.5-canary-1bd0d03-1589312259435","dependabot-npm_and_yarn-rollup-2.10.0":"1.0.2-beta.5-canary-8020112-1589347820274","dependabot-npm_and_yarn-typescript-3.9.2":"1.0.2-beta.5-canary-a5f43c8-1589353590846","dependabot-npm_and_yarn-types-jest-25.2.2":"1.0.2-beta.5-canary-4993fa1-1589395986518","dependabot-npm_and_yarn-tslib-2.0.0":"1.0.2-beta.5-canary-615f6d2-1589411502969","dependabot-npm_and_yarn-rollup-2.10.2":"1.0.2-beta.5-canary-adf58ed-1589523511339","dependabot-npm_and_yarn-typedoc-0.17.7":"1.0.2-beta.5-canary-80d3baa-1589687934188","dependabot-npm_and_yarn-rollup-2.10.3":"1.0.2-beta.5-canary-6f46f4a-1589842476806","dependabot-npm_and_yarn-types-jest-25.2.3":"1.0.2-beta.5-canary-3b59d34-1589843950138","dependabot-npm_and_yarn-rollup-2.10.4":"1.0.2-beta.5-canary-4cb1b65-1589870044852","dependabot-npm_and_yarn-rollup-2.10.5":"1.0.2-beta.5-canary-e72c8bc-1589922341260","dependabot-npm_and_yarn-typescript-3.9.3":"1.0.2-beta.5-canary-0f5d3ef-1589958814757","dependabot-npm_and_yarn-rollup-2.10.7":"1.0.2-beta.5-canary-6bf94e0-1590127697800","dependabot-npm_and_yarn-rollup-2.10.8":"1.0.2-beta.5-canary-eee8d3b-1590213645497","dependabot-npm_and_yarn-rollup-plugin-terser-6.0.0":"1.0.2-beta.5-canary-a8f684e-1590228899568","dependabot-npm_and_yarn-rollup-plugin-terser-6.0.1":"1.0.2-beta.5-canary-d887954-1590232693016","dependabot-npm_and_yarn-rollup-2.10.9":"1.0.2-beta.5-canary-3de3e1c-1590302819712","dependabot-npm_and_yarn-rollup-plugin-terser-6.1.0":"1.0.2-beta.5-canary-6866f6f-1590358852675","NO-TICKET-expose-OpaqueApi-type":"1.0.2-beta.5-canary-280615b-1590477704162","dependabot-npm_and_yarn-babel-preset-env-7.10.0":"1.1.0-canary-be49305-1590530930008","dependabot-npm_and_yarn-babel-core-7.10.0":"1.1.0-canary-e894cb9-1590531655438","dependabot-npm_and_yarn-rollup-2.11.0":"1.1.0-canary-843a022-1590610125425","dependabot-npm_and_yarn-babel-core-7.10.1":"1.1.0-canary-f7e9ea3-1590622926924","dependabot-npm_and_yarn-babel-preset-env-7.10.1":"1.1.0-canary-6153d68-1590623623619","dependabot-npm_and_yarn-rollup-2.11.2":"1.1.0-canary-bb524af-1590646959609","dependabot-npm_and_yarn-babel-preset-env-7.10.2":"1.1.0-canary-dbbeba6-1590870373720","dependabot-npm_and_yarn-babel-core-7.10.2":"1.1.0-canary-8bcc443-1590871135457","dependabot-npm_and_yarn-rollup-2.12.0":"1.1.0-canary-cfcb72b-1590900349309","dependabot-npm_and_yarn-rollup-2.12.1":"1.1.0-canary-af2c380-1591132026664","dependabot-npm_and_yarn-rollup-2.13.0":"1.1.0-canary-d27fdb3-1591216500836","dependabot-npm_and_yarn-rollup-2.13.1":"1.1.0-canary-c0e2c2d-1591250949476","dependabot-npm_and_yarn-typescript-3.9.5":"1.1.0-canary-4f0596f-1591305030945","dependabot-npm_and_yarn-rollup-2.14.0":"1.1.0-canary-d890821-1591569709557","dependabot-npm_and_yarn-rollup-2.15.0":"1.1.0-canary-04b04b7-1591658231490","dependabot-npm_and_yarn-types-jest-26.0.0":"1.1.0-canary-ae2e3f2-1591741234969","dependabot-npm_and_yarn-rollup-2.16.1":"1.1.0-canary-2520b7e-1592175902594","dependabot-npm_and_yarn-rollup-2.17.0":"1.1.0-canary-e44ecae-1592430687157","NO-TICKET-update-libs":"1.1.0-canary-48f3c2f-1592678994388","latest":"1.1.1","dependabot-npm_and_yarn-rollup-2.18.0":"1.1.1-canary-2835045-1592861953392","dependabot-npm_and_yarn-ts-jest-26.1.1":"1.1.1-canary-9f5ddd3-1592863004027","dependabot-npm_and_yarn-jest-26.1.0":"1.1.1-canary-315c2b7-1592963825365","dependabot-npm_and_yarn-types-jest-26.0.3":"1.1.1-canary-9ac4336-1593026141405","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.2.0":"1.1.1-canary-2dcb984-1593193095672","dependabot-npm_and_yarn-rollup-2.18.1":"1.1.1-canary-0e0453a-1593200935579","dependabot-npm_and_yarn-iadvize-oss-eslint-config-1.2.1":"1.1.1-canary-28381e5-1593348286133","dependabot-npm_and_yarn-typedoc-0.17.8":"1.1.1-canary-02214be-1593394297099","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.0.0":"1.1.1-canary-30cf674-1593438454258","dependabot-npm_and_yarn-tsd-0.12.0":"1.1.1-canary-a143360-1593454105193","dependabot-npm_and_yarn-minimist-1.2.5":"1.1.1-canary-b234752-1593469078439","dependabot-npm_and_yarn-typescript-3.9.6":"1.1.1-canary-59e8c5c-1593636922345","dependabot-npm_and_yarn-rollup-2.18.2":"1.1.1-canary-9048baa-1593664043026","dependabot-npm_and_yarn-tsd-0.12.1":"1.1.1-canary-e235d2e-1593710139329","dependabot-npm_and_yarn-eslint-7.4.0":"1.1.1-canary-89d55f2-1593808150498","dependabot-npm_and_yarn-tsd-0.13.0":"1.1.1-canary-13ce33b-1593860332468","dependabot-npm_and_yarn-tsd-0.13.1":"1.1.1-canary-ddbf940-1593865597717","dependabot-npm_and_yarn-rollup-2.19.0":"1.1.1-canary-b290deb-1593928066513","dependabot-npm_and_yarn-rollup-2.20.0":"1.1.1-canary-eeb26b7-1594080074979","dependabot-npm_and_yarn-types-jest-26.0.4":"1.1.1-canary-bd11d0c-1594085260830","dependabot-npm_and_yarn-rollup-2.21.0":"1.1.1-canary-f45a7ff-1594165990895","dependabot-npm_and_yarn-ts-jest-26.1.2":"1.1.1-canary-0f25678-1594663692687","dependabot-npm_and_yarn-lodash-4.17.19":"1.1.1-canary-c5aaeb5-1594857810973","dependabot-npm_and_yarn-typescript-3.9.7":"1.1.1-canary-97e0dd6-1594930378573","dependabot-npm_and_yarn-ts-jest-26.1.3":"1.1.1-canary-ef3ebd9-1594967039662","dependabot-npm_and_yarn-rollup-2.22.0":"1.1.1-canary-df4352d-1595047577310","dependabot-npm_and_yarn-types-jest-26.0.5":"1.1.1-canary-95b8ff8-1595088595024","dependabot-npm_and_yarn-eslint-7.5.0":"1.1.1-canary-1aff06a-1595101006498","dependabot-npm_and_yarn-rollup-2.22.1":"1.1.1-canary-13a1f8b-1595101739339","dependabot-npm_and_yarn-rollup-2.22.2":"1.1.1-canary-f22df89-1595398538126","dependabot-npm_and_yarn-types-jest-26.0.6":"1.1.1-canary-9b5608a-1595527860204","dependabot-npm_and_yarn-rollup-2.23.0":"1.1.1-canary-29ba22a-1595536520777","dependabot-npm_and_yarn-types-jest-26.0.7":"1.1.1-canary-6ab07e5-1595550278146","dependabot-npm_and_yarn-ts-jest-26.1.4":"1.1.1-canary-4b015aa-1595947718763","dependabot-npm_and_yarn-jest-26.2.1":"1.1.1-canary-8f9789f-1596139189833","dependabot-npm_and_yarn-types-jest-26.0.8":"1.1.1-canary-8a52c06-1596178764805","dependabot-npm_and_yarn-jest-26.2.2":"1.1.1-canary-a09240b-1596249252055","dependabot-npm_and_yarn-eslint-7.6.0":"1.1.1-canary-11cb359-1596279455934","dependabot-npm_and_yarn-types-jest-26.0.9":"1.1.1-canary-bdf5814-1596677952836","dependabot-npm_and_yarn-tslib-2.0.1":"1.1.1-canary-0de0a23-1596756645961","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.2":"1.1.1-canary-59df1ec-1596828276128","dependabot-npm_and_yarn-rollup-2.23.1":"1.1.1-canary-d94387b-1596832372333","dependabot-npm_and_yarn-typedoc-0.18.0":"1.1.1-canary-d125172-1596934252991","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.0":"1.1.1-canary-fadce8c-1596978679443","dependabot-npm_and_yarn-jest-26.3.0":"1.1.1-canary-6a1a741-1597096056568","dependabot-npm_and_yarn-ts-jest-26.2.0":"1.1.1-canary-9602310-1597180556145","dependabot-npm_and_yarn-jest-26.4.0":"1.1.1-canary-84e1414-1597288691922","dependabot-npm_and_yarn-rollup-2.24.0":"1.1.1-canary-a7ae075-1597369520429","dependabot-npm_and_yarn-rollup-2.25.0":"1.1.1-canary-c57466b-1597400116052","dependabot-npm_and_yarn-eslint-7.7.0":"1.1.1-canary-cdde177-1597449664369","dependabot-npm_and_yarn-types-jest-26.0.10":"1.1.1-canary-bb41975-1597453968183","dependabot-npm_and_yarn-rollup-2.26.0":"1.1.1-canary-0ef57e9-1597467249834","dependabot-npm_and_yarn-rollup-2.26.1":"1.1.1-canary-9fdc7af-1597553784580","dependabot-npm_and_yarn-rollup-2.26.2":"1.1.1-canary-2c57508-1597557839436","dependabot-npm_and_yarn-rollup-2.26.3":"1.1.1-canary-131940f-1597607682619","dependabot-npm_and_yarn-rollup-2.26.5":"1.1.1-canary-beb9192-1598079882939","dependabot-npm_and_yarn-jest-26.4.2":"1.1.1-canary-9cbd1e4-1598101965119","dependabot-npm_and_yarn-ts-jest-26.3.0":"1.1.1-canary-d8b7da5-1598508090877","dependabot-npm_and_yarn-typescript-4.0.2":"1.1.1-canary-eab086a-1598510892902","dependabot-npm_and_yarn-rollup-2.26.6":"1.1.1-canary-5ba4aa3-1598592636521","dependabot-npm_and_yarn-rollup-2.26.8":"1.1.1-canary-9f75988-1598708164906","dependabot-npm_and_yarn-typedoc-0.19.0":"1.1.1-canary-2fd4c5d-1598710337660","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.1":"1.1.1-canary-a428f46-1598712094514","dependabot-npm_and_yarn-types-jest-26.0.12":"1.1.1-canary-4eed585-1598969492986","dependabot-npm_and_yarn-eslint-7.8.0":"1.1.1-canary-ffc7f1e-1598974390531","dependabot-npm_and_yarn-rollup-2.26.9":"1.1.1-canary-2652c98-1599031351178","dependabot-npm_and_yarn-eslint-7.8.1":"1.1.1-canary-2e25b95-1599067290644","dependabot-npm_and_yarn-types-jest-26.0.13":"1.1.1-canary-719a459-1599145407024","dependabot-npm_and_yarn-rollup-plugin-terser-7.0.2":"1.1.1-canary-3f954b2-1599330115651","dependabot-npm_and_yarn-typedoc-0.19.1":"1.1.1-canary-344952a-1599339415860","dependabot-npm_and_yarn-eslint-7.9.0":"1.1.1-canary-d2d2065-1599936663488","dependabot-npm_and_yarn-types-jest-26.0.14":"1.1.1-canary-5bc165f-1600350589390","dependabot-npm_and_yarn-typescript-4.0.3":"1.1.1-canary-c26570b-1600526192934","dependabot-npm_and_yarn-ts-jest-26.4.0":"1.1.1-canary-a485ced-1600599378560","dependabot-npm_and_yarn-typedoc-0.19.2":"1.1.1-canary-581d2eb-1600653941457","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.27.3":"1.1.1-canary-463482c-1601096460246","dependabot-npm_and_yarn-eslint-7.10.0":"1.1.1-canary-367c1df-1601158677167","dependabot-npm_and_yarn-ts-jest-26.4.1":"1.1.1-canary-72f737a-1601460787398","dependabot-npm_and_yarn-jest-26.5.0":"1.1.1-canary-c2b6182-1601950934300","dependabot-npm_and_yarn-jest-26.5.2":"1.1.1-canary-717db69-1602085514502","dependabot-npm_and_yarn-tslib-2.0.2":"1.1.1-canary-566bb76-1602101761936","dependabot-npm_and_yarn-rollup-2.29.0":"1.1.1-canary-a1076f1-1602243255147","dependabot-npm_and_yarn-eslint-7.11.0":"1.1.1-canary-9a45251-1602417604212","dependabot-npm_and_yarn-tslib-2.0.3":"1.1.1-canary-9bf30f9-1602424126921","dependabot-npm_and_yarn-jest-26.5.3":"1.1.1-canary-3e06e5c-1602439546186","dependabot-npm_and_yarn-rollup-2.30.0":"1.1.1-canary-0139810-1602694620675","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.1":"1.1.1-canary-775b394-1602796683028","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.2.0":"1.1.1-canary-3f79eea-1602798093608","dependabot-npm_and_yarn-rollup-2.32.0":"1.1.1-canary-9e16b46-1602916777734","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.28.0":"1.1.1-canary-552fedd-1603031024483","dependabot-npm_and_yarn-jest-26.6.0":"1.1.1-canary-1f85529-1603179184054","dependabot-npm_and_yarn-types-jest-26.0.15":"1.1.1-canary-58602c5-1603290660780","dependabot-npm_and_yarn-rollup-2.32.1":"1.1.1-canary-4350e75-1603354976299","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.2":"1.1.1-canary-500ea59-1603548577843","dependabot-npm_and_yarn-jest-26.6.1":"1.1.1-canary-4a84501-1603616456186","dependabot-npm_and_yarn-ts-jest-26.4.2":"1.1.1-canary-fc6ff88-1603633945478","dependabot-npm_and_yarn-eslint-7.12.0":"1.1.1-canary-58148e8-1603650080917","dependabot-npm_and_yarn-ts-jest-26.4.3":"1.1.1-canary-3c0bbb2-1603830483772","dependabot-npm_and_yarn-typescript-4.0.5":"1.1.1-canary-4208134-1603838712674","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.29.0":"1.1.1-canary-2d316d4-1604107225974","dependabot-npm_and_yarn-rollup-2.33.0":"1.1.1-canary-fa5a7a0-1604213890306","dependabot-npm_and_yarn-rollup-2.33.1":"1.1.1-canary-c6cd4cc-1604309954011","dependabot-npm_and_yarn-iadvize-oss-eslint-config-jest-1.2.1":"1.1.1-canary-48ad75f-1604310764637","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.1.3":"1.1.1-canary-32880a9-1604315402892","dependabot-npm_and_yarn-eslint-7.12.1":"1.1.1-canary-cb5aa41-1604316908580","dependabot-npm_and_yarn-jest-26.6.2":"1.1.1-canary-bbdf5c9-1604322483523","dependabot-npm_and_yarn-jest-26.6.3":"1.1.1-canary-fd0081b-1604480585015","dependabot-npm_and_yarn-eslint-7.13.0":"1.1.1-canary-b5953b6-1604714929475","dependabot-npm_and_yarn-ts-jest-26.4.4":"1.1.1-canary-eabb900-1604848093339","dependabot-npm_and_yarn-rollup-2.33.2":"1.1.1-canary-8f30d8c-1605363766533","dependabot-npm_and_yarn-rollup-2.33.3":"1.1.1-canary-4ac3da0-1605687302992","dependabot-npm_and_yarn-eslint-7.14.0":"1.1.1-canary-d7ffeef-1605912871554","dependabot-npm_and_yarn-rollup-2.34.0":"1.1.1-canary-5e05e71-1606630494127","dependabot-npm_and_yarn-types-jest-26.0.16":"1.1.1-canary-d5e13ca-1606854733107","dependabot-npm_and_yarn-rollup-2.34.1":"1.1.1-canary-4cfd792-1606983962877","dependabot-npm_and_yarn-tsd-0.14.0":"1.1.1-canary-774e651-1606987469439","dependabot-npm_and_yarn-highlight.js-10.4.1":"1.1.1-canary-ff08777-1607101017117","dependabot/npm_and_yarn/highlight.js-10.4.1":"1.1.1-canary-7c136c2-1607110934970","dependabot-npm_and_yarn-eslint-7.15.0":"1.1.1-canary-8238b81-1607156225697","dependabot-npm_and_yarn-rollup-2.34.2":"1.1.1-canary-22c6067-1607234650807","dependabot-npm_and_yarn-types-jest-26.0.17":"1.1.1-canary-f83296a-1607405497156","dependabot-npm_and_yarn-types-jest-26.0.18":"1.1.1-canary-7d44b6a-1607461201724","dependabot-npm_and_yarn-ini-1.3.7":"1.1.1-canary-3acb49a-1607621541645","dependabot-npm_and_yarn-types-jest-26.0.19":"1.1.1-canary-652729a-1607640204628","dependabot-npm_and_yarn-rollup-2.35.0":"1.1.1-canary-3e02efc-1607945336112","dependabot-npm_and_yarn-rollup-2.35.1":"1.1.1-canary-79a8292-1607957934328","dependabot-npm_and_yarn-eslint-7.16.0":"1.1.1-canary-a4fd5dc-1608328910278","dependabot-npm_and_yarn-node-notifier-8.0.1":"1.1.1-canary-75fe0c1-1608570061628","dependabot/npm_and_yarn/node-notifier-8.0.1":"1.1.1-canary-2f89a18-1608640866496","dependabot-npm_and_yarn-typedoc-0.20.0":"1.1.1-canary-6b8a2d3-1609181466168","dependabot-npm_and_yarn-typedoc-0.20.1":"1.1.1-canary-a6e6695-1609219825812","dependabot-npm_and_yarn-typedoc-0.20.2":"1.1.1-canary-51f8eb4-1609264766305","dependabot-npm_and_yarn-typedoc-0.20.3":"1.1.1-canary-fba59a0-1609272409690","dependabot-npm_and_yarn-typedoc-0.20.4":"1.1.1-canary-a0004b7-1609286724879","dependabot-npm_and_yarn-typedoc-0.20.5":"1.1.1-canary-afe8853-1609363184528","dependabot-npm_and_yarn-typedoc-0.20.6":"1.1.1-canary-8b153c0-1609465237167","dependabot-npm_and_yarn-typedoc-0.20.7":"1.1.1-canary-d47ed33-1609492725302","dependabot-npm_and_yarn-typedoc-0.20.8":"1.1.1-canary-affe1f5-1609541251553","dependabot-npm_and_yarn-eslint-7.17.0":"1.1.1-canary-a9dedf6-1609557112742","dependabot-npm_and_yarn-typedoc-0.20.9":"1.1.1-canary-dbc1218-1609564277611","dependabot-npm_and_yarn-typedoc-0.20.10":"1.1.1-canary-a249b82-1609638840018","dependabot-npm_and_yarn-typedoc-0.20.11":"1.1.1-canary-61ca8f3-1609791587354","dependabot-npm_and_yarn-typedoc-0.20.12":"1.1.1-canary-d422dc1-1609806748199","dependabot-npm_and_yarn-rollup-2.36.0":"1.1.1-canary-b25f9b1-1609854132044","dependabot-npm_and_yarn-tslib-2.1.0":"1.1.1-canary-6374da9-1609889788878","dependabot-npm_and_yarn-typedoc-0.20.13":"1.1.1-canary-f0df008-1609910674239","dependabot-npm_and_yarn-rollup-2.36.1":"1.1.1-canary-fc1a98f-1609943997655","dependabot-npm_and_yarn-types-jest-26.0.20":"1.1.1-canary-15f1e9b-1610012151794","dependabot-npm_and_yarn-typedoc-0.20.14":"1.1.1-canary-acbb560-1610223837845","dependabot-npm_and_yarn-eslint-7.18.0":"1.1.1-canary-0686096-1610752507981","dependabot-npm_and_yarn-rollup-2.36.2":"1.1.1-canary-c8f8911-1610778862290","dependabot-npm_and_yarn-typedoc-0.20.15":"1.1.1-canary-73f3416-1610820725580","dependabot-npm_and_yarn-typedoc-0.20.16":"1.1.1-canary-0309f44-1610851051898","dependabot-npm_and_yarn-rollup-2.37.0":"1.1.1-canary-3256e81-1611046173496","dependabot-npm_and_yarn-rollup-2.37.1":"1.1.1-canary-778e11d-1611145531555","dependabot-npm_and_yarn-rollup-2.38.0":"1.1.1-canary-414eefc-1611333153071","dependabot-npm_and_yarn-typedoc-0.20.17":"1.1.1-canary-cfa9ea5-1611433264189","dependabot-npm_and_yarn-typedoc-0.20.18":"1.1.1-canary-9fed8de-1611517256217","dependabot-npm_and_yarn-typedoc-0.20.19":"1.1.1-canary-0304477-1611586331477","dependabot-npm_and_yarn-iadvize-oss-eslint-config-2.2.0":"1.1.1-canary-a15c19c-1611591136534","dependabot-npm_and_yarn-rollup-2.38.1":"1.1.1-canary-3439db2-1611843817632","dependabot-npm_and_yarn-ts-jest-26.5.0":"1.1.1-canary-d9183a0-1611928497358","dependabot-npm_and_yarn-eslint-7.19.0":"1.1.1-canary-f9eb947-1612069309929","dependabot-npm_and_yarn-rollup-2.38.2":"1.1.1-canary-107b5bc-1612079718340","dependabot-npm_and_yarn-typedoc-0.20.20":"1.1.1-canary-c1d109b-1612125291569","dependabot-npm_and_yarn-rollup-2.38.3":"1.1.1-canary-8cd500e-1612178933536","dependabot-npm_and_yarn-rollup-2.38.4":"1.1.1-canary-0e76662-1612253867131","dependabot-npm_and_yarn-rollup-2.38.5":"1.1.1-canary-4b2e5cc-1612515107644","dependabot-npm_and_yarn-typedoc-0.20.21":"1.1.1-canary-b4fd7b5-1612548402699","dependabot-npm_and_yarn-typedoc-0.20.22":"1.1.1-canary-f9bf579-1612628824041","dependabot-npm_and_yarn-typedoc-0.20.23":"1.1.1-canary-37845ab-1612652123711","dependabot-npm_and_yarn-ts-jest-26.5.1":"1.1.1-canary-6cc5ff4-1612873622470","dependabot-npm_and_yarn-typescript-4.0.6":"1.1.1-canary-f87888c-1612897009877","dependabot-npm_and_yarn-typescript-4.0.7":"1.1.1-canary-e3929a3-1612990047524","dependabot-npm_and_yarn-typedoc-0.20.24":"1.1.1-canary-826aa25-1613014643612","dependabot-npm_and_yarn-rollup-2.39.0":"1.1.1-canary-58b9699-1613146062073","dependabot-npm_and_yarn-eslint-7.20.0":"1.1.1-canary-bc1da82-1613170002290","dependabot-npm_and_yarn-typedoc-0.20.25":"1.1.1-canary-0dd7fac-1613360741891","dependabot-npm_and_yarn-typedoc-0.20.26":"1.1.1-canary-4499200-1613791330979","dependabot-npm_and_yarn-typedoc-0.20.27":"1.1.1-canary-c64be92-1613865688568","dependabot-npm_and_yarn-rollup-2.39.1":"1.1.1-canary-9a898df-1614075665360","dependabot-npm_and_yarn-ts-jest-26.5.2":"1.1.1-canary-7b1e798-1614118965986","dependabot-npm_and_yarn-typedoc-0.20.28":"1.1.1-canary-fbec41c-1614122191378","dependabot-npm_and_yarn-rollup-2.40.0":"1.1.1-canary-e2a2fda-1614350809006","dependabot-npm_and_yarn-eslint-7.21.0":"1.1.1-canary-557da4e-1614464576863","dependabot-npm_and_yarn-typedoc-0.20.29":"1.1.1-canary-7d30d56-1614835170404","dependabot-npm_and_yarn-ts-jest-26.5.3":"1.1.1-canary-dade30c-1614846763103","dependabot-npm_and_yarn-typedoc-0.20.30":"1.1.1-canary-5d81b81-1615048197914","dependabot-npm_and_yarn-rollup-2.41.0":"1.1.1-canary-97b22c4-1615279991651","dependabot-npm_and_yarn-rollup-2.41.1":"1.1.1-canary-eafa57e-1615439907923","dependabot-npm_and_yarn-node-notifier-8.0.2":"1.1.1-canary-5ee4803-1615504510954","dependabot-npm_and_yarn-rollup-2.41.2":"1.1.1-canary-7c52b3b-1615560023836","dependabot-npm_and_yarn-eslint-7.22.0":"1.1.1-canary-a35b410-1615585902465","dependabot-npm_and_yarn-typedoc-0.20.31":"1.1.1-canary-d8e39ec-1615694045382","dependabot-npm_and_yarn-rollup-2.41.3":"1.1.1-canary-9e46d0a-1615883131543","dependabot-npm_and_yarn-rollup-2.41.4":"1.1.1-canary-98af860-1615905150272","dependabot-npm_and_yarn-ts-jest-26.5.4":"1.1.1-canary-8bfc8cb-1615988155338","dependabot-npm_and_yarn-types-jest-26.0.21":"1.1.1-canary-94ac0d8-1615997123234","dependabot-npm_and_yarn-rollup-2.41.5":"1.1.1-canary-d033a6d-1616044880033","dependabot-npm_and_yarn-typedoc-0.20.32":"1.1.1-canary-e2243c1-1616109354245","dependabot-npm_and_yarn-rollup-2.42.0":"1.1.1-canary-68c0300-1616142237901","dependabot-npm_and_yarn-rollup-2.42.1":"1.1.1-canary-a3e0d5d-1616220452205","dependabot-npm_and_yarn-typedoc-0.20.33":"1.1.1-canary-3b39a81-1616376520844","dependabot-npm_and_yarn-rollup-2.42.2":"1.1.1-canary-0aeb522-1616393828933","dependabot-npm_and_yarn-rollup-2.42.3":"1.1.1-canary-7d49358-1616424988972","dependabot-npm_and_yarn-rollup-2.42.4":"1.1.1-canary-d9b6be6-1616596890182","dependabot-npm_and_yarn-typedoc-0.20.34":"1.1.1-canary-d312191-1616643438682","dependabot-npm_and_yarn-types-jest-26.0.22":"1.1.1-canary-c6a9f50-1616695706194","dependabot-npm_and_yarn-eslint-7.23.0":"1.1.1-canary-0cf9796-1616792841962","dependabot-npm_and_yarn-rollup-2.43.0":"1.1.1-canary-d4ce30f-1616823863898","dependabot-npm_and_yarn-rollup-2.43.1":"1.1.1-canary-d0a4ebb-1616913025554","dependabot-npm_and_yarn-rollup-2.44.0":"1.1.1-canary-cef6442-1617031481510","dependabot-npm_and_yarn-y18n-4.0.1":"1.1.1-canary-1dc550b-1617038482209","dependabot-npm_and_yarn-tslib-2.2.0":"1.1.1-canary-8cf98e6-1617647342641","dependabot-npm_and_yarn-typedoc-0.20.35":"1.1.1-canary-4849cbe-1617747227075","dependabot-npm_and_yarn-y18n-4.0.3":"1.1.1-canary-d849564-1617833694213","dependabot-npm_and_yarn-rollup-2.45.0":"1.1.1-canary-0bba690-1617945900927","dependabot-npm_and_yarn-eslint-7.24.0":"1.1.1-canary-2bb2c8d-1618006766393","dependabot-npm_and_yarn-rollup-2.45.1":"1.1.1-canary-1f15451-1618031968125","dependabot-npm_and_yarn-rollup-2.45.2":"1.1.1-canary-4e82c16-1618292263250","dependabot-npm_and_yarn-eslint-7.25.0":"1.1.1-canary-f2c6cdc-1619218187727","dependabot-npm_and_yarn-types-jest-26.0.23":"1.1.1-canary-3bd01b5-1619552767457","dependabot-npm_and_yarn-rollup-2.46.0":"1.1.1-canary-417a824-1619674717323","dependabot-add-v2-config-file":"1.1.1-canary-e8eebb9-1619710294921","dependabot-npm_and_yarn-rollup-2.47.0":"1.1.1-canary-dc34773-1620106081964","dependabot-npm_and_yarn-ts-jest-26.5.5":"1.1.1-canary-4603cb0-1620222311178","dependabot-npm_and_yarn-rollup-plugin-typescript2-0.30.0":"1.1.1-canary-6411ddf-1620252834422","dependabot-npm_and_yarn-typedoc-0.20.36":"1.1.1-canary-f3eb721-1620252831738","dependabot-npm_and_yarn-handlebars-4.7.7":"1.1.1-canary-9e1d8bf-1620317906335","dependabot-npm_and_yarn-lodash-4.17.21":"1.1.1-canary-6e44621-1620326942458","dependabot-npm_and_yarn-hosted-git-info-2.8.9":"1.1.1-canary-89325e7-1620413505425","dependabot-npm_and_yarn-ws-7.4.6":"1.1.1-canary-a665a4e-1622413500906","dependabot-npm_and_yarn-glob-parent-5.1.2":"1.1.1-canary-7662dad-1623104116345","dependabot-npm_and_yarn-trim-newlines-3.0.1":"1.1.1-canary-8c70834-1623190559876","dependabot-npm_and_yarn-normalize-url-4.5.1":"1.1.1-canary-fe09311-1623276921257","dependabot-npm_and_yarn-ws-7.5.0":"1.1.1-canary-9b2ecc8-1623881836840","dependabot-npm_and_yarn-typedoc-0.20.37":"1.1.1-canary-a14c73c-1623887116926","dependabot-npm_and_yarn-typedoc-0.21.0":"1.1.1-canary-c461827-1623984712161","dependabot-npm_and_yarn-typedoc-0.21.1":"1.1.1-canary-20e4972-1624591415859","dependabot-npm_and_yarn-typedoc-0.21.2":"1.1.1-canary-9c6c5f1-1624761504598","dependabot-npm_and_yarn-ws-7.5.1":"1.1.1-canary-1bf27d3-1625005362618","dependabot-npm_and_yarn-ws-7.5.2":"1.1.1-canary-8ba43f3-1625442419084","dependabot-npm_and_yarn-typedoc-0.21.3":"1.1.1-canary-0ee5b15-1625946553376","dependabot-npm_and_yarn-ws-7.5.3":"1.1.1-canary-63eb4b3-1626046828782","dependabot-npm_and_yarn-typedoc-0.21.4":"1.1.1-canary-4223a85-1626053020164","dependabot-npm_and_yarn-typedoc-0.21.5":"1.1.1-canary-9778786-1627751226724"},"versions":{"0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08":{"name":"@iadvize-oss/opaque-type","version":"0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3f0bf87295ebea41f686fd427832cb424f126224","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08.tgz","fileCount":8,"integrity":"sha512-dwi4IwO+Cfe29qTf3ukDG6VzGRtjCHKMMl19V7YkGATUzNj40xowP4BHYWjCe7YYZsc7mQjMvCZLh/X0MCDHTA==","signatures":[{"sig":"MEYCIQDdxyoFx1FHgGc0cEkUpKrpQp6aJAyXR8Xm7tzufm2sfgIhAMRQqe8hVQxsjPNil7XL9xmuyrfwr8qqPr0NJvTnaqo8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8020,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeNec2CRA9TVsSAnZWagAApbcQAIlvyaFcyilJxzpQVCO1\nBqgd4sGi4tw6gVNe8KDkk6IlGWDhQiCIWhlf53DXuNR2P07WY1IvqZ/s6u2Z\nGWj81EUr0WD3PerQqJ6G74D0mRrcmP5c2i8u59vhqhmXykkPd+FPXqt50m9F\nVx+yxbB++srIoqAd8H3DDn7aGXdAPrdl5OsTUI/60qM3TKJeWx5kswEK8Ou6\nnqYwgvyVzipqSOD0bkS+sP6C3O10HWrhZrzkCTAOWLaZnFLxWyLcbkgCBfyH\np0spYQ8PbiAuvuVnfvuLQdFVWVEV8CoqmW0jtKlOc9uzQBXBadvUOpe/h+pS\namgXx6r4LrYcMsQv7fh9J0EEb/jVG8PTDvrYutW0go3BEz6bqd/FmAs6+Jo6\n/8OiXZgZeKn5uUD1jfyuFZPGtCPDvWV/rL1c6q/erPZncDpU2bgC8jMlYGxs\nnI8EyTCFAk9beOdJvknstxEwEAA6BHX/Ju24fJEGLqa9Hj1qBG+quKVO8jed\n4zxBUiMRFviBbmx74/G5cQnDsG3VpIN8CQdMt9LWwJcZMXbed4as2VLo7qIN\nzBWDCxtXi4N2FkWAFGjSILCEJBvmp3xGrTlGht3uMioBYFQrRoMvqHLfK4TL\ngnGQa6jf50BHghK28IneTfJ6t73MT9Et03Qb7nowbV0UCPG4kXWjMPme2y05\nVhQp\r\n=Jfh8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"3c69bb780cb5da7ac35b33345f41f4ca4bd4e355","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08_1580590901900_0.964766730519866","host":"s3://npm-registry-packages"}},"0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8af3cd8a1b10a4086f2d9b19eb409ec56f7ab6f0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404.tgz","fileCount":8,"integrity":"sha512-TSJ4r9z4rddGU2wq08RPvLfyEUSvBAUmwcf8cqeTeQO4LSm5d3R7Kh2MKBf7CWhM9GY8D7RqJ9F9i6ebiL0cVQ==","signatures":[{"sig":"MEUCID9fXFd8hsTQ2HrM/S7e9mnIm13NRcpZMeKJ4BsPRMQSAiEAqowwg1RbTCOg9j4PHZ5PuvkRQ9vRssU2CWb2sfIDMwQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8098,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeNo0/CRA9TVsSAnZWagAAt8kP/2GgF/iO18fSSPGDqgP2\nxkLycRGFPv4Y0OE5pwIWYxbgC1t9kYelknZDm5zRJ4Av6l2ejBsZUlHpEd2Y\nOWIWjMr4rC8j70AdtbaFjxdMOYrgHXGLKHvR4G0SGk/HPER/Pr4t7WT09ZEB\nxLz2T/NYgl5JqhuZltmDunE50QCavOpBSD5i61nwwu2PmPj5Yzrjku3U0Q+w\nwnn4CKD6eJ30MaQBf8pNU5mw+Q07YZKb+2dSOif2b7xjacSg+jLFWr1gZELO\nTKnPt0sQL4m5UZ1HqvfXQZVjH0jCPy72p8/Qeuz2R+e5NXn2FLkUlMKDFAfb\nD7+okO/LixvfM7LL7F3S7e6O6Q/wGSXoPI9kMGmZ3DtnlTXJKh8puAs3B8xJ\nSuv+Uqc7J/qsu3K5LKi6XYWnoCuELXhAFOEEN992W/WBU3e7IeHHrUDRSLAw\nQ+9pPgGPy74AWlC04MXPnIy/EUWfwhl9Dye+G5Oz8nNnqXqSf6llceKAP92A\ndP4YsTZg1couEZcu749To/T6xwht1dPvIIfTFaSdaS1PfSzNoN6YjUc3w8b4\nEL1Au40u6Vh32yONXpUVMjVQExc436n1BAPzeZyhYTC0hFlzTcY6pCAfLdEz\ngRDZIa9BwEaqJu+SSLcrHgp0XPK+L5b/3DgrIaDoGiX6EKfXqEZNxINNjbOt\n0BAi\r\n=LN5e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[:📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId = \"roomId\" as RoomID;\nconst userId = \"userId\" as UserID;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId = \"roomId\" as RoomID;\nconst userId = \"userId\" as UserID;\ncreateRoom(userId, roomId);\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, we will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fb2a5765290c19bb4cd9749eb674907f2fcd6641","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404_1580633406974_0.319454578583779","host":"s3://npm-registry-packages"}},"0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"60a5abd07595b1f022fb04aea06891040d7b90ae","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072.tgz","fileCount":8,"integrity":"sha512-rKdfwr6UZ981xQtOpOuVNvrcESFo6u1TYqrQ3+nqPX5+Ls2qKOJRybDiGDPWUMongFWevqsBL/tmgf7hVOpTew==","signatures":[{"sig":"MEYCIQDual7spMseZVbOi6y2ckgfqU7933FEgqfBtp1dPhbwuwIhANxemGTqN+q/i3nGDjWtfAi8XCXO8p/CIbzXa1BAJFRJ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13437,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeNpcXCRA9TVsSAnZWagAAXosP/3/3lZQYlIQwczVqkgQE\nOrnstaaPiTD8ywid7gmgjl5T1p3Vs44Sk8UmwY5NIO0pnVwQnx6BqXh8mg6L\nagnrNyeWfDbUpJ8ikOZXY7ZgcAo1GpdPfMLW2tgAslpMA8DaUoURPRS4s2fe\naDTEo0vOZg1AiLHxcLv2dQfZ/KYIJdEbXLPPEUcnv0df2NLZmM2gD+FZrTyV\nob0RN+Hok9XQO8U1soqLLATPEKSTcj+Izwfq6EDOY9TdLrKXwf7DYISb+Dbv\niWdPbIfJV2NxK6bQvf6PD+E3qj7skLy9tPj/6qZPOKgTWbOVq2LATxtKFPMc\ng9kbIT9Hfj7kjyTexkc2uNu5QI8k4dgdnsuDCJWUC0DUJF70xWRnmeRX7kmp\nxbVLKLoRASyJ5sdjNTZajOC3SUlaQNPgXGuhVTxSnPpILIB0+sIG73wasYNO\n8NNgZ5UzF9LKniEDxb/0JghI9pX5kriXMGpREcplBtK+TLHbbss5NJyjQbNm\n/5xr9MmoMj+z44lUkSybyNE+E4r+h6384hhxy0h3fc91CcLjVbE0CprG9agZ\nQHAH2WhRdsKG18TW1n8/S0JV70VdTvKlVyIeG2al2b3nbPryMitOmEZpxFtF\nTcuBMHHZPG0dphSmOZW5nV+NcgrRsqdOH9wGtMI9TYooVJRgs8WP3umTnU4F\ntsfl\r\n=DAN1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId = \"roomId\" as RoomID;\nconst userId = \"userId\" as UserID;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId = \"roomId\" as RoomID;\nconst userId = \"userId\" as UserID;\ncreateRoom(userId, roomId);\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, we will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"be3d67d3e2da2084831a0423b1b72bc7a868488a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072_1580635927002_0.9187814610990266","host":"s3://npm-registry-packages"}},"0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9619697773e5ba58bd03152686ce6dca703f7207","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d.tgz","fileCount":8,"integrity":"sha512-aLVWo5nUVbwnE+MIg0BRPNAeLhZw66MYCYM+BhM0BPVoDDujhnDgo/M0lXNgL9lWGznSrIjW3OU4W7tJEVB0Lw==","signatures":[{"sig":"MEUCIQCT+jZQ9P2+m9USoRW5CuFAnIi797MO2ZhAJ6bQ8iag6QIgAk9CmMg0UD/g16IgrsBAxJSJ+JzpWfZ70Nl16HhFGjY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeNpe4CRA9TVsSAnZWagAA64IP/iXIQYpt3X6kB2P0T905\ngFGQ0LF6R5CeqzVSfbi6aeeq1ueGzZU/+XfVhP6VaUJgRcSQLEXla/D/YirM\nSUJoY/NFgOxXM6xFb/EaMZZ4MsZsgLS0VdaRAjUdcMzezoqtSIqhVVTBg254\ndhrU/TXD6PzPZfSAJPpOxYSOyZz283TcM2m6WoLrg/OwUy6Y53WKsPxVgFu9\ntxvzuCVCtJZu4VZUbijDq+qXgGLDn+QgRGjJ7eMQ7PH1aVLUFyi+AfMYDgfJ\nTDgeuC5Dz5IVmv19a8/N2UM6rjKdAZZVUilngJvaF3ugeETpxKonv0z2H07A\nOVmVMOkH0P+GnkUXDD342qsJM+WIwGqHWicYrTbyu3xg5uyzfFlqGUMDXGxo\nCxuC7J+OImqSY+junslqTgFo5bGl62AhPjf1lBNsezKXap8aGTo6kSgkpNaM\n2kgg90oa4mlmfVuU7VL+BIJZCWkokBVinBSWqErYBiZZerd2+Bou1MhWcfCq\nnE6LPiTV1IB2FRjFtBCf9WMF5VRX0uS1tjfox7refA03+T0Bd7GA95ImJIqN\nsvY62dTQILl+K6a2i/4jsi+0Uxm74EMObTLoRUaUnZNe1O55XvvrkIxGf+oi\nbJm6YuG0XAMWkQppxbQiYXRaiVUMnSW9qa5qZZaeCcKhU9+6hqsK7KH+QKmU\nqXmN\r\n=/FVz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"95272cdb584209c55aa8e07985485988081c461f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d_1580636088092_0.76344447564869","host":"s3://npm-registry-packages"}},"0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"89b40dba9430cfe76b369c3bdc4d07dea10802c5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082.tgz","fileCount":8,"integrity":"sha512-QrAHeAYi1wdr1uSVFtMHkUBCqgXZbnI5FRL+Gv8uivfW525sUlzKcAbpbWhsJf7Pg8TR8bjdj1VZnb0ALsjNzg==","signatures":[{"sig":"MEUCIAEh/RpCDscAz42OY0XTXCzIUnhdl6vnnnAkUKm9z7nVAiEAjp9B1QzcJQR7av1/IfYkztrMc8fDkUtotOQaS4BhHjY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOH3CCRA9TVsSAnZWagAApy8P/jdehiDVTqlBIkQ/KvT5\n+YxRJW9Tcx4hAFSm4gn9OfPAlASOjFnR3PSeyTIYs9/5fXS5TADavN4+FTYP\nbp6/iyyjmr9+b6FLb+d+N4ceAgpMc0R/21Cg8MY94CpAH0B5cxO0is/7JWFo\nlBfcDinPSi38BYFgO+JicbwfQYK+PN9SQ2v43TFO9LRhCS2RaAGbogcDXxw6\nHH1DQgbzY0OqfI4qTFQV6Ca64vB/0JYvyCexmLQMlZADlJPqoIosYMg1gQCP\ngKjT2sFqHuGtvIZZ7+UiAsUaqHR/BXCmoTRi+RhDYCdi2hL6s5JI3qE3VjrD\niMfb4sTCjhTftABdxHvWXjWUapQCcGcTKiy2J649wWAjYRXtQ/594sXT9avl\nKk3v4HC9XfPoo1AQ60T3vetja4CCBuVD4HPZo+/pSm2Ljg2VzLbIp4dDx6dR\n7AloUIDldmzEJ5xOKnsXL3SZYstoGZ57fw5VU0IHMbJrSfgWhHSqhbmq79Cg\npIlFOO5x0DqcigtToy7i3V1Pq9VC4LojZsthCK+0gh8KIuBiPUGx2KlifRAD\n6BZci/PxsKGq+yBeghm+z9mGeI7+GU6LCTb5hFkImKwphuVG0p3hzeOQyoSc\noQJ4TQF4lZPQWHjIH5XdeR4VWR8sxJqpbBPFLy5Yg/wqfZZd4Jp9VYWxM3Um\nqTNU\r\n=ZrQR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6751d66a97900a3e90cb1ffebf3ce4b57f9fff2c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082_1580760514103_0.38993520199272647","host":"s3://npm-registry-packages"}},"0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"12226777634de1e3dfa9fb0e7c70fb01fc509fb5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac.tgz","fileCount":8,"integrity":"sha512-C6XQNCexX6KqtlEkrWfjJnQQcORZ/FkdRZ9WgGFBmOp4kFAurja3SUooNRFc2RpKkjv5EGZGWrPMl6IrWAs9Aw==","signatures":[{"sig":"MEUCIQCujF0hpjC8VnmwVwBB+MR68uXMQ5FBp28JQJyIB+/U+AIgdONxcqFBtdLfk6G2vkaKMf7kgrM3guWlz4RaEU6PAoY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOKlmCRA9TVsSAnZWagAAbVkP/1yseAxszDObLF0Rv8Fn\nMlRzLkaGy+YaV7te6IbP1FdnIM9/k4z2Km8jr0FIPLtwIx+FkjrL+RgO2Ptx\nUwWR5QrmgsIX9zkKN2+jZNXOcLa5Cw+2fRrahmGo8kwwS9At3pPU0GrlBmju\n0oQpUekcIP2Bz4Xqmo5YVVtEF/D2LhhV9fvF38KqUC4h7C/2A6+RAwY8WDn6\nySjzjEkvjqBVz1DZ3IpMf5Hhh7g4elahSgRRGY3FKUSRC49U4cb6qALnSXEL\n1lWGnH1ChzZsrCD8ULvH6g2IqrUcMdpLGuAjmvz5Jm+tshoka4fG0gtsVXp3\nn9IPWlN9irm+1S+nEjG4AWZdtT96Ojqg5YkuMDfpvu82qjiGBY/Z5pBxhiar\n4OW6FqVv+xX6C+ren/oFDevMy57eqhFr4FUXbJ9IsuDDDZm9TbM6rEeVVCXo\n30gQy9CjgzlMhPUpsjdMvdPBXmczChUGJLNXpMuehCRTvxL5xhHu6U7MTHUn\nnhMaT90qifnjz41wNJNr3UaO2lOXx94w4P3gOvb32REuHQbw7LXNJp/ITCM3\n1cGUroyK3iQqk+MazvGhBwx4t5vmd3DYT8UjzZxrb+AFGW/G15uWll98jLIf\nWJwbKoiEtNPdhSFqrmuZFrmLeWV0CK1RsvzDhw+YsByC2Y78DTOVVrP6uQox\nkop3\r\n=B2Ip\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ac34b5f85406331a27831295fdf24bea8a1880f0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac_1580771686104_0.9519290762538215","host":"s3://npm-registry-packages"}},"0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"032cb0d13450d2bc1958a3875ca675448b139c17","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce.tgz","fileCount":8,"integrity":"sha512-m7mfaDMxG0oM4DiWRBiJ+6jowQ2435S630qmTuFxz/wJzEt3B7m9M+9SY95a03KgEk4G55NZRgWlAsoUi2CqVg==","signatures":[{"sig":"MEQCIA0Kj7QdErF/AqJvs3SlbQ07kJFkTzvgcxRxzqrRy83RAiAIQ+ZPZMGKb+Rk2fsmBzb4tWWnFB9NXJPeTeElLzRQdw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOnk0CRA9TVsSAnZWagAAEK8P/AhEBtZQ/cFxDNgS7y7/\nrZO3uq+LSBg+8vjngsUVN8Pj//vWtq+wyozSpjNF9zSYhVsRLzEPqLDYdXb/\n5RjjnEbCC6jOj3mbkqhLAmLmNUnb5a628MeeGkxlK7Srt3DUgbvhcqhLpsdv\nZq/KQMsimU9j+jdSBcf7w7AYgYQVodCMurD2E+LuiLkHa8BGoFZ+xyjKb3dn\nNG/xR7HChFBLzWYrYCM5Y/y55O2l8hzr5WE9XKo2wpm181/aJuz9GlFxpj7M\nNWStemyHr+bj46Q9QBUllnEJnvP7tloj6oGaNjTZDr+zO94Trgej/UFVeBLp\ntqi899YVrJ9qSMOZO0XvkdnW4yB9awoQoDiRrTz0FZ+aUOIwkL9c65f9Vvbc\nPP3smDbYZF0plVMvIOmqiG3OocdLrs0Y9cMPZviQjKJPOLIiwD74UDn62SkW\nyOz/mT4Twkj/tGHzqvogp9np9dttt3sY6vNGY07TlbPqZxabOFgliCHXml9I\nqI0tH4/GEVfopxL2+3x7iahbRKf2L7jCgDdkeb4daOV7fauAiAP05cgaCLkt\nplUWMEqiQ3s7QHqNH88LoCJX31R9bPauiPOBnEAKnouZBXlNzgslW7vzGBzj\new2mTAYY/oO5O4Rz6cWwe4BqQ3lDIB97zMb5efiRCsBX+5oVKq8/jeukdsWw\nlqHE\r\n=NM4t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"64e8946281959b7002d5a776128fc0835fa04070","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.0","rollup":"^1.31.0","ts-jest":"^25.1.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.1","@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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce_1580890419921_0.4106510717590466","host":"s3://npm-registry-packages"}},"0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"07389f60af8c002d53e66425b51f7e02a4034ab1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374.tgz","fileCount":8,"integrity":"sha512-LO1+lh1Shtdq1za9l+9xf9tgTft25OT1Dxe+opqieIUC0vCnBA2qIx/QwG/Lyok0DXoXJ2Mik+/FGtc6FCEaCw==","signatures":[{"sig":"MEUCIC6BpJYUbyCeVnnA9gZ49DOAMBVSi1OQcpup1dJeCHfIAiEA/zdGG2MjN5288Z7TXZAfZl0ex/QnVmlMUDgPUICuVpg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeOnniCRA9TVsSAnZWagAAAvsQAIFmd74OgMqwJd5i7P5A\nLXJSIX3a51gh0UQ+sTDHWXrkbHxKj6OgcWPzWPB3pRtuZuUIuOi0QdOxkM24\nYqo8ZRiS0HxqVQ0Ru1u1XaUbYlR7hU5KOwzKVuJUVD+xRRzBF71zZQc8pXXy\nSQiDz67rGBfSZms2ZRlwWSKz5YO5bXbhqbvpXsDP1+LrkE7QvYKtow08CWEL\nb0rBW6tZB6mGke6OHJvavOMystam/tp1YV/goHrAKyhJsw6ClAtZQbEQGlFs\nX6B9+hBYXZfEaumJuxRtoAq+kQebhkAeZT1Exu/PPJdiPFSjZ85++coGYOUw\nF7JGaQYsflp5vuywFB0qZ3PLjgXVI0gny8bBHAAexPA2XjE8QYh0H7TgGCXp\ninRWnGsqJfVTfIEGNrf+f8FePohtw5lXqbySUjP6PPDrL/TqylPGTJZlNVgm\nMH5O+Bna7Ny2ovHrZodcgEuozlUsyOxD78MNBoeB/z2i/TSlE5yFwi1tZ74q\nd6gDGfw2+4YxqgTsEIrad7VMXRWp2UEAWlZ4LAiRUHUXMsHpOL1GZ+aBbnMW\n67uYl9Hw5M6AUtBXkeiTysXftdk58Tv4dHzE5FvOu7Qi0yqWk8iO5cWv5Iic\nVAmgTaeICUT4xcY3a/A2S69vm2Q2HSoDV4VJkZe1xUsql3RtrVfqFyBuTRlt\nMUod\r\n=LFdj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"575d1b14e24a480177d6fdd22e51f58bc1901cfb","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.18.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.1","@babel/preset-env":"^7.8.4","rollup-plugin-terser":"^5.2.0","@rollup/plugin-commonjs":"^11.0.1","rollup-plugin-multi-input":"^1.0.3","rollup-plugin-typescript2":"^0.25.3","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374_1580890593641_0.20679525305222923","host":"s3://npm-registry-packages"}},"0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b6f2ce90f3ae6a79039c9d31b5084cca85dfac38","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577.tgz","fileCount":8,"integrity":"sha512-+NSsIsNJzpKQEh+fpYP61NwC3n9hPH5wtxbjXcLlQjNap7mzILBzlWugF1rvUtuTSxbtHIeIkipnjyH5OxokAQ==","signatures":[{"sig":"MEUCIQDZY1i3YYhR2Uh6qZ/9o0dB8D2oSq9Nwqid9fNuFapyHAIgZKewTiI+8FD7rt8mWuXzfC9Br2TnFqqojuR704WkJoU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQCg6CRA9TVsSAnZWagAAubYP/2YgBe0Vl6w1R28ODzvk\nfp6xNLJjA06KN3XvtU8A3kAdYaumi/DLD96H9pe4wTvsM8ezaGzaC3ILf8Ma\nVIdGQScJjg9m75mPPhNDeFrkkF3N+hxBopgQemqqND0be/iLT/+aq2yQbG7k\n+b+1Fpj/Gswc4q8DMSb5NVyYlz/iyiNQdHMP7eyRFh6tC1smRA1Zj6AQB13K\nFLAmw3gzaNFJ5jJ1OYhZYZCQWQL7p3YzAbY8hy3MkC/yI4AFv8Y20XSGNDrs\nNgiUgFkvJwXu6QPKC8d6Cn8iKhoWi4TXlIcOUuI5+u9Xzgc1n5HyE2EvEJzj\n9BThdTugpKaV5Qd+KrysVyYXALQZk6HinnpXLUH14lgkGqCZ0Rn0YQoJ81B3\niDJzfhjCEiT+pZwrWPtz+Nmcu/tYuVSOdOSwYzkP6SLcIa9EjRqkItrGkZbE\n881QWqRry5715uy5IG6pI6UWRB1gaAUnstdXFGOVVlDNOnQcoVqydTkr+Vlm\n0IcxeyNPNsgoXOrkMKTR5wjvRT8gSqeNsuILWRr5cbAWUpr5+rCs4SwgjpIE\nfHOKdQBClCIBuxn+d6Lm4//Z7OeNN9xgZPaU8ZLSCbuDKcvFDnOS5O+UBihL\n4ClXiqPAUbDTSw7WJPYls09XaqORKupAX2huPSfqElwvGS5Xv+KUkDffBhMu\noG66\r\n=NIAh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $m = fromOpaque(message)\n\n  return toOpaque({\n    ...$m,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7cbdfa1cd20a90bc9fe55df6ad52378bec4d7636","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577_1581262906315_0.30880235992434857","host":"s3://npm-registry-packages"}},"0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"565dae10440d272f0491e6cb06ccb3578936bce5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a.tgz","fileCount":8,"integrity":"sha512-Ak/hsV5A7kkG/eezKzlzYtkbIWm0MWPduNP+xym32yVV//5LidxaJ0KwpTQ8Vddy9pqL7VYtZfG1O10n478wJQ==","signatures":[{"sig":"MEYCIQCqgRmW9zbhXeePF892wScudikbQyVFRsy4hSPUtoNOTQIhAJNRO5p63ZbDohkgyYzc+k/MWuN50eTovB4EDsdSFQhY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13466,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQZU2CRA9TVsSAnZWagAAVaMP/je3aE7Y4JE0IcDcD++h\nOZliF9PRFn6Fz1XlWm7iVZK7NE3ooHTo/Q36UsIQJaoQwqpOoo5nmEZ85/wP\nlljw2EduG330ev6zQwuZMMNBx0SbRGmz/0m9CzBoBLc5WdAV03hm4u0ry5UF\nkkGSbFYPDOoG0gWW2ynhNpI6xnwWBThmutFnzz/NaOoVJp38bz0N5IsP2aoH\nfzKm9iukHSeHTlcqcwRkTSRi0RBkKIpdAoChjboVFbGID8qxsq8+91Bay3su\nGWFhbv9ZI7O7NmwUdqJuySBw7WVpwPZ/0DIYZwxIaZRqk73u834fiE3SqOdq\nyiBjeNixKDaQEINBxajy3v+vZZsO9xPY5/9XrJqcfkOGOn10d01jAaX2WMeL\nUpSYmt62l+9ebTgG/r5bCSnq2FZzR3qi+qMsCP45hpBmaT4bDDYZGwdk/MY8\nwL/sA9Az/O90ssfWh9ufXvHCoZpRB4XPVX9UNZcUt4EOp9KPg709w1gdh3Lv\nPOH1g7MRZWIXCOjdDCZL6aMt5i8E6y+VcilOTTXDziEsmoNFOAVov7FQG45o\nF6nR19w8qfYB9UQCmGbzk4YI+tSmHYSpVUGQ2YHXNAMaVYwSOmwq46WD+b6d\nYcYgX/T4rkNRZyZeL52+JheKTpDRKzpJq29LR5Rcc1RS7JPZHYpFmvHiNS8K\nVuQY\r\n=8DOy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f7d188247081355cb0e55e2526eb6da3305b4b9c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a_1581356341685_0.5851347396947093","host":"s3://npm-registry-packages"}},"0.0.1-beta.6":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.6","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.6","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0a3c5f8ea6e9803b1fb5d0e54f0a9c4bd5e1b4e1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.6.tgz","fileCount":8,"integrity":"sha512-lbPuDu+xqY70es2bn3ZwuTzs6dl4jLTeEU4o0qCQqR55+SuCRMJoyL9XVniMwCDm0nQl2AY3TcJLjeVVyIiL3Q==","signatures":[{"sig":"MEQCIG+ns2qZDd78yLCTbHIYVaQZOQ5vH/J/YU8xewomMQxCAiBbA8iFSSKrl4rDKIfPx6D8mWFc6SLIcFxq/WJPY4OFgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13418,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQZX1CRA9TVsSAnZWagAAnEoQAJQBVWu/IdpSgY1y1KMI\nS2c6EgotMSC4f6hMqe/uqkxT0on14lpAVZW4/r28CJqICshzKWhi00FiCD61\nBKeYvgpPjAQVAQEcShaY2TB9XM2gj5fAGtCKWEU4ubkpCJCzE9VZPU7AVlPy\nGLZQTRrF0vTKsq1mUoMifEQOi5ySaclJikL88nbnrkV/zFeTSZ9BmqucDM0h\naoysXuATU3dYLQUFG1Aj8EFEnKcvFMrrgWx/4IFOKsAkfEGp2W1yTWjzGlML\nFKPYJx5JrAv58UMQm8I9N/+Ed3CNYXkyS+djwkFxFbfeuq/j5pNGjBk5rdNl\nlSvR/ryfXX7hyJaQZX84lgOg5LOMeyZYhjUc4VeZhX4Pwhjro/EhycAMrbVY\nseX9p5pd6b9NpJKs87l9QFA5FCvmS1RN20+Uyss/SEQLlA2hFQ9wiW1OUlSG\nQhVWiTOGiGgC54c9FoyJVXdFPPzGDyIYXR5+Cyzduq/9r3rdhs1cd78og/vU\n4roZuFlylnpMyE3NrwgpLKv18vfsuionCOpcQ1tfS2y+wFrL4MCbeWhBdOy1\nrtnRy9aekkIynvqU9ZGI73vy7dMxQ5WmIh+WBcM8XGUl2/c4L+ng+lE2bfkT\nIdPEsg5yosOayMFROGB639Nl2JVBz1xsaXv1p6Is8fa+03dbCtiw682TqMBF\nnDvB\r\n=3emR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"53f661a5ad4f2a98a6c2adc27ba7caab1583999c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.6_1581356532555_0.28482276145938323","host":"s3://npm-registry-packages"}},"0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"53cd72cd94ecd74203f2af53e0dd5fb3f8093ba1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc.tgz","fileCount":8,"integrity":"sha512-Mfl/H5QupTGsjqJVBCC21hhwdETrLI820FswUoEWSmW/vNHUIIw/nu7cjUXEmoljxnh5eTD9CxwksEuSLCp+hw==","signatures":[{"sig":"MEQCIAe3p4xkUhJdGx6ZGC5vbhbrQ4Q2Z3y9Xmq7XqJsLjvlAiAOK3u660dGSXogP4IlJxkwjm4S7tG6yjkWcSAi/0Sfpg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13466,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ0gdCRA9TVsSAnZWagAAIpgP/22Xbx4cZcpMbWdBSZQC\nJQrYfl9dydj0QYVC9iXEemZdmKxSmoS/cFLs0aKwq65ys2WYIGl5VAJEmM1V\ntb4Katat5LqRieujoSniI/6gnXdBfzUDmwa9uatIKTR6Dd0b5ieCyPK/Adyd\nJ/1WUrgjIlmt5VAodmNkqLRwY8SeHsMHV3KXrf0aK7S2IzekietMfcKJ5uRE\nF/2P3rba3lOqUVs2b3vQNRhFbARDbLPIziC+k6RghsMZXmt/elKKT1sq4sso\nb2O5Tm1rsZLw4fPh9knbkrup7JBYfM+9NArzIgTVNOP2A846hU/U1H1UGDCc\ncUq9tm0ykzRjinWqNZricSenBBAcN8qLuvE/rLXNf66vkgNLaG0ReJyqmgl2\nzYLInPiIIl9CBt5RWIdFOvjElhIg4W6O2oUgdrJoqFaOAWZDzMWkDQnD5kZZ\njlETV5ZOsQtbR2Y7dIgNRzJhg/cgHBUYZvrdqJZgviFe/lSW46sPP8ys1+O6\n3QLDsudmv6pmZZtCOy0glLiosSXMaF5bLakgFeNw9xWP/fimZBP3ineWTz/d\nIkZlAJEszJL+451ybITV5prke7vINOuBeacVbcuG1eeivY1/asuX4k7r9XEH\n5C927NsDWXYcGpahnKJvtLtGFlmhnl1RcgxHJFbas59AdhBXdUN5+1U5m1o0\n/g3+\r\n=C+zN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"16c75b302edf8c68c8bf65366152829b75eb0f5a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc_1581467676971_0.5937931022983183","host":"s3://npm-registry-packages"}},"0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"843ac2d65988ded22efd09d4a539d6d31ca950d0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d.tgz","fileCount":8,"integrity":"sha512-lWhm90fJMsq522tG7jdo5jAT17DpHto1k+wnY+jAMNMNLCpRT0i3pxyrEe3SNzcYKx5i1QruSULY6iq5JeYuTw==","signatures":[{"sig":"MEUCIQCXLbpNQC1gw/+7B8o4RzAH2rMwYWggSOFa4bdyITW/vQIgU/AH+u9oRz6wye2srsyGms2IdzVqVkDd8e057AkmGjM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ0guCRA9TVsSAnZWagAACg0P/1wAL17DOKFIrTlL9ABs\naGx1qD7LwIummMQ+ZNx6jGrYLQrvSMisOLcaiXJR321oIv/epRZPREzyth75\nOSJt41YaTNr6WVCkAepWHtMUMoLdAToRt1UWkhKwX3EnypFEzd5ncMP8LYva\nqfXLfy++O0YgdpjeDAnQ2C3iFXHpZM5cISOTeINSfsORgmuifzZdveEJo72W\nDRiDi73mRe4qJ0puLnNBvA4FZej+xGjfdttHEy2JZqbhH4Y/rFeFRjFwpCHR\nRZ+r5T4WdtckBXgueWNuo6/tHLMrVhvfAIB2KoxfA4BvO4QROl5RwUtzXSjH\neRVAVPmV/lXECgkUkNUZqJyjG5dbd596kfAqqIdp3yB8GKwNw5WcKS+6V8VG\n8G/DEqUePjUDtrfAw2luNEkP0ixO+M/BycPZa4MhRRpllEDjGU9AUrICfcVm\nYNeGYh3OCmHPXdnNbLDsbBZbbw+YOx/fgeiqb629CoiIzN6HgGHe5WI1BmJi\n1M3d540bcvtgVggl3JGg8sir0pO1PufPTwiTq3wtkBuOCcix+7bmgt29gES9\nAgRL2xhz/hsj8YqbrIJqWQ8Jv8zJ/XMTIElIMN4+2dIrBtf5OtsylcN3nrwI\nUavfW1dmv6ivgXa9jZgY0pQWwcq057xlWFfN6vzad7IMsu9zNbxs15o/CAzy\nU1JY\r\n=iRJS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6a67d1eb7a76ed259ffbe8514342b17897c8b942","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d_1581467693945_0.5565458510033501","host":"s3://npm-registry-packages"}},"0.0.1":{"name":"@iadvize-oss/opaque-type","version":"0.0.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c652b93b1e18f91819fb30b6f268e31cb7fa1b88","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1.tgz","fileCount":8,"integrity":"sha512-arPti21PzAOPr7lDn1Z8KVbwh1LIzejrDkRbmRlvc2E7LZlmv//bYBC7dpJjS27VlRKNY1a47hlgARlisqovQg==","signatures":[{"sig":"MEYCIQDkw+gJP0Hq5eqrB7z9RHW9Zs3DofUAXK6yU/sWPxSkCAIhAK+n77QR9+VgxgGpjWiscC716iIvlrmq/1xFq+aCzfsV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13568,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQ66pCRA9TVsSAnZWagAANIIP/jX+TvR7S3HVjvQioOZj\nUmPIXS1N98Qqhl8LvLaNMHFyHQ9XeGGfsYbop5aG31MekJcv0roz1piLirsw\n5psPLAk5pKy0sddKKcnz6yjnCDcGOkkiTspsGdOhBHyJT286B+FiLLY+QJdW\nq70gbSh3iV/2ClES67uMGyONyk3V8ECjoeFZRSmBD37HM0NyEU3euTP6C0sg\n3xYF7TERY7czsqYkheq0G5dfxqGGx36/dyDF/uHoqoaFqkuUBcum0xBZoayr\nHs6GIVOcmpjQ/YPdsZFkBeF79IrpJXEhCYdYea29rBR/a3kdKLfKvTAbsQei\nRcQ+ITaCFl6/6LOYogPX0wst+YfMZL1hVUmGRhskd89F/8nqGlyH9wnKglpW\ndHd1zBAvISBouhjfqpAbL32FhyKKWaIGfkZazgttMQVsxGao9UkVuul3Fhaj\nzVC2MnsCW1f/Zqd0z9ALdlnM7dt3lI1JZxaOy0g4BYdFyLySzk6IGRAMEqMm\nppYw4gajyVuek4NTkdiHO16AQuU1O5cXmxa2hFqAighSuZCPURAopOJwuS5R\nGjWcphylWYHGgdMhMrJIwEUi2zgmbgdCv65H8PrxxVQTgUMicVAFB66cXogG\njen9rF79a7CJhck5ixGL3bcao8pl1ipiH7Wfc4k+s74kVox/1RRjViUJuPTJ\nPHvO\r\n=jwmD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"e98f20722d5f1f90567ed3aa469a429cdde73cb6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1_1581493929203_0.11438419031395952","host":"s3://npm-registry-packages"}},"0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f":{"name":"@iadvize-oss/opaque-type","version":"0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9dceaa76de11f42ab3c7ed3ca944353fdcada2a2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f.tgz","fileCount":8,"integrity":"sha512-umNZncYk8hDBUJIX2P1vgAb29jFGtMXGX6fy8EeV/9cEpCpNdwolhub+zdt/eSi6VWnSSq8vHugIISDvajh6ZA==","signatures":[{"sig":"MEQCIHwoQvP2PSYC3ZCxYszrVlvb0Kct5nJewOBWC3r6wxyUAiBw17lyUq1OIprycfv6NP82zWtAEmNwXB6HvFGC8iPJrg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13561,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRGEPCRA9TVsSAnZWagAAr0kP/AibminuirjVmx6TvOth\nx8ne797ySCIHp7sek2H8S3CP0FcJuGPgaxBpNPnAzM/mX7K+PztLioD7R98u\ndN/2u7s2W3UKVCGwwtOcAlP/XO7/q+NeeteMwXgy8tj4vaOhwpoE7pMKBlBT\nlkzE80rbtcEwuKaZiH09mWUuYZAZzfPVG8TW/5+SVXG4c01Sfm9o+d8Fszki\nSiWyvT4lxV7F5OnU8zO24XjRF/PBoChCWE0s5/4bXx89TZOx4X7RLZNwMeBN\n16TAuWGTVEk3j5jPtqr5qgzMhDHiehVJCz4pLimLVzUmJCJCPXaQ8FmicxYR\nYafn7H7I/rN06NfurBtgYACfELhznyRCR4JQ1nAtX3aojN9j5N0OQ76q9aWN\nEDktSI9FND6kKdjqkHdA1iqF6psiJDdleCqrz3dwv/botJfOAHcLFxsXmiL+\nM6nFafT/RO4xozVUDAm3vjOyNFKzt7IMyskHPuf+QVOOKJ+PD1pTxXLQYeJT\na7uBnAOgqT8vixC9BVgw/CDZ0MooC9YyRkEk/pQSdKOpgWSbYKmCyZWvGeeY\nhfcJivryDb6KBDBWvKiFvay6T7wdH/Las0kI7HqpPENIugDXjWnAUfArOx0H\nJ7xR/4XhoLwlri+/k7NO3sgKrAzQ9WXQnuBK6s38naE6x9hN7dO5+RTjBr3g\nT6L6\r\n=rl0F\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2379cb86cae28d08ace83202c498c6e8db09291c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f_1581539599000_0.9183965852625837","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@iadvize-oss/opaque-type","version":"1.0.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"497a15a309467fe05c776e93bb68e674dda236ee","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0.tgz","fileCount":8,"integrity":"sha512-XOGqli8Cb2EPSh+UJ+vb5Ea5BhX+zNkCkSbjoFr6zE13T09cjivP3dfK9sayyO7OvnKLxNT4KuK6poc73zFB+g==","signatures":[{"sig":"MEUCIQCJhxbmZSL+i9Nu5hGFm0/znLBbmWLf5ePBSnfQ+ZT9nQIgYEhJJ1rnlZNL9DWeG7Nl1Oa9pj0F+eEJbRi+2ecb7rw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13611,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRGGxCRA9TVsSAnZWagAAHZkP/0iwpNaT4NgEZgs/B8nU\nOkD1nu1lJI9LvSyXeHeZVT6NgleYU2kgvH4WBCXbDIhf9zq8k+CxR1hwrE7X\ndWFTfRg6YtlWmFgo6ripPdHqHYIXph7JPBSljYakceWcYmcEmgZpVndALI82\nJ/RHG81FlUHtzcBLV2KtthgS41O/trCkfA769hry/QNe++NIWE5uo+lAa9II\nIj8rwytuQ7XeJZLVH+RiKqCWXvVhcX5iUCreMjo+quDJSrRyTK4Ho0Wb144R\n4BbP/9EWsY/lpb41ycYqBeuRrOdKSUm4QmlR+Qqr+rtd6+oV+bwUEmFfv6mI\n2g9HALLfjUnKh0r0KdRn2hMKdJ2JhCMtqYHPLhUJlO1fb2bwUzOtVMy7y/Go\naWQfzxsbeDd8ODt8Wpn3n2s6RQxoAT5+Kcbthc+4/LXHXpkeaqgxhi8dDTZa\nhM7hq1dOfzCseRb/N2UcOJti2O21NnWeaoateP0plMwIbP/3eiJIffcXT/Es\nBmprCPbQ115Apj2BSi6eSDTHrjs/eTqIZ54tDP2ysKFqArFkR358e0I1VmA8\n18b5jXQEqMnrj6guRAVKAQi8NUltHh2trxEWk9TUs6mHlqZ86hEtf7GBHJE2\nxrwrkuNlHib1nOP29Rp9qotBCcl2SRUQ7JSkEJuyvvjCjqOOslaFyO4eDaLb\n6shQ\r\n=XWXe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"c8b72ac1dd2417ec6abe12c114b3066e5d33b09e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0_1581539760725_0.1119023055739754","host":"s3://npm-registry-packages"}},"1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e":{"name":"@iadvize-oss/opaque-type","version":"1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"795ddf22d1c992fc0b7285495dc6fd68efdd0fa9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e.tgz","fileCount":8,"integrity":"sha512-5o28YokabpQXuf37Q2HZcLNhvUoHmerPZCv6lt5R15jjQd/XSBo5++SUZ+U00/H6V7wZEuQj67wtZVbbfAUL/g==","signatures":[{"sig":"MEQCIDewBUmpVe57bOrMm4qvTog++EQriuKz6Fetii/TvN32AiAfBxx2l+Q2wBBCOanS3crKQr3hJvDI7XIIwpDiqjWjgw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13659,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRk51CRA9TVsSAnZWagAARooP/R0oL1RDkFOiqPvs2H54\nVvU2spJgoyhQXuPvOt5N/0v584OhBh2XqGPFG5SEEU4sdg9uvEINqsCaSRp1\nYSy4q95VUdyC1bor6G25i7g4TVNSwiMsYDnAMCVD+mFBdKpfh55hbcd9UXiT\nYxEe5h3flj4lA8JcDRRL1oTbGh0AWTcxQamCcPQo/KQN/9N+wFKqmoC7di8O\n16GGR++MqKncGE7m66AFMah01GraOYKq0zk/bWwDmC96TGDGg47N4gNtrOHL\nWSXvr9G2wmF0MAa+QMKEbGel/wwPod0GyU9XodWfcdQKpmjbJnVyOJXy6Jyf\nf4nco7zwHSVOROmnEe46Ho4h4IyRgVtik3Zamthm43XxEWtfOx6L9A9FX09z\nrhB7hWH2eQom+mDjTlD70iQRufYZoft2bQdpwldUzJ3VmJ2TvmiAytvedMuj\nshfhWxbPsc33iI4L23r5+Dos7eOF+RlbZntN7xX/8IbYYyUpZlExG5OAEqWZ\nJrZe21Ktzh3BwpxI9q2e98usG6vZXVlQbqnPib+XZww55AhWAO8IUtbOChGL\n8sUYYt4d3wQb+YgFMS25oyfEbEcqEBrt/BfaCjcug0Z32WptE7T+tCza58wS\ninMVEBfvhseQ/VDsEbC2b9RCTGXOHXwCy6v2yfCC6G5UTkc0ZC+jDHG3U3Qt\nw0Fn\r\n=LoGY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"eb7c8ac87e4c7a4408526f76d27329272f54e3b7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e_1581665908972_0.5817552522632374","host":"s3://npm-registry-packages"}},"1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050":{"name":"@iadvize-oss/opaque-type","version":"1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"12711c55ec607ab72ce2dc98545592ed5467468d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050.tgz","fileCount":8,"integrity":"sha512-URonVFXpzsvMvDbRvCaZuXpMeDv5GbgHvhUQCvqLwZEWt1EjHHmB0QC5PbJyhoDCxioX0y2xKXkvYUoI0/XQ3Q==","signatures":[{"sig":"MEYCIQDH1IdkzY68OuzWFU21CM2yY0Xv5jrMMKk6fXoWLNmYAwIhAOe1M+kwvD/GA/urp8vVCQHHq7vdy1+pQOgqb2fxotjB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13715,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeRk6HCRA9TVsSAnZWagAAhgQQAItaZRzKC/HzdJHPy9F+\nuOrBZDC26HDFEMwSZvQxAuZi6EgttAWRNR6JCours1Fu6mDGhQv+1OQlpZsQ\nvMBvUj0PNKzLFBL2cpUJ/qzlbtqv1Ohi2VkiLdHI6EzYiXpSGlqLOYaVlz3K\n2IbZ93yZjoTCKoFDHUHYc1hCCHpdTCwVfO8UcHGgBdE19L9yX023zG/+ZY1C\n5o1HElVtqwwhVhR9OSl5h42LmtcOsd/+P3RQcbs/HyGy5+TPBe+n8PzEqmQ8\nI0W2MuBJDCsaLhCuH6fYkeltUW6w//cQaDQfnLzhAKL5OeSATXnFrs9R/90t\na2K3dzLe+7or3m/uinTkMdqVFM0ayKQEbhMCbJbhSoVrUN2hUlpGqVoHqESm\noW+DGuHCU1T+T/h66vZTpx5Jl2eyeJibP0t95joOIoitjni6HXlONX0V85Y6\nD5hnFQcFo+Hkw/w1m/KB+5NRH/CwJbHciD0Lz/veEFgfuAikd3PI8VY+UFuw\nWUJMyBogOEMY6xjj/9eXn7Cpys5gWygBnDVxgvOgiLWhx4mU0P1uv7RePcmg\n7ETiU9Cr20WJwSD1qEXWm2Xo9hOApp8NqkXO/ivwvRO6BrqY+Le11LArukoT\ndxoGwhpKqN2FTvHgLIfOunsZuW3SXdcaH9SXTTRyK7lRXbfNN551Ni8QbFdm\nH1CA\r\n=vlZN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1ee748fae4eae53d8c875a1915f27e8c8345066f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050_1581665926814_0.14451518098278648","host":"s3://npm-registry-packages"}},"1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f":{"name":"@iadvize-oss/opaque-type","version":"1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"90ca7104ec527ec31f5a9c6ec88fa1acbc72477c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f.tgz","fileCount":8,"integrity":"sha512-f802tI9aqPN9RLSmGKwFHgUzFquMUj5IpnKRjPh9frklBywj/R12Tfcsm9ZkG5ZY55vN32Ar/ezwHFmpOULWAg==","signatures":[{"sig":"MEUCIQCMLsIs5H3FbWNDTHBkUQOQVUsBGRS/+yEOedDIjmxBzQIgXVOjPoboTDQODe0BlPSEte60ChECg1JcsdNEVyj0jtU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13716,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSM/HCRA9TVsSAnZWagAAjD0P/2GOS/X0cRLyrXZc+3Dy\n9WhCgTgiUTF+rUTpp0kYdkyjAm0jm7Iil46eUK53kFk1u7nhfEsikDdNhhP8\nNKXMu1SUPob2lIVQXS5EY+KsOTnETOyZfpgUejxiDK8D9ZndJ49xZJZV7mfE\nJht2phCddiY5YdOOA7pMCTXAL/1NYFDP3T7TWsTN1KFMNmd/5if1OCzxP82P\n08iLaQUSE9w0dRHucKYVGShlH9JOc2W2ZjCSX+Yca27AW7kEcfrYH/HMXJlz\nfI9NMWKDDh3ejlqkYi8DpQCCY03clkxcPtY8jVmqPFmE/tuNoJo3x2vmpgv9\nX/yapjZNqJd2sDiSor/a02rz198POvn5XJ6WNUjOAzkl8EwFDheeyefnAZvA\nkyVIaWL5VbiJvKb8DvaCp17UzEOZzkIEDM/5Hvza/R8W+11L1yAPufyDgkud\nCfoNMIFrsqg7o10c0thqGzsF4w+c2ubz7q2GVKHaWG9VeoFx1AMM5S11Slo/\nFXZJaBOOpGaP1JHfCZDfBCzfR2cAIBS6o18vvg9p5DIVae//iLTxJN5E4++Q\nPYg7hMI3NPEVIZ/ItXSLXa22qEQCfczxpxMWCqfcOgAuFJuCc1b37u5Dd0hH\ny2dA6VVs7xxrLJ63l3DBEaP195rUhkZ+/85rT+v4LeZOwA9IdL2KPYSh23Qy\nAV7f\r\n=mY7q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"885980df6271587dbfbb1d9f8637afeacf07ce98","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f_1581830086981_0.5942370143265288","host":"s3://npm-registry-packages"}},"1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156":{"name":"@iadvize-oss/opaque-type","version":"1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"76403547c2e4803aa68faaf6c74ad8c4275d3c23","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156.tgz","fileCount":8,"integrity":"sha512-tcCDHXYrCt4j+rV1iMQYjunH4K9h/brkwOmOhrE81hrraXwVqwOlYyqaYD2a7IyCAxyTXrIklR0i2w5K4UT+hg==","signatures":[{"sig":"MEQCIBj3CJq6Wi54dd1y+ds1txk6Nav3icdw9waZdp6VJBYeAiA69y4ESnE429hE/rmcB890RMfpl+c4E8jXd6JE6jGcng==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13773,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSM/fCRA9TVsSAnZWagAAdZYP/1Qf83D82IfYKn393pKm\ngANPB73y9SnkrQAxm3LLnGMX3lli5ETd60lNHLhFOSmGDtmDY56gIaTyjxEP\ne6B1j1Z6kOZfEUMo1b1UV4VPEuG5G1S5mq8I7isP00YaTwIN6c5sefdUEFAy\nerqXytxTGrjoJWXgatKuUyeP0FRL2oZXT8COYPwRZPXh1avnr6rwuyP6XrpJ\nvJ3YjVEvLr4Nh1A3fItKL3MvvWZ0NPeMFM6LA8RESQnTS72ykwojCbtQndSi\n76xrkEM1H1XPDrCxQn8KI0wa6g/ivj0S/U9sFnpmFsZxpKivGTUPjct8lc3o\nNAHf9jG23rpArv4hJol4WrMIzH0miw5eqE13f+A+qPHH5JCavNov+qexcfkR\n4I/iB//nFMo7O/Pr9GNWbInkowkt+Xzd/0Lu2AG38fidttJah+4fg/TYmCaS\nMoGljzQm61ALPbwUclSDTnt5GjV9fsfKoteS0yJ8yZfW0vgM77CV5E5im+Wl\nssOBwdTlPZ8sEt5WcsqE8Q+IyQmO6u02oQDUr7xAuhE3TPQ0os+WYV8HYBB7\n8CSIkklGxEjne+vGLx2PMdsfIdHvNM4h8+Foi6hFcjzEYmtKxjESZzbrp2Tm\npOOIOfBjBryCBnSKaWEY4s97pzNdqepHacwL4fEycwxaDXdmyijOI30/363B\nkglX\r\n=/6A8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b85e5fb01e426f070aeb53a211ef669edc9e03d0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156_1581830110757_0.08158827486033737","host":"s3://npm-registry-packages"}},"1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a":{"name":"@iadvize-oss/opaque-type","version":"1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"44ebee275408e6b86460cbed7204cd590bcb1c8e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a.tgz","fileCount":8,"integrity":"sha512-Ya3yXFYGHFzvy8TPRplCBHe7mvWR91si//+vrgSqpOYr1pKF7T/knUiwin8h2c1ZwLThHb2UnGEqnit76cHnmw==","signatures":[{"sig":"MEUCIGMJXVm6fz6/n4M8LXUQiCSgO7a+LegSg+NcYsQ3pmNXAiEA5/A1wOvrpoJNWXutk8mo1INFphBKabjsaNCiOe7Ahyk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13773,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSlPKCRA9TVsSAnZWagAAZtEP/1ZeVrbEX9xetVEMwaCf\nKP0HqKA5xZ/Rwe1gHRUVt4ZMkB4MHhe58YVOVkwFXvt+LzAX+jAWiWHPSoDs\nRfctB4bFEF0dzubSMEGF6/Yml9Q+v+kDdNDUv20J55aeQneAPfqCrMMN+qYQ\nXGlZAtUOoLcTcVzhg6C+lM3klEGkeOaz0VjWDnOjJ20+1Ilmkoyjzj23euXg\nudlr9+rB0lgj4TMzu3EVXqXxwSk1g9+OyOroLgbknYGw8mSNLO/JhpfX7AOg\n4jZaHmUcqWuLF6R8omey2e0Beij3lTdqDIAjqbf/rCOivPJNVG3q062lC2wG\na/QRUlD0I6WJA0o8bPoA6PHC+XvUWfN7Rzs1SLwurdvDmVdJaPI0aa2fKZel\nqe8/ZLf6W5fz8iF22T01ZHrCL9rRmBsOy97LI713gMicpFfoKMc1koTBjwrX\nQb9eCaFrweiKqg51VJ0ZSZr38jSEYnQuaM9cXi2AFhitVorv4B/GhvMAQ0BP\nrQ7stQAKMiS3iBWjhOgb21ZJR2E9pzkc7GmrlmQnU+AC15sUAjiQFUkHtCrx\nzfzn0nCqfs1eay7ymlZJX9e6SHvv4wk5W4H+fHalKHhEz4STncnrRdirzU16\nnyNfc6+flkalP/3Tktb/ygOu2vBnlL5oLs89s2fAJv8W2XoZnJUz+cOjPZek\ngAEG\r\n=9Ivz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"10ea7188eef409d16960ea428b207aae9d06b0df","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a_1581929417617_0.6296802560461501","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@iadvize-oss/opaque-type","version":"1.0.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e53b27e857b14d204b392e92deeeb8ccde341b95","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.1.tgz","fileCount":8,"integrity":"sha512-O1UH8Ef64e9eVTK5GOwk/B32FQMgzVuvS6HSncUZxVbCib54ZhjNk+Wro6oxDXisytw0RzPj2BvVCqp/wZqUVg==","signatures":[{"sig":"MEYCIQC/Gk30r2IBUH7lzCs8mh3bn4/AzVoMFSMcpNamkDaqUAIhAIr8TLSLp/KJYtTpgydoDHdsxS0vjdaxYq8QnkhNGLx5","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13822,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSlR+CRA9TVsSAnZWagAA7NEP/iiccVH8pFo5dKjjzX58\nFVl9m9ppR+qsjF6LDP1zp4OOUHWNMrcr7TEnsNFVmMW7SUEwn5AzwUAEP28E\nVCh7ofJgLBBYfyFW3zDzElPDG5iFG5TjRVaSDiiiBaj5cSeti3o/3eUY/TO1\nb4TGhojWVO3NJ/O74zTKi2QHSR0num2rQN/sxnncLtg7k0Er3t8rh3+RASsF\nHOnXj92Q0Juga2LwodYxf8wKT+RIRzh8pSBwY/0zD+OfRS0KfyWJ+vuGBOor\nBWzFq6SzyYeY76ZcWfJeTNib1zXjte6+rXJLlrBhMgXkAz6Fq9XpYMckPC+n\no6alsJd3O4vbzrP1Ee01cGIBiR1jwU2GOX4cF9YAcB3DjT9cIVVDHlc0qYl8\nJS2sS/UOQyE6afpJEOfhEwbYY+QAvunpztLIIr//hm4iF69GHvIHqnH7TS3l\nhOYrG7C4ytqii8BrjMgpLsiSTmeQPB4GA47e1z+0XmnDxS3Dl1RnHutEoW54\n/mffhWuMteQjXbmOe5z+y2c71OvfnRBrWCCL4vVzeSWIvUf8uFILQmnbytkO\n1DnAGxiDCYOQ60MoI//S/1eRdLf7qu0KydNec0B8Isn60x7ESVto99Ini7ka\nNAeClUViZOC9yxzV76gJ3SbCOPPgjPSlpviD3GBBBzOrGnYCT52f34ZnfEni\nF/vY\r\n=bO4V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"56997b156514d5bec2a269ffa531b91b8d379846","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.1_1581929597738_0.618325788629035","host":"s3://npm-registry-packages"}},"1.0.1-canary-91b8646-1582100771471":{"name":"@iadvize-oss/opaque-type","version":"1.0.1-canary-91b8646-1582100771471","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.1-canary-91b8646-1582100771471","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bfb837e6b5c7094154954414a341e9231b70efe0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.1-canary-91b8646-1582100771471.tgz","fileCount":8,"integrity":"sha512-g1boJBF3/HFZTg2ssHbjTkne0aB7tWWLFuBk7jKlIqD17qonOSF+dYsKHGWTeUO8AYB5pllMwqcxJETkT0pQTQ==","signatures":[{"sig":"MEUCIEQTcRLVTEgx5uSXhQsu19U1m4EQAMRUQdPS43+ygFOdAiEA2tKya7Mfkg4/K33T7s5UelxQf6pq6mT259sLhp6+apk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13851,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTPFXCRA9TVsSAnZWagAAlnYQAIgL2JsR0cOV2k7Z0MDx\no0T1Xhjv7zadlqRtFUBVlAX8pEg9+9f+grmVzhubD8UkJ3TJvUJw1QXFFoSo\nw4DY2xks9KjqlrtFkVmRoF4kP2M3YmFTsqeUZxyKzL5ALaW2yH1jtWXzgIS8\nK1FboyfVqCL9acBTGnhayGpc8/iRR8oIadbertELfCpvayylRIuDJM45KWH4\nLhV/VscJVrad9K8w3DhmJpY/mijgkXYKt4F1J6Hi22V8OuGKgR/xHdmIdu4x\n5/LP3zOtuipVhVzzZBvPDCqFEBajPemyekcjTGcd6fsrzq5I3wX1tkKnIsfv\nwnKB89BOfBfKJIg6T2qlTY/WzBl2AAgFBhUcwOYPTUsBTAxxqvUtHeKbs56S\n2YLNrCUq4p9JZ2NxEkghgR+yQbR3C5Z/SHZnJTW6bukmdjDtGeen++le7uRy\nW1EW0Ac2EiGugcraOL8nHtMuPFuBOiB45NggSGjAlJ2c4FbA+m5j4dX4AN0C\nbR/Tj9h2SZWYamXdOiOrG8YsFZa97ztN6xWtlrh9BkhR4wtZRoPKjMDr9vAk\niWNOJwB0iRAT21VwxE6LEZs+QEZ0TvhleaLxcp2HW/rKqgn0yk9d0MXBn810\n+B7z+8hGKes/CS3u7DaAYUifd6wCHHOfcN2/SrR8seUF6mUiPd6Wo39jt5XY\nND1J\r\n=+32e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"704d398352c7f869b12eee91fc1f306d1343b86c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.1-canary-91b8646-1582100771471_1582100823013_0.5865630170265468","host":"s3://npm-registry-packages"}},"1.0.1-canary-93ccbe7-1582100793815":{"name":"@iadvize-oss/opaque-type","version":"1.0.1-canary-93ccbe7-1582100793815","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.1-canary-93ccbe7-1582100793815","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fdde0c2045ee5189af229c0aed8c06564a3de706","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.1-canary-93ccbe7-1582100793815.tgz","fileCount":8,"integrity":"sha512-Q3vkxM2cdsH7VnmAHCTDgTou2EQUJB2b1QuOjZM7f8c4cuAoWvW31sohED+WgDxUWAWtJywV3m8PoxpNb4iH8g==","signatures":[{"sig":"MEUCICpmo/XHxqQRNKhOLAw5KXVEVYKhoXfEROEgfgVIxdQyAiEA0mwJSPLVDkinSy6oGqr/x5uW+pAxrsZJdxh7OCOVcKk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13907,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTPFoCRA9TVsSAnZWagAA/eMP/0TE/cYJN9qyU9/EMJPS\n/tL4SZno3dTxRZl9q5TFahDEE+ZE3HPP9Kv2H3F0oEiQo5OP7haQOI5n/PWL\nn/Z+mE3nBOMFk/j20kljwikkb2UXdr+2tTWwxOk2C2gUD89asSfMi9WcJU4z\nG642aR6ByWIDMAT5Yw4t0+OzB+85v7NWRMw1XnmjTxwwNNK52+zVEzGwH3tg\nBAbI/N45yKclGW+u+IHKC/fee+QMUC00tq27ITwL8lfmbYMTUF9vxZSeaY8L\n/IPtrcFQ+cS86ifvoqHRYdziG7mzrc3VMV9ZDw3a6NHoZocoYu9FYI1X3WVE\nBwu4tRRcT8wfXHJdwSlmfRXPoR9SZualPeEsZ9YiLnhqypeB4YVNSRMPyQzD\nyxvh4zg8d5we973A6VSRFMFspsh9M3YHPCn7wvgSHmc7nhEaFW+5ldyUqw5V\nInwrfy92cLhklhpAz+Ve5ZNl5DPrQXIs1K3rahAhCLbek2q2Jhk4GxX+2KqD\nHKWyIJr4T4KFaev3GGCMoGYvl5QSY5yE/XVnkWpTeJHwTSgHZyx63BGO9rGf\neANWxJfGM3TOl+SKR9vkFmLdm9TH1i4bvOyn8rrpYFoeEk6x6EJhx5aaHlYV\ngBRUd5WaACEclu6LWl7iY6k110Pe1iuiKQwSSGv9XzSulLbz67EI/vRwWPia\nQOEQ\r\n=CGNj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b83ded391f07397f713cc26b578591703c2be9c5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.1-canary-93ccbe7-1582100793815_1582100840463_0.419868656261025","host":"s3://npm-registry-packages"}},"1.0.2-beta.0":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7e3080723932089026129ee2ae12f5b77af36092","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.0.tgz","fileCount":8,"integrity":"sha512-6rsan/RHYpH3lyazFq42x9b07f857oqWoGdGDoAIagPxtnmZI5p2Tv4THGEnfI0JuaAAbJnagJrYHJ2CGv4AhA==","signatures":[{"sig":"MEUCIGux2PB05hoUXdYkuliAecT7g60KJWdUmHVxHQ+UKFanAiEA6Eic9uroDGH3MTmfT1v9csLe4ak41SK3ofsEzb5x6Rk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13885,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTQmvCRA9TVsSAnZWagAAhu4P/Aru9lvWIHX/XUxjY8dn\n5pq6Zax9mAhkiK/kQABa/5QK/QUwGD1iy3GS7JPikKyhIVZudl7cyYhvmJyj\n/DInDCoJ9az7LTpgGtYS1673UNiOCciRVS4gCSl8LM+fEDQDXAbqNHYpy0uO\niklyYFr4KG1kEr2pelfuPMDOv3K2gvMXbB+6ScBX0dzc4RXy1sHSNEbTk7QN\nv/Gd6gLnjiVFxHocU1vDFVuTKImcnv9BAvNU/r3FGBhmBhhGnERZH32syRVJ\n3D6rZb3498OHPqVRLK/ELapvLUEUM5WqZFFQC+CeSKdSlridGoFpGyKU/gFc\n9DA4sc3n5i97ZKqvr3D1S2Y8VbLsVSLPw81IZk8wKlh0oMPxTBLQjME+wDfE\nRha4LcmH4AcbPXlXMOMA166r6fjg5QJGv5oiwqDzHJpqskS0/zxyBga9fg5G\nbDtzHIe4hFlbfFMS9kq3/YMUf+tn6pwmf/i32U/65ornwSaaU5a9G2gG+fx1\nIo/bLyL4N5OR6+s0PR6VhcSUHId7CG0H8Ql8CLFfDwtNmL9OH5LZUUv/Z5WH\nQZD9YbTKxS+JD4+aVq3gMH3wPG/emBUJzKerjpDQJ/9XyfaoRNuDqVtyOLvd\n+ORyrFQh/jTGd6D1wTpgdPgi7JyY/y5lIIQK+iONNjT/MOB/fb5zvY3tDOlm\nMDZk\r\n=o3xk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5a91c93d5f592391a3dd484cdc2aed80ca10c5b4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.0_1582107054722_0.011907005118917402","host":"s3://npm-registry-packages"}},"1.0.2-beta.0-canary-1a2f75b-1582141821114":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.0-canary-1a2f75b-1582141821114","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.0-canary-1a2f75b-1582141821114","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b2c73060319a3e4480e396634092d00f64151504","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.0-canary-1a2f75b-1582141821114.tgz","fileCount":8,"integrity":"sha512-6pFX3VqJ2WO8B6UTm2jD83J7u1Qk53nQOox6NyLohQkwTXCymJ1uPjjOZUFyMzaHx/bfuZNdhBnBXIqlGs5Vlg==","signatures":[{"sig":"MEYCIQDCWhdi2HBEnEUjUHRUV1O1AtFRbius2wWet/poamh43AIhAKkrBECo7NyU4+8X4YoAEntPgoDlgMn8FgZtrNMPGQPO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13914,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTZGvCRA9TVsSAnZWagAA7hMP/0t0VBEbwoZ26CTezOfC\nf8qjJPK9CSE7loP85G/jr/P3XRpXvu23X4LJ7KieXPoyg1L6TAoNpv5/adGA\n0zUy7CCOW3S9ZAjNfuSFSHajcKau+igbcXWvqa0qL91uxi3rEXj5HnP1RHpm\n9UYPVfAsaSj3fdrdlgpgE6F8V2TLAL/n/p6rj9qtA7H3aki3nUOBRuR5YUxd\nsQBXDZ85RFQV5QkGP0z3QlMIFIK5cc+0WlI9ajy6SU1Hj/nnmvaLWpG2jqdr\nMbUZ2+tE/QuVKRqiXOozYnqR2QmuBfgO7DLFqG4uqEaJra33SFQzI/AFMRYL\nwcFw7tHdg5IvPu7moUyNvgaNr6GNtzmECIOHutIWEfBFKDCXlIUm7qENVONn\ndU/c/Da9KQ6fylqVwFmEeyoGE/MDYe5bFoHktBp5pq9XFgYzpDCF3JezNWyL\naLIF4e7NoAXK04ZLwWs0udACkDxFcB1D9lM73fJ/HnPouS0HvlhkNrGxKqhk\n+pfBRPnbtLEaTW+QwOt6VXJ0vuBA7O77WDeos4WIoW/0teJphSx/z/Jpmz95\nmF2m7is1D1YjwOZ2dSzLI1zPL/NKtYPVuL0urENWrLHApOpQoAZq6EMCwIeH\nI/f5H+MdarM88jFAbXIgzrj8hXje9uyU4Z+dfmQN5JaIMlQQS/0UliQgnnLa\nOrmt\r\n=hyBm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dfde4e317e194382385b87919f453a3b857aa118","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.0-canary-1a2f75b-1582141821114_1582141871033_0.6167520317647301","host":"s3://npm-registry-packages"}},"1.0.2-beta.0-canary-c439b76-1582141844980":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.0-canary-c439b76-1582141844980","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.0-canary-c439b76-1582141844980","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"13690e19e081a590c033d845c0f8b5f9cf4d31b8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.0-canary-c439b76-1582141844980.tgz","fileCount":8,"integrity":"sha512-jb5W/+u/bz03n7OpRAcCQ+t0w3pHl/H9GwDClJXQVfQU+d3k8wISJwab/0YGsBp0x8q36MdBdg9iAJv3cjugQQ==","signatures":[{"sig":"MEUCIQDW2kxxXQm9+3D7UJWOu190txBOyRG0IaV2NBMwFYyXbQIgKcDavAsPJMh7WZVlGC4g4exECTg4qiZEmZ00C+JAZrY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13974,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTZHGCRA9TVsSAnZWagAAi3MP/Ao6OwT0gPI73wHawkZM\nnvtG+ls+gZ2jsmoEdD/sNxidH895YuAHcVSZGP/YA/wloIJk3kpbzeGefNcu\ngIQ07WXs42ANOy98lKZ4z/Q1zK7U5YUp7PVX2q5o8I8r6HhfGK8IP4LtZMgt\n+MBTl5u2ciIyJtEVnKuFZfphZv4utdTdVYIcSlFrR8xbQwvEqRn9dXBwj7YB\nlH3MkKz2BTTkN8v3ADezGBTD52bO0YPeOVo6P1iRtYo9aNy/irPj7uZqjNYS\nf/Atwg6h9QMj232SvGS03w+hUG1I/jIRaUobwQP3mdmdNfcLjSRbRciN1rnZ\nXbIXBYJ5NQyHYBLJh0zT3LNyjxGCWdt8PEhsCBr0BAykiteZm43H2Ev7HohP\n+jeATIEkxd2enqW5InBmiMnEBYM9Qb76Hj2j6/vTFdHO2ai+bOIgNgzuGlIf\ntTLY3VIyOGqPj+Sx5z3T4m+V3Ujy9uoQ7pjK+0PAF7xshhBFP03rmnynNaRr\nXFQndwtM0IeWoAlxv9scKi6oX9I9bkLYUk2FkshQc2HHWr8Grz0d6QkOeYP0\neziyq7gTDF8MzmYcjUYTQoCJ7OQei177O6YVZd7eoosTQ6DRRwrOwub9BhYu\nmu0x9mvEXlFMlYnb+jQgQpI+8b+MNU/qmvg/Qwt+qBkQYiKpdmwsh/YGiT6F\nf/fg\r\n=tjUE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e5c669d9f0b926dfd60792051b76cf5276964451","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.0-canary-c439b76-1582141844980_1582141894492_0.2632336526681467","host":"s3://npm-registry-packages"}},"1.0.2-beta.1":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"155a86f86349d48ebdb191e658d0b42efb8864f9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.1.tgz","fileCount":8,"integrity":"sha512-RRvKcWeI2rIftTc/V5gOLBYNfQsOzaQaqkOiElylIQ9gn+uDSGJkWzyZmZAGzSXARR29KwqmJez0WrmZuxQYLw==","signatures":[{"sig":"MEQCIE2UbAOhW2mr9Pg2BnpyjmcNxTbQ70/QochWQQwWbOorAiBlDUYcIUX/Rd2Gh1t1YlufX+Hf3Zbdr6DXtN30SM1YdA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13945,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTjF5CRA9TVsSAnZWagAAU3cP/i3aZPDRF63gxMQNikml\neL93evbJxzL6MbJ2aMuf3M7u//zM4m41PTGT9NwTZCXS6ZDZ+rPniSSp0cJF\n5j2BwRwyaRVI/HrJlN50XiYETx47xkn4nbaMIZwN8olifjjLyq6jmB5/s0Nl\nxpd2KLR0A50IKR4UV4UVeKbhkvvS8i2QC1zP/j3lAyymGTJ58UU5DqSTLAgy\na6o6RNmyZcz65LRPyIqHU0auvN5IJCWhpkHCd5lF6oesA/yJ0lziokBDm0J4\n9dnwbmB9LMDplV9XmXSGjEFKO/HMWnKvJwl5kMb1S4U6dcImpwWET9eH7bIL\nF37xoE+Ng7A661xuluioEzgjyADLp2ucYZQoJ3GArb3EVmYiiLgSN9okWf4Y\nxlX6S9dypNPSTq0F9+youZy2nYuG7yH3iKIoM5CqWPN1AHX+yN5sl6lHy3Kn\nOHF4cw/G7W6oIrngKSL5GxAy8sFWxtjPCI/hUL1bM0kVW0iDIOYsg0tlr2QA\nsmIV1F/QfceB37dYFBtcDeiyqGWwYoTcb4jAk/aqkMvZ3GZ3XJUztXdF3fgx\nMlQHfiumkAY99+pdvYkznu2yJJhuY1xfwJnsQVheMWeJ47tbLJgPTNHu9EDN\nUXkIxd/AJO520X09AmUFlvoD/z2z4bkwPEyardevjb1Q4qemg1/Kpo8R7A65\ni/U4\r\n=Go5t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ed1e6e05d64b512f83f4875425e49b1f3b546c04","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.1_1582182776660_0.42528494840645403","host":"s3://npm-registry-packages"}},"1.0.2-beta.1-canary-3a5a0cc-1582234187251":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.1-canary-3a5a0cc-1582234187251","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.1-canary-3a5a0cc-1582234187251","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b63108bba0083162532c62bf8f7fb70f2063c651","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.1-canary-3a5a0cc-1582234187251.tgz","fileCount":8,"integrity":"sha512-GjZ2IYHOYCTYFdXwO1iyBRI0MrnLQCO7pYSN41eIyT9E6z1b35wTbscKn/ws5ccDC1zizcNVUq4QJDkOX/aY3g==","signatures":[{"sig":"MEQCIHOwfRUIvPFcEE0L+S22uj8PhZvXkimGHRxKi5Q+x+FKAiBq9aspC91ul4zt0uwSyMiW7NQWted6Y1ljuhgkea0e7w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTvqCCRA9TVsSAnZWagAAJXAP/iHqU+qkAmcHVnZoqcGj\nrxDsvzhRITcEFnoVmr88pl9mjY85pQi8aFyVkCr/SF06dE30oaC9BlS8CiAL\nVyWfBTk6M58dGwA8Jd7YfNbogt9Tu3pt9dEih+Y1gLt31Iy/P8R1zK6jyfz5\niWs3ibe0buEjwQIuGdnYkX9y8ZtftdFwiDKchWpYMiC0v8dG4rVT9Yj8szmG\nuDPXxNpp4RKDkXbdaWA7nBKcXfJLr3TyZl/BWb2h6Y8MpgJ8iQooUrEVzIod\nJ/zocMTX+PpmyAfA4qsS1pv75//ACUgTVua8elUuTIRCb5VJd36bJ34kZ9eW\nUZ+nUeHvj2S0b3/B8jlLgABpsgM6xU/hN4XAcAcbxI2PVS4hex7dXQL8ONLA\nXad6U11zyOTwfBCeqAXWwGWMXeYktf7yvJBk7UQlhosTFSP/uDxxsprI579e\ncZrf06BcKOmu1rcmfQRZWIUflXsudew80snXFArrqbSLmN+5wjYtkI8efEjo\n62sTgIPFG19VAAqHYYbGig5mC3vqbRjfJ+z1CZaCa4wmrR4Gpn9vTwe59Hk5\n5WBPHXP7z7X+HlpDlsM/YN8W8EfFPN8BO0S/Y+kX1MXqAZpkspIQkFS1x/gP\n6ml9MnD8x7cop2YZVufAFnvIlrsw76I1PAjUmUHNQd65AwlqeRbYhMulMXON\n5/eB\r\n=tCfV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1e8ff7156a1af8802821f5b8272da5c767f7918f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.1-canary-3a5a0cc-1582234187251_1582234242389_0.6456400631992807","host":"s3://npm-registry-packages"}},"1.0.2-beta.1-canary-9a9837f-1582239111238":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.1-canary-9a9837f-1582239111238","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.1-canary-9a9837f-1582239111238","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5a053054f1a0abafebe8a56a19d8ed06392d241f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.1-canary-9a9837f-1582239111238.tgz","fileCount":8,"integrity":"sha512-orX69Wlki09kY5HwPXKd6I5UvQ3huBXFLb7UqReOHfnh+O8LnLJq4uJXlnLCiltfr9z9b3y/IObzbIZ0AvrlJQ==","signatures":[{"sig":"MEUCIFKiGgBHlkWQOMjRRqdpEJy8+gsijKP55llvf5xzbdoiAiEAimKgL1YgHHm8LMty3G9sW6pFtVjQAbMzDAM+Q7B+62I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13974,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTw27CRA9TVsSAnZWagAA1SQP/2ZLK+HvtepPsJPrEO94\nbl5P5rwsJaW93blP0wvwxRcp0qZ1JWLEIxwFXwg1GsykGJXWyIe82h2Vv/yI\n+/ny60gzHNbY9TY9Tj//Csc0Gm80jlsaFKoDNIRK/NnY6dwhQaSijqOGARlW\nO7JEuv1PM3jZlqwwkheyCZoXGQ5ExVWQ3WCoeVTvCNf+fA/IeTJ6X04NWNgL\ngYbcyoys5w/bmhDAeQ9TI9mZ6dJvgEC7lZf2PAnQ6k8edvq0oE2SdwGVyA+6\nxV7VsjYKomA+YbsbRqFMnWr4FZ5j5QRcj8wK3oLopIH/W3qj717GA8vjJWUY\nD7Ii7PQChtxoL7g6IOQcG0Ga7TL1METQ9NK5dziy6yIBp3Txk0lVlvgeP8EI\npZ6nKFDefyy9wOxo3ue7QFzGQ5fBVh88cpLs3ACJblHNj5xRkxvRxce7OLNW\n1hP/27o88Ty4GiccyfDDNVI9X6n6g/CGsUMqFXJWR09mOJD5Js7L5D4mfDsJ\n7WOa4D6U3UlWK/IbIYpDPE+OZGBbBKbS+QpZFkHz9h1i3/PmvnD0pcW0T+Vf\nvNwdYW2CBOSKsoBShrD9cgnAFYOQFDzaOvrmyFSm/Gdp3UA9rkBY9yMyF08b\njxXwqPvN3nJC0C1JJww69TojNCjTFarsEtHWysY4/eMAEbGaAtNVeNgQKKkd\n7Nvq\r\n=Vz3k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"251a864e78899c2098d79d9cd4a9a8444b336720","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.1-canary-9a9837f-1582239111238_1582239162710_0.19133782528181587","host":"s3://npm-registry-packages"}},"1.0.2-beta.1-canary-e2f7616-1582239148334":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.1-canary-e2f7616-1582239148334","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.1-canary-e2f7616-1582239148334","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0845bd8fa457ebdac0d9fe6b5e37e181d01ffad3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.1-canary-e2f7616-1582239148334.tgz","fileCount":8,"integrity":"sha512-JfpT9rStI2bMovuuwcpCqB7cWhG7AdXhYSf1lvEzzSzdy5wl1QkAw5WR3az0lsfs0Nb4s5tkjjMyzkQ7jdf44Q==","signatures":[{"sig":"MEUCICEMXYv5nKkSMwjfhdxuWhlgCCq98MlDOFLAJxkuBg/HAiEArqfHdXFAFARsXI+wldZ8DrdSKRWFULyFPpkIOXgtqzo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14031,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeTw3lCRA9TVsSAnZWagAAgf0P/1bTofmVG5NSJvv4nqq1\nCbhesnLTSyvWSvNrnruFw4PnpDpvb9AsVzcEv7gQAfA/0ACenzPfDFuvLFqL\ntotNrP11bjGm5imVlQL0FkgJwa6CN196su45ZTaZFSUVuJgNiCLYTK0XoABg\ndwxzLnB0pQCutunYwhN1gB294CWLLMndZy9ujzcMeoHu47PmzsFyd8z3cJ6p\ntiQ4IPbDDd8z1VR4T1+lF8FyFqlIq5hVAulyIXijwsQq9lEK4jjadfV/L9vP\nSC8SlFNvfZPX+zigD1ZidToO3LZojxiPg+pyHG50XjjXJ7xgTdOni0AiJ6UC\n2PeEwGwUaO4lKs22kO+SF/pRBEG+uQbQIkQKPPWqQCF2t7B8dvuKnry8V1g2\nTrMkvfRfZaRQYT9KYaTLz03Hqaf9BH3NO2/p9PjoMF/MVaHjkKObn9Pa6RrB\nTczHdyiKTB61fUVrYJ/AXW0Eaahpv2rqJiGf9rdCPtVtbNxiZudpDDZtUyem\nsL2jomjSwn6CKfD7T/iA6yNyvB+ecTxrLM9k91HMMirKLb3RAHlXGdk1OFQc\nRzibeP/DyldJgi/EDheJpJuC+SSvj8IZybXVMXmFXUIo+btKfrcdN20vkCAm\nfrfyvoHQEIxTCF4tnzepjATO2eOI6LpmGyJdIeTMRoHHqCRbqY5aEF7F7KaV\nHH32\r\n=FWgZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"671b9144eb9c8a6cc739414ec517a2ae8810899d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.1-canary-e2f7616-1582239148334_1582239204943_0.1275527335175035","host":"s3://npm-registry-packages"}},"1.0.2-beta.2":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.2","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"aa7d1f731e1660ef292bde23925f18a86e64d32f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.2.tgz","fileCount":8,"integrity":"sha512-HJZ8sAU/I4eziAzTsmVwGgmFzLSg490FLK4zHsKhm5aEYx7QlvmYMWqrrmLW68TkdM9Fmpv0Uw6BaMp6jJcZVQ==","signatures":[{"sig":"MEQCIHIr4aa3Z823eTTJ6BpeAS5p6wOhVPhp11ezMX3Ey0VoAiBFs4J2flxzm/WUhOKnhiSbSmAxlmQtQ/IaE4RKb8iJIA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14002,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeT5w+CRA9TVsSAnZWagAAnzgP/iEZr2AC4BdlkB5CTRAj\nadL4pofQZ2Izv6tFtzPA2RaYzj5FgIEQkY6lfRFfzjYGAxcdXyDrj9ApJRpa\nUxbqSDDj4K12gl7z34+tBZ7JwefVklP0RWGvkfN2zsd6zZaHj8uybWXtReLo\nvJI+McTlzoCek3QMFuwdCpzxRK2v5Xv6lLqhFdUT6jfch0tfziYzP/+62yVp\n31GinlypLvxowpfSWxJwoso2CVXTJ1ochcZzRT7Hj/0vDZTJtIF0X+5LOHSf\nQNvQ9cwVhaL/p/yiOvLkAGbH0dS9XKauxTTJF1SpsHGA7OxCqFYaQJLsUAg7\n5RCDkuYKFqzFNkOekHc0RHq4Hkb+MF+J5n8VqD7/3rj4Lu84i9a0RFLmmKrd\nUhhBYmVq9AoOdGBoKumiuEOhRGl9CE/1jJHooJOCjUbpVEGGQjtSbXObqVGF\nnbCXhcKMnWLJxqs1RkUAm8Q8WbgMe7knUx6QRqBi0cdZIsgGZEH4CYuEMLqz\nQHQvDkkC2ZFETpbtYpbvjTPRnYpeYnjS4/N9m95LrpJsYddaXzXDWuGgsjWu\nWcg8NEwVpu+r6Ikh5sDxdusZ4U5QNbFcpuAXk5gDkSn8gwBd0Zwd7oUCmgTG\np93aOJsKEEffxHcpaQqq1ODGGAvXTEL4PPcllbHQGjUNdXikbHyGchoiCran\n3S2w\r\n=hljD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"64cc1e2323fa354be718ad3fca5319e908f30d78","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.2_1582275645759_0.014937504714654493","host":"s3://npm-registry-packages"}},"1.0.2-beta.2-canary-29297b9-1582276849355":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.2-canary-29297b9-1582276849355","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.2-canary-29297b9-1582276849355","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"abbcdb2cf9ad31b46e0c2747914888f63f7b27e4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.2-canary-29297b9-1582276849355.tgz","fileCount":12,"integrity":"sha512-fcCyYJGfq5HdS0eDWHsl6IqLG3XGtK6A6s9cotK+SmTy905UNUC/W8Zghaja3wD+XX/hqrqbRg/XPMAv3Ih0Zg==","signatures":[{"sig":"MEUCIHF7dFjrvY323nLDtfxLxYnMn2xETLbrZOCXvA1ZgsviAiEA9v1+Wv4je1DXBArrGqLvmE1IRcbJZqfoBKXaMxKOJyM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14039,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeT6EvCRA9TVsSAnZWagAASu4P/1znFH2nhhXgd+u1POc+\neUuM1pBAkTkw+azTAXIVf2gVUKcTm8a2rnv0Os+GrLtjvweuXFvaW8iVrrN/\nt9RIUt/nX5KMaQ4L9XWyBCp27BoEDoPOHYVpJ9VA7kNlquBbaLxO7jWwXKtn\nHns9lZTTEfVrWJXDP07pC5KjT2pXNcgAeSWLYojTOoECtBIUrQecv+CDtAcn\nwvQMdd/oc8ONh9E2UezrVhYCZEYFj5e8FF1BvWamaElOWE97KJvRgyK3Oun5\n/kdl1qDj5vGN9V37qrz8bRDzQ1BBpw4bWNtQ7iUOggd/MchiLKBo707Vx9Cq\nrdMREMoA8lP33cHXVQ8Cw7qu55IsmxnfhDcf8UqBCtA18yJVy2/aSKKv6Uho\nK477kWa4mf/Rzo1YjYHMv3Vb8jKQts5bxiUzXdlxy5utXLsDCWRi1jE/Rb/M\n1N6AJ58SEO6QGC629f7EwPLfs8TycD9Dkk/LnF6VGXtVWZmkoWxQHPSw0DxA\nyjq4AG+jePi8CfjwTVzPGNhKxmSFxnwfvRhgu1W/6qUUH1weaucLVW58aTKA\nl+/eFyKeefk2AgyHCAXvJDuPQ2sO4SA1+TpOUc6Yzmw3nOnr1HfySa02/J0d\nICo2P+XdOmvfPTMcx0AMeTbCgmg6/iZq8R2oWW1ZrePK45mRnsBtuPFla+Y7\nmoYq\r\n=BOtD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"861d30bcbc2ab548b0f96537f9c8ab1577f99f50","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.10.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-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.2-canary-29297b9-1582276849355_1582276911281_0.11167255040340685","host":"s3://npm-registry-packages"}},"1.0.2-beta.2-canary-8a7967b-1582533367835":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.2-canary-8a7967b-1582533367835","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.2-canary-8a7967b-1582533367835","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"24e2f1a7d46724d3af640e1d1d79d1d2f05a5f18","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.2-canary-8a7967b-1582533367835.tgz","fileCount":8,"integrity":"sha512-S+MdT4yZdr5lyhu9/F+PzA5b2kp5dv7+9ThJr6WLwE3WIL7EBDxl4G3R02LCayx71yGsdslGIors+qRUqanoqw==","signatures":[{"sig":"MEUCIGJ7B8yo+8senoIkDEYZ6HnVsXrtYYEWIxRF3RBc3Um1AiEA27Qp8lk9g/YPDl0GDvguRA0MbccD+pgTpwUx/onodjI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14031,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU4sqCRA9TVsSAnZWagAA0WUP+gL/Uw9YsgzqyXlsYBPp\nbAjrqs2y6flQLHJlSeq11fSr1PxuqbQa4lbl5YtvxF03RcQ8t6G1mJTV9bLV\nCJxak7OYE0P9JvMhPlTfWrY4HPd3nQ54lHVLBHhr1VnzCN4D6gbeR1EMC6cT\nHFvGBByXPaGICQMzWGZPl0Imn6/472B1q2Sh7JLzvOT4xeL0NA0FVQtP69Nq\nIJpZYNOFOhQWzhKyZz6Y1xzCTvjQWktQqjfSyZpjIEVXZ7I1+5bC7rJNWepy\n5aoWU50IY5qqlYU0CZAXAv0jIrUAgVywmrmP8KjJ9FjzrQGm69hTRfBgnKSX\nJCMbg0U498YkUa04/NLSzamNMBv1a8e1pHt41b4jfbffhFtIUktgAh3dVTAl\nb6J1sepA3cf7uVjSq6xldOOflrzEzXfMnXwrSYwfImDdppYaK9eWS3MDqCUc\nDC4ZkTdApMXLmoG60TZfE4Z6FSB+SuRR27vFvNFRULa53JpZbtI3jidDVJVB\nRgUPKoBwN40mE/cAogjSUEIbQOr5f7dJxceS2jwZ57Ho/QbdRdt3Nadc3ebn\nnwMFObAh2v0hPyhq9kuPRWzal8hgRsGa6s8E/FW54XSyYhxfV88njTwVG9LM\nlaeCSeawHtot6lVZiU8b+6lDHGTwQjc93FKMXUIvomFEd3wCapGUSNkt68QF\nCS0U\r\n=fnLT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"05311807a0ee717234d538d26b6b5b2769b02264","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.2-canary-8a7967b-1582533367835_1582533418448_0.3809126620953831","host":"s3://npm-registry-packages"}},"1.0.2-beta.3":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f89a12a242c2d32e21396d04b3f534c6596bb104","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3.tgz","fileCount":8,"integrity":"sha512-JOOgF971jZbdbdTU41PAvR5bELhof4YzjHTM9GAwKBBzr4DcJgFAsW1nb/ImCGnMuw+gB3qplilrcslr+rawMg==","signatures":[{"sig":"MEYCIQDtCmxmz7SK4d00RFidnyWqlkTJgIsRO/gSWhuOLHrIWQIhALYBjMcQ/XZjuU+pizQl5FdnNSJH0Rn791897JOq+9JN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14002,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeU4u2CRA9TVsSAnZWagAARhIQAKHzpAUR6SMXecFUTUpS\ngblU4fKxfcKK6wS8YJzPjGrevxHkKJByaRAilUHXnqkUDK/BbIn5spM/Gfb7\nRZecZUvbfqmKFMYmR9U5XyjojaMzU2NeDtDKzgAb3Psel3D1DIW4eOqkELzT\nfrvWFFXz/iYa3op+kI+wjLfOr7L3OH+Dt3lY1ApvelT0nUPOc7tFuNbIhHmu\nkhFexOhlCDpOV4kdC+SZglsStQi+hdyCtS/agbgzZj/oICKmngtfYRZt0u2F\n1vdwcdOjKOyGW6et4pKEUefxtYJFh2BYyDB2j/ppm6TdVaKa0LlPYuULEpUO\ntIhjyiyg4gtwjaXMddIsCwuHi5VMzYHNUiASQbmmfGNLdRayZwKQjZ1ocHxM\ntN8WCVvi+vbv+X353G6VnokzysM2t8gOk82uAkvrQjvfaRQgTK/5WOItcg9J\naNI8rJbXI/LAYx3EOmW7ucS5KFr0mNFpjoLCTKmxcpu0d/w4cOOPoAbcVAD/\n4pIPe9Ti/IBJb6Aj4UX5i3ct4nXPAhoeQ83P52/Z+LOCp2FrPcgA3Tisuxk9\n8CivDQKoCYWBW7mvJUUXHNjSleCMfDdPFnre00Weg6Yj6Nq/adEHFG+nl2oi\nBI6Ewds4LEI39mjA6j/aPEKnv764BbeAnQLnlj5t4c1A88ENiS1wzv6lsGa6\n7AJ1\r\n=ECv7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7a854334c5caf4076711467f9c1b681b5f353d4f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"echo \"no lint\"","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3_1582533558096_0.9218761462275691","host":"s3://npm-registry-packages"}},"1.0.2-beta.3-canary-aa25177-1582577707123":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3-canary-aa25177-1582577707123","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.3-canary-aa25177-1582577707123","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1141a811fd0f241aa69de581754cb76b5b4cbc2a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3-canary-aa25177-1582577707123.tgz","fileCount":8,"integrity":"sha512-LFBETypFPU5L62g7cnXS/EpanimQIrq0IwYbbuPM6YgrMhFXQ1l5ji7919rx1SyauZMCJ52dFmlx4iTVjQLtjA==","signatures":[{"sig":"MEUCIB5PkA1FY8d+Fhsepl41re6T5oawwo9M1N4bGo4kpH97AiEA0loI2S83+WieRs15/NcMR8YYfdC8pAC+aDEnidygHtY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVDh9CRA9TVsSAnZWagAACMQP/1b0eYi9ZQ/o9kvuuN4l\nkDp1Na2X7kPShtIsdhE8c1WLdX4VGoXjEYAEjjvgmwS6Nd99Vi0MoeO/5cjW\nUE7ioQStNtO2lGRuMijD41hfwlL/sNjBQUBU2/uj0XRjB1WxEKMqgZ6N7ixV\nVwoxarutv1PJ8dQuY7OQCuf9aW7z4NGM44wOBmYRupRDbKtmO1m/VbTqG1w6\nIAhUEmrBgIul44mmcjEuqBIteBSltXdV00HxQux77BtWrsUH70wG2oSwoG3D\nqClXdZFykFAvJ6c3eyaL+6HD4YOYw5NkTT9UoxpZtmWIqc95Gq6amdFS2qCI\nCOC4N0jnBttnXBHV3hXZcCze3Fb/2gf4CVnKwb4F4+B9nVxhj/zlM7o+e27F\nUdZIeP0eR4jiUVCoRgp5FyK+ViOLYRYd3ZlpcWdTJKjABpxq9VHClPCfhGko\nhXYfyOyP1Ae7mwMh58ZIMGcO3qIcM9+AA9UaTyzoaZ7GWaM1nASQw/CLsSpV\ntSC6evoZVtjS0N/LEY+MrxUv0nv1muN7SQk7x1M8v/ecR+Iu0i4k9ov+uxLn\nfcHQIGgfHf4/LiIZgEkblWWG9NX/5xvtV75vN1Fkm+Ybs8bn+/9Ie5kLGm/s\n645t2e+gv/1OTvqei5MD37kPfq/2WKQ5yHRW28ggc7je6U29JEKB4RLVJ7g+\nLoSy\r\n=6H9r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0d0f5313a0393b3755d2b8c270c651fdf195f27d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3-canary-aa25177-1582577707123_1582577789099_0.13662005523871423","host":"s3://npm-registry-packages"}},"1.0.2-beta.3-canary-b7e2f15-1582578385877":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3-canary-b7e2f15-1582578385877","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.3-canary-b7e2f15-1582578385877","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"22f4504bde45b66316d464f21b69e7c08bef9c54","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3-canary-b7e2f15-1582578385877.tgz","fileCount":8,"integrity":"sha512-x2dmg0kLGP2WPSr4G2WI76IqeytBl6uCLRVu8h6GZDNfJrSZJAC8kWE0cLYF1dVN+uPdIli/FzfWmDY/avD+OA==","signatures":[{"sig":"MEQCIF8z34pmuoqVUF24m+2HfICOlraAKcSID5GEu2B1cEo1AiBLnUUMJaYzZHngv3C4BgzUH1LsHtTvo/ziBtxdM19WXQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVDsKCRA9TVsSAnZWagAAa8sP/0xc6MUO++pzN8Q4ahss\n5dyED+hBvhmKIVlWv41CAtmaVSmCVzGyrMcgvOn+QcrhWU4JZ9TnE0BUk5qI\n9vewXdFQHQbHCZOXZV5dk7aaOF9SxA3Pot2wA3twvtjxU4oty1Pc0ti+qjp9\nWDONeNjBz3Cnfy7ldBmVCBTFwzB1uwrPV8HU13RA0XAlDWOUaP6UsJWUq+W/\nLmItFCaE09izI13T04nrno/EP/SZu/dzSMtQRng6cWlCfoEcT/Xz3uw6IOeo\nmmROJgzOgLMjI1so2SEN6oe7NJKkXKfhOMeyHz2VZ1RK5czOku2GL+AokBAW\nLjIh7KzJvMHtWshXw++UKPNueIjhOl+EV7tx+ZUmoUeXIBfhQJ+wVIQVr5u3\nZRmtqYBdVqMmwr57qH3WWtUlsWvffMuqTs/1ISKaXZi0iSs+CgxbemRQBJtC\nflQXI7YRa2m7T5TB8JTawmAkxHLQmvN/DQ5HizJrkgdqgKJbQYzTOhYcm3H5\nvmwGL7RPV+cFa2kBzaLG5KcAzpKxA6yCGxwY2fDES3zj9MJ+e0rKI71xVS5z\nAkxaPHGwgRQ1z9BGBhs8l989MuUaSRkty0xCSsF+5p64aQksVDqLgHeERWLH\n3L+Ghwn1iPRAZLCzqqr9a3jrpJ5g3VY/+A0KdEmrM7nSSqLacofMDKJ7ceHQ\nmScc\r\n=VvZf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5ced9cb619f0c816397d41f5e4320a168d7e8e64","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3-canary-b7e2f15-1582578385877_1582578441632_0.1754735573742714","host":"s3://npm-registry-packages"}},"1.0.2-beta.3-canary-9e65889-1582578704239":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3-canary-9e65889-1582578704239","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.3-canary-9e65889-1582578704239","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ce471316f9619879a9fc701492a7cd8997f5f347","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3-canary-9e65889-1582578704239.tgz","fileCount":8,"integrity":"sha512-juxJYvAwKmiC4B3mgIX28REOUdtIbu3bf9q5+TmSclZtAhLV05Fk4tGVAZPUMnKVx3HFdfpaWcedA5kt9QTaYg==","signatures":[{"sig":"MEUCIHQkSjOmnpFGC2wwGSaQcpl/zHAjoCVX+S8HmCFqA+4YAiEA9OH/9VJY9COO2t7b0c80qjYvmogUN0LrXudO2hPe9VM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVDxNCRA9TVsSAnZWagAAA/wP/2XGkGX8j42bE7DLPw83\nFwjss/sCtBeFkUMpEs1FtnpBGYy86Q7OKkpj0BwK/5DCM7yQ7BIIWERqPHkS\nQE/n1+R7KUeOC1LAYbNBj0zbyz4OBf1q6uIwqz4nEsqpLWmwIdSM6dsmt0eO\n6zroFfCwO//3zbALPynsDgZo/WWyHpiOMjcqQcgOeH4gMb0bS1SS+tAhvzWi\npVTVvSC3YaMlbiHfRP49zDjWcXjQduQOO3FpYaB3asEfP+gpktp4AicsCwsJ\nPzA1R8R7Ox1JsXAOEFL0Bpd4EU5CcBbySB+OBSN+sG43tI59GIpPqF8K4SK5\nEPPzW6RJWoExes2qAYKjJGgJ0ikjUCTdIek/GIi1Wcj4Qp9i/r+qXGXjVKOX\nsCEsJ04goDSbM6R2qjlPXmbEjyMT72wGGaF5SLaUKWhgykaxPK6BiUTLKAyS\nECiIkS9ovobRp/9EgsBr1DormAIP4iZlu3dIVFiQ65vBOB1jqFQMOVGAkPQj\nojBBX7WJ6gow6Ejlkg81oWxxdC8ylhB32fG5JSQ6Al8izxBlVEPRDXS+Xm2K\nigwL5VaVGLUOTmBclvzMJbYRHojU+acsBm7n7CoKfoxmQY6oF/kx9GT9GAek\nHI+U0LElsBMAYuLgaugpVHqDGP/S6UPdf98PkitqsjYXCJdWlOErxandOEEu\nzZ4R\r\n=qP3m\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"256ee2c88917083276c34f332437ed7e9041c18d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3-canary-9e65889-1582578704239_1582578764920_0.27125079471032754","host":"s3://npm-registry-packages"}},"1.0.2-beta.3-canary-29cc612-1582615963044":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3-canary-29cc612-1582615963044","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.3-canary-29cc612-1582615963044","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3cc6fb267ad00db6f2aae86480e991f471b574a7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3-canary-29cc612-1582615963044.tgz","fileCount":8,"integrity":"sha512-qezfzehQFfGTWQlYsdi8Qwo1rpoTgjc2YQokjJ9pb5BUuU727XiMoC376gRYtyxCVzOTKYRsILcDrtNnD1B/dA==","signatures":[{"sig":"MEUCIQCSU/hNNjvCMHZ4bjDnJtcYmDYVdTls0yn+A76rksj3yQIgDIvQ9OVomV+XYeYG6F43AXOrXJyVPKa2xqUyixRW0Y8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVM3fCRA9TVsSAnZWagAALaYP/3GrGFrReCDZeRJLmSh7\ntTrvkB56Z4xukkFTz/YjubZYsBlL0GJPPaKyMuY2W2vGIFLP/urE095Vm6mA\nfNRKW9rQ7ZCrEgk2NIn1WKDudyPNSnTlnAzHsABUOyk5B0amGRjiZMp3npqR\nyrHVsGewKIGoEH4jWRTVtPu8B0I4D2TIAD5L/XcS/nf4PiQZR1iB/NABj3r8\n2cRDFpFP+zILzT+K9QOu0pcRoX+zNyT0EEEpu32OUU6wmmdNyxfcq0NNS3pf\nEtatL+xKan6NU/xOk3JTczQGvaCe8CRWjLzvHvU5FTT6S3iqtDBJs5+kLyFu\ngObGY0nuSxChZbhkUJxwaNOEc81HvR/CnkMCKWA4prdobsfqT7STmQYJwhai\nbx7uBBEvgDQA/fV+gnBkgsip5EyMzgEvmFr3+tMRfID87Oio/2jGWjDrLDCn\ncg/B4gHvT3/lIDTLqzFMbaNm1yyUBo8gURKR8Y9r7xuQss9ZryxOjob9Asil\nLTs2wCUJOpd36U79h+5j+yS4b5jkRyWFxjUd2ZVqHQCT6yqvFl15Ir20u+vO\nFmJ3P1TPyd04wqd1ZK4G52Y0qGbQCDf0RrE0b/bUFaitO6uJ6TL+JCexdSza\nondbl1j8XM3F3mTCAKCzreXlXX8ys46ltScNbIFZV8s/3of04wofHoh4c5NE\n44cj\r\n=L14F\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2784e9b6664791b91e446db375a3b85ec0d09085","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3-canary-29cc612-1582615963044_1582616031255_0.35654168266608854","host":"s3://npm-registry-packages"}},"1.0.2-beta.3-canary-5773226-1582616158710":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.3-canary-5773226-1582616158710","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.3-canary-5773226-1582616158710","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1e2dce3bf0ad0683a3e5f47b643767f73fdc7f5f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.3-canary-5773226-1582616158710.tgz","fileCount":8,"integrity":"sha512-qx9h/nZrRc+cIdpaDr46XNw3nKhLCSS6H91IbdezbH2h5yZARe0wPDyru2w7Y1d9sU3aQXsQSQCSJ/3TPd4e1A==","signatures":[{"sig":"MEQCIAfy8bwpneaS5b18pVECLepZCVMRxjHVmlk+p5kJKV0gAiBDJGmLmY9IZfwTdhLrYeM8JtehDaER7ZWTP/4p4vsOKg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVM6UCRA9TVsSAnZWagAAUOcP/3mSBI3yHY2EnK1OTxcc\ni9TfE3Vg/UXwXBAa8XwtN4zrW/hto7vrQNKWhuZ0SQJg/wi1d5ShZQlA+TNz\njA7D9tbCCMlrnQLA5fzsh/9bV8g/PCAzaI53hd8okALhBmGoJ5fiA9Q1q2rw\n2bD4QfI7DPY5pPOzsshUZTLXuMn0yJL194h6dqSOD0kwKJjCIMX26tS5sLli\ntOHs5QMgyJzFdeTOx6bbNJDr1p4w+8uVc36PMtrQUcyv6rgoKJ1zMHgorB5A\nwblRmKc4FyAov+rvb2kjYUHZUiCubIPDxFt71RkSb/+ZKwB2FHM3qKm0eyKN\n1mWE+NnkBoVtxK616kplmEuZJMMwj9Fbaen68pe6z8kbyr/OvlHF5YEgCtPe\ns4TJW3yG6ESbzu5BGLM3Bxzw4elde2oesWnpH1RvfY5DbmSTN+fT7rbzZClL\nG/9D/ATs1F1+YAAUjh3LfPTkTdcHGW2aZp8twtBeVNSY+ADFvzzIid5+9j59\n7FU4/ml/d/HTOl768iARNisoVGjSr2bVTeCVnnNo492rTQ/8aC40DLJnWHTb\n91plQBHKLM5ltq8uWlN9CYUJWzX8I9be0+4oyocpOlhh1d8NkW+ih0llR4+q\nE1wkQzLtLh8rDmdt9Frs0wCJmj5y36p9uFqWLJb+Tqrzm0vFzIDwfztT4WrO\nL4hn\r\n=nXOg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"961e0c4e9915a570bd1274ba9f16d6241dd18818","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.3-canary-5773226-1582616158710_1582616212264_0.3562116583960422","host":"s3://npm-registry-packages"}},"1.0.2-beta.4":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0963bce22b28d241f6cfcc74a2b70fa30a07c133","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4.tgz","fileCount":8,"integrity":"sha512-B0r5zOJH/FTLS+6A+FmNpozSXS7NPO1DsYgwYJ167Rh0Y8B9gl9yXK5SODwDa3jQMO58j/HjPIjKu2cLkAkqxA==","signatures":[{"sig":"MEUCIQDz7D2LX4sWNkzhgOCSk4QR1h+Hwq5WPd1ZCb/l8cJvZAIgEXH2A0aZbdLYzfWFjnA7ysv/B1mzyzD73UfZXh8WGZw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14006,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVM9xCRA9TVsSAnZWagAAL0oP/0VJnuWE+oF0I8ggY0zk\n6T+ydf47i+HThANxl2fVL+KpCrwmgE+qQchOf58n7wRSCn/OBI8XiWn9ba5s\nSgTr437n3Ny904S90gqwgq17tUXlzpGlF/4opy2B65ri1gi2BuZFd96JZP4t\nYKzNdYIU/Qv5dDhGeOqIg0PvVf5bryc9pJqepZXV7N2HfrWKU44q1H7Zg1Gu\nkNveyn1aENbcFqfo4e0p2j3c4znN7DadpSW2SmWflinQY2kUEcI25Ba2SkIW\ntPWjMOcvmY0/ci7H6bO6cDPxkrc7kseU08GDWXE0ez8FwOlMhbhUnLco+2VX\ndXSWOSdZOlJs5kNKu9u/PZKjw0XUhmazSSTnJCvMsPsatNeglefPJGcJWOjt\nBNgfQ/w/cjuRU41exwvNkiNnb1XR0al/Z//nD1lVERgfJwIrbuuapzlvJqrC\nxuJbfBP4ihwoDXBuf3SGWSmd0k9Okwt8GXCpQ38XALM2DHUbO6yYHIsCFHQ5\nGWYFiNFQzB7eSQqeR8oHG0sx5+IHQf6VF1q36A/rhAgg1AzOadMCPMF4bIiw\nwFpt/74VXgsYHeWN7LPtXNxqtA87ealzDiUlGbCVOwzUqMazRblkQ4Xch+Vh\nhDk2gStElGVQaJD1W6JwjxozDNSW7hw90GiGF8/QmVK+y1tj+MfaQUKyumZo\nb5Bc\r\n=9lDG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6ea99c7c3ffbf38e44c93f742b9bf442722f0ad3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4_1582616432849_0.0021140716675041027","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-b588baa-1582618324422":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-b588baa-1582618324422","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-b588baa-1582618324422","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c9edc1fecac921f16358857e9847e2f9befcb80d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-b588baa-1582618324422.tgz","fileCount":8,"integrity":"sha512-5CXvzdo37r3SUKDMJ1ApDWo9POfXZJvJt/foTWD7xAIep5SKLg4Jd9ZBByiGNVItZsp8GBssl1D450y6oWiyBg==","signatures":[{"sig":"MEUCIAD96+pWB5vaTOw6OwsPsR4DHUVxaTaCPKtk4FoMvgDRAiEA12bgyf7EOOaKcTGE9ky4Vw382f95HIGwtTHCehn+R6A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVNcPCRA9TVsSAnZWagAAVGEQAIPDVUlooUB8KO4EtMfs\nFjxUkeUvYExXDJU+J/lsLG1z9JhBEBJezRqaaHxIUfF6lJ4S3dBvBYs4fbnD\nqYgNk9Sb9IRCyM3xBysk6qS9F7RHfcH9nMwPbYBx2PBVOw/0S/ciRp57BZYT\n+QkaHqvkLFseJzOTkOfIbaJEf++TVue7/QGN6a8jht8hM6i5lTXzPbHcEG5l\n/jcs6TXmzIDN/YS/Yflu8Yah6U2J8mXzLs00gk6m3hNQ9sDwJw0BtS1AY091\nyUc0+dloxZ+JoKfsfRCGMJMQ/Cce8WxZCacZNUlNK8ooY3V1baBedLAuyBcz\nrhBcwMP3M/Ae+Zfp+wX4rvJ+E0nfoXaPn0eG8VzhMEdHtUHczpYw7GwL9Tuj\nbNlMXpW7oI4eVsE7pnCPGmL/I7KmFyGx+YgLlGmXAFtT28yQMRnIe5VNcFE+\nWA6LzFWr9O9ilI0F1n+QIO2wa2sT/DRIq323hXwAa84Tu0I1wBp40XIxpyXW\nlFJGxko16Vfo0ybd5O2joO+o0oo1mdxjj/ztvNbajpnsGCjXRQ65bZvqOuUk\na297Dj8AQgLBB732jAXph1Fn3euTXCPJCPaaixQRKSdbJtW/r4+WC2pUcEHK\nEy/ijyLgXQxkWzA7fgMN0GvlbbPznRTfC6Mv/fO/6VoMOrQaMiGxbXN+oquX\n+85s\r\n=50vK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"00b04957febdc664115e4a0e95290eaee1b02721","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-b588baa-1582618324422_1582618382504_0.5155165741938084","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-f3baa1d-1582618348828":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-f3baa1d-1582618348828","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-f3baa1d-1582618348828","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"119b0934cd03199e946ef47cbf6d554c83531116","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-f3baa1d-1582618348828.tgz","fileCount":8,"integrity":"sha512-I284HP8xQeYDksZ8XOexcjZUHfZAJGfPeRRGwY8HVEjTfj3EcLuPj/vrV/jfyskX4RMXjaMsOw9XaDpq2aPbwQ==","signatures":[{"sig":"MEQCICUdd+7f6bY9jDtZmtf7wKI7Y8XyfEb43RU2cMYZa3gnAiBWNEPoVeLF+TI/ZRB6PR4KK4XodkZOHqA1Z84gsT9R8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14095,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVNdHCRA9TVsSAnZWagAA9iMQAJweK9dBtWRHNDiigBXo\n+u7NSP4EQWaub56ifrRQwBe9P+Djp+c9DmrEdD8Yt56s6wUL9v1uEjpTipKx\nIPl8LSvpPgqiURTkhHBrN7/50qRmw5WakfUt3V4dnpc19lUX13fuqtP4UFj7\nhZO7d/R8kOu81tQU9v5BD8FyQ5dOmf00Fq+VJQEsBZ39dC4VlWxPEUxRxb0/\nRPY1Lp1/IWfXH4dPELw0oKF1dgHtfyITpB1e5cTy7EU9Uv6ioteZBj6lA5/H\nm4TZkvvc927lAJfzDHgEHExNuvprBRpF9yIHwicPmPG6lleno1bX7vROfnwJ\n+xNSq9Jfqc30QlCGy79AwIjCFbnMhfB1rGcYI6i+DyBRR6QyOCFMrv73h27F\nycIj/cxcD+bcx3uQSQyN3nuFHByFt2IioglgpcRqIx+FevL/7z7/lLNhayoK\npSm4rC01IEe9ojSL32McDC9EGpRjW2WSP5wLVL3oiz2UXettV75RRVh/cCkH\n/2ku5GEoeuSI8ZXeit5c1eftzAQCMUE60KV+Tuj/0heRUWYq+V2eTQyrDgY+\n/Sfa994yZ2vKCoxG8mUaYz+vyQGUXikBasGuV0bNCMIdJlowVnw7zbqHCKQ7\nW3HMWBz+cghgf/B1+ZznpPYdrgm5IUgS8vFvekR1EV78x1StP9SeMdvU3Z5y\n6UMR\r\n=k3GP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6abc353411a6570b9036c3f0432ed3ed1853ea47","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-f3baa1d-1582618348828_1582618439437_0.22009119700296753","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-fccf77b-1582663254431":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-fccf77b-1582663254431","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-fccf77b-1582663254431","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ebcfe9e32e0a47410bb87f8193cb48c099788316","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-fccf77b-1582663254431.tgz","fileCount":8,"integrity":"sha512-U2PGDNArV/2NpS9z1CnD43naYnZogDF9/8dF5pq+nE2Busjr3GLac1R+H68SqccX4FoEiOvH3dIQhE1u655sNQ==","signatures":[{"sig":"MEYCIQDTR0hqd4vZm68PMq2oVISox6viA5MxsF4n00ymPVAxvwIhALfw+WFVibQ0Zd/7Yk9Qwx0uV9OhG4IxZfaLsnzsEmcd","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVYaMCRA9TVsSAnZWagAAZgsP/2CqFt0PPbAiwwerdnKs\n2SXYM9v52qCvjHkcXPepgq1zw1ClGNlbsGa2bSIpPJtzc32loUmFih4k/xXX\npgwYoK06vxR1svy4AdTPEzZDYHOyV/qrDLzyHDhZRg5U9Y6YHzKGwmPOvpyq\nmgpFd7L+3Pm4d5jbMRqBmu7qJM1i2le+vl6aRd/KUHhdl9pG/hWu92Y10XbH\ny9neCWJs+WLtzrGkvh0uFAgwGndBsy40O1c7UI91DKgfG/rmPDkDCG/8xh8l\nKBamMGkOzjTAiobaHP0rWSsdZCcAcFQXCKYLA1BSGX2eiSwE1nu1cGAtB4Jh\niKhNK5TWPHD+YCpzElgYBmn3ZpZuT10xgcVK/kIrhOJe5SlPuxXJRSMvpAiM\nga2I64jgnDXGQl9t2nRO+SN9mbfUwMSKvUpeKtkLLe+SFCRLUCbuakFCBJnf\nZEoqVj9R1i1m4QZTTgL4MJBTU48ydCbVlFOxdB1UYNgvnG3frFqdcEeVIyB2\nT1k+0k+ut2k/QJ+VV4OQpaILNdaniJ4JOsUfQtpz9jt3te1xGuTj9s//Weri\nYMHznAqtFCwCDTdCnfoklh6WQrGoZF2guCy9dCz7C4ZdQ8mfn3nj26jzNYbC\nnGyi/ifJ5otFp9lHqsp//IH95PLlES0c4kAlZOzoupaVxewg80pvBxqAbkJs\nLlMt\r\n=JBXU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b518e74d600c66ea4d272dc90181a74e0db31ccc","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"0.0.4","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-fccf77b-1582663254431_1582663308195_0.7206115719331454","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-9680a22-1582713795612":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-9680a22-1582713795612","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-9680a22-1582713795612","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bc3503777f6b1ee2e0dc28ec7d15ba824586c7f2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-9680a22-1582713795612.tgz","fileCount":8,"integrity":"sha512-qlE42sAokhvmyOdDEr6Y+VVMIsobMGMRr/e4i8gduj/CWuVVZ8U6CrxUAFR8oMAMwHT2YpJiEmYp/8yp4Z7UbQ==","signatures":[{"sig":"MEQCIEVeYvcuqY2SVkduDVmfjaO6jWaT8L9V3fsL/CICP1G2AiAUMuTjztZbFOFX+Csn8cqBWfKQrfIdDeu0UJl7Ncw6KQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVkv5CRA9TVsSAnZWagAA0WoP/0bVwLDovyXwcrs9N60j\nPJfgScjAXmINjupCF1JcFgGHrDiUEzDNFJVYf8tLXlxNQQjz36WZLL2w6R1x\nng6IWN/eOv7QTvpmblob8heODPd5mtX1AcG6ljySumskY5DtJtgnTGN5rEJ7\nPxz+d4vTCMOmiS022TRQT/y30u7A/fX6mvrCnKeDWOfn6ySH/GFLtA/3pPFm\nCDopFHJQ1qO+lm3/2Ee4IlactSMy3MCm3IBsMH9HhktYdj22NOCCuUjEW1FA\nWBAFIrVnXenOHCuLVTZaNz4r8rwSZv14ikRI2OJTxDpb+5Q7zN1AB79oni39\nhdwCuOnrLyWK0qnykrKzUsWbjcCuB7ACM0oTTczAB++xiqKLpDrfzofB0ZGC\nGgPOLNNpZTJwX1wn+uEDxlKKzMaxH+lrkGvRwUR/nvnV/AP6UtSNH1cuyBWg\nbzcbv1l+VrLcPsGG2IHSORBP46fA6XNwXh50C6bLut+vV3hIMENBfU9T2gkw\nVjPiMpiVa6sm2EfYg6hdkT8L7E2Arl2B9ij3vwRxHzSViJYXGQHL8IAxqtnQ\nE3cQDzcPIeceDFNUQ5LOfqxkG8EYYarWFvumdAdTsZU88O0EMhJrpRIjXhFH\nt4HeOiZddY/2AZv0hogXPAFFJC5Ti0sq1+KxPdEJu/BGUcv15Cxy/hUYxG5L\n4l5P\r\n=8R1m\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b26687f6560306ef7f921aff954205dd61f1bc4e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-9680a22-1582713795612_1582713848936_0.5860128328875476","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-66f1691-1582714072420":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-66f1691-1582714072420","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-66f1691-1582714072420","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b28b63f0ca72b0588845a2ba04f10f8b46e84c36","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-66f1691-1582714072420.tgz","fileCount":8,"integrity":"sha512-c2bgJybSOpL6PkhrDHJ1zP270/erDwHcrIekAgsu7V+1H4m6pWDbIkWGXyzuSVHkfq05TCkVrk0NZqvUBP51yg==","signatures":[{"sig":"MEYCIQCZmaMXwlWpuDnTQdn5PNjLp6d97v01c3y4Wtw4r2v+lAIhAJ9TgjT3KrWBlvK71MrEL78TXXqYBGfqwzQs81fIhjk4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVk0RCRA9TVsSAnZWagAA/k4P/Rd1NZRd34efv2xFktLB\n8ektUHBgQyUDvX9S9ZkoJXJKytTydKMMksyiJtfqOXVWZjIIkuVOK/0GY4ql\noxlLi/8Rv7fNm1U3oSwqn9g203+/5XivgcL7csuEM3OSzcmSXif84mahg3M3\nF3GQcZj2naR3KEyCa5SGw4mCDTlVGiId3PwhtwiwSUEFcuI/GWMKTzskudKH\n76dng1exzM6y8uKwfWcA8DXt8ZcadfcEdrmJpXU/xS8dLMSv5Ni/uLBVYVqe\nSIcZacdtM4Wonp/n8CR4BevMhWmZJG16nCUk5/tVlTGRGtsp5O/VN4J7/4XG\nP8EPoLfXJTQOsxuapKFXFrVvYppooFH1OKO7EGbmwFX8HBG0WQjsrgpNVcVl\nInLx3TJQZqFVohSISqlmKqTVEgurkI7sflcMOTYelAb1DeVCSJiN3gkFtdvB\nR79Lluh99uSv9NxXvupVw6Fua0u7jKCv1DU1Hw0z81Ia26FOVlglX4u6GOzl\n6YW7dksy9B6tPCbwvdwfUe+h0FEr51ehP/SVfbXt6WXt012eCVK+ssogfLGU\nZ6W10DbkSDzJn5xAy8wa2zVdixSyHYvT+f5MxvrCF2zcZ9SvuKQmx79gAAPX\nHfxfbmBDOK+Xv6nOVDRAVjj4ESqhCgNoodi9kODE49ePzkY1ZM1ofhPl/9M6\n7ZWo\r\n=T3Q9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"647d9e573b809adec7dfb4aacaee9473738eae76","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-66f1691-1582714072420_1582714129191_0.19474389326591224","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-f261b22-1582716244261":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-f261b22-1582716244261","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-f261b22-1582716244261","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"894082a735c33500432def80d8a637d595542a68","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-f261b22-1582716244261.tgz","fileCount":8,"integrity":"sha512-LmVA1xRDZnDCsr5ypOkBnkE/GCTSd8XpK0OU2UOaDY85c2XIvD4RL6MMhANW6mQQpOgP5pXjhOoUlXxckzbFbg==","signatures":[{"sig":"MEYCIQDh1inXKt/DnbZKdfP0oS67lA9x0ZHHWJK0bogEXRl2IAIhAMXhyDfV5VZzFh71ZGvkJ+ta7FMW7l6kNIP+Ma4GHJXo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVlWOCRA9TVsSAnZWagAAQoAP/3CpLTDfJkAlSPX7whMA\nA2qFNQ4mJqtFf4DkxMT4Ma/KOfMSWA+s6Auevbe4WzQ5yrRJMBEnldc+3X6t\nbKV5+xbUa9/EB3izqHa7kE2jrTgo+OTy4yYodEU6qF8TkEXTdgtpE6XO8Fes\nPVpEvu9KzkEH6GarVxTavFWvqkw1O2B8a5Wfa1LSRceE18w8US48mU2KljI1\nZx176jLxjqnojDIQOmh4lBS5CVICbnCkJeQr6ljdGJ3IsuLbUnLZ3vhvkXzv\nupsuS/COSnb9Y+IAzePnLmHk6XdK4eOApQb0sOZC5RuGxC2ZZiYsu38AuyE9\nkqSUh4iw73pfdTWedXrn1XeCR72q0O+Qu4HV7l6sbIOfZVPjeoG+zdlrw28w\niJWxHj7MFpmxoQEvC2mGYVxnBaKo/C0dP9ujCcgAFJ5dmr2TQccTwUSkkUJl\nJM/CYnBimIj+ywE1X/Juji6bxAo0jaoKbNoXzJueAtI7yyHoINe7MHciy2Jd\nVN8Hg31hUWGWWsQhSKf31f6I6sBZ52r8B5quHeOvIIIw3ps1LR0FtajJOznB\nh93BKJILjPp5dMXBeL3sBSr9ESuK2vRWdpy4bmLSdSHgyrEkDLUA0XXiHaYG\nw4IdLH5F+4sjp2tWBnKNhzGZ2GjJlHYe//pLvGLB8IkxSYEcd/uJ/9a6uJCW\nshF2\r\n=e83r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8e5388a0a42b2e4a9aa8c112ae734e173c1dcd7c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-f261b22-1582716244261_1582716301880_0.952787186932855","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-cec2caf-1582790970733":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-cec2caf-1582790970733","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-cec2caf-1582790970733","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f75c6f282546046e4c6be5b78d050aa71037c98b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-cec2caf-1582790970733.tgz","fileCount":8,"integrity":"sha512-HNfFOhFyDlwszbwQ5+ta/24AOVG0Z3pTcudfCwn6YyM36ZTpFho6N7dLtnlVP/d57MXnpuaxKePxuaUlpODnKA==","signatures":[{"sig":"MEYCIQCohpBBGnnM4WGG+4GrM0d/xjVokVaR3dY9NtGBj218+QIhAKB85nCNAq8H4kigpYP8D9zjpTzKM3gHSVZ2cmn6blUQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV3ltCRA9TVsSAnZWagAA8GYP/R4p3iv3MdeCKc8C7s8O\nk0OQwTwTMbO4GTw4BhwHLQ+lQF9QKXPXDocPJQqbbjFbsitUu7fR4sjxC+BM\nLjG+lUh/Mx+7kCSR20BwNcb6/Aom2jOjb3tOfqcth8KvLK24Jx6Tevn95/rR\n8ITWia3IPqpwXCo3VIO3/irJEoPNqOifPoI5b9LTcHpPNfOXcq9YR8Rs4jUs\nFWeEBU/bgKbawB27n8DOw+4iCcD8EAZbFIKadXdTrvmLIQgdihpgnIVuC4q9\nPnM3QVzVt+pEvzTW3BxptvS9Am8y325PMRiRp6CW8KXKE/MOrjJrFKmnX2Af\naW/2cCRGoex37v56f4jwnP9cGaxGpJEod6WMUoWsstoVsyscRuah6U0pcFKV\n9fWrGMr4kG6mmvS9Ost9KyRI/Xyt5CfQqDpYlW/ZJPaK99tVrtiMe+5PqBm2\ncrWI6KC37/TgQl5jsE7xoQGQhJ8JjnmgIqKDqVBeP9pgb8tuUxijI3XbLkyX\ncD1Ao6OiBw0FvrL0E1Hf0kvQGrlwDAgBaRhVBiL7sHdVem7BfHNkwkcmmL+/\nXthRGwEkFGdfcTahcpYFTnyoJ8i1DL+k4LOVoowBH/3cDJ8RC9nVENL06eBu\n55B/8KLJ9WE9UhEPJg8iJeyQOyHWvBS5Xpe5RC4yNSKU3Ubn7n4Bz9C+j/0Q\nEQsH\r\n=oOKl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7a08e003ebd4fc2c519aa32508da8fd94a42c5a4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-cec2caf-1582790970733_1582791021140_0.18465040969145674","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-be25631-1582806431978":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-be25631-1582806431978","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-be25631-1582806431978","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"191573f40f7dd8ffb5231e43a6a383169e7d8e64","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-be25631-1582806431978.tgz","fileCount":8,"integrity":"sha512-Qg/qHtd+l+AFgHW8WTdtRiwFVbXH6PUVqvloDv5k68EEK+bAnJWh1ZcBqCApA1u+9Pt0gnn3fHzHqQGtFCdXgA==","signatures":[{"sig":"MEYCIQCg0crYWRkl2u34X7RZuMrl7FQ/T/AFkxdLVuie99irqAIhALKph3290GFET/Okb4duGyY0Y4A2INhBz26G4IVCOAHx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7XUCRA9TVsSAnZWagAAkxoQAIocKsIxfl3avLf3vJ+Y\nv4ci3gccyWGkR6wOuER54Pfb5EZAA4E14zCIsBH8wqnIYzWSdw4nbUupMdWo\n1LpdCk4k+7dADC1JDYkCDv448xEE156LkpvuW8YBqzcfVz58ZHC2GH8wRGzD\nRyS8U061PVyOApGWeymnsbBEIi9SY05cmfaNKOHV4lJmdzUp1z2VxzbsY2Dy\nRiEplfNLVJaZ5QfbaQkuKFSRx/rGtur+Q2Bg7xxlRX8AwRNvWfClq+kaYnZg\nej8xeN0+Ps1vlAaLujQOCySIXVP6hVt+lNl/UnG0UdzmMBi8Qmn246kZjwS8\njY+epBHhYh2COqSiNTzkrK32hiSv+Hw/2KNgETt3LYe/8AHZTjUAwmeZ2PPB\nLFy13FEPNIU/mhlH+6JHj8YiThE0RMb4Eo3RH8W0j6tpGDIkadJseKnjfJ9l\n7KlNrrh/2N2jf2bd5LcLRYOo5YAZl79Vv2kepdOvWVhEGl2dgyvqoKqdaVXK\ngA4vDWjgzH4S/wPiEIkOwe/r33l8bbR6+sCq6Jk/BMWBO6NmODUt2uTwmJKX\nn7xAnzjnXCNNzmA7pkY6uHUIkXxYL2uSi5maDZUCXWCDmR17Njoye+ZGoBrp\nfwki6i0mEpbCmQkt87RAXr4QwzhtR3INiIamOdkROyD5mhZ0bz9vhfE86m0G\nPmgl\r\n=Q3Df\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1fe8aa058a38b844d986d3167b1aae621564ecc0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-be25631-1582806431978_1582806484399_0.003759097920018828","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-28b4ee4-1582806433549":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-28b4ee4-1582806433549","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-28b4ee4-1582806433549","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f1e424ae80433c065ba38e8348e8920af406fd37","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-28b4ee4-1582806433549.tgz","fileCount":8,"integrity":"sha512-tuhzoWPc0m0uEowL1qJQmZbDPq7BoeTVniNyW2FWwgI2ytUqcYOg8uMZbLvESL8pZZnMIVnZWMAsJ5CZ/ozLyA==","signatures":[{"sig":"MEUCIQCvunFXZBhgvfNt1HoE0CzYHPlJn8woAX/NOaGgdMLkbwIgVgHPW5a5PVpv4Q7nf3uJ75Lg/m2kmIZ8BonN/JNL5xs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7XdCRA9TVsSAnZWagAApdIP/3lwUridfDhOf40+Qtg/\n6uZs3g1UsJjtKoiKuM67wRcmp5Jhn35LHanPXYr/IoHNWt9Vb29s4ei5f2Tp\nAfAJMFirxsCJRD6n0/Ko90jbepqfnzrZda+6SYF/FfCYi6kJoUC9of6veBWS\nGui1ggxpSA4vzYcsWrTdSEA3K0ZTfFUuPrEe30D1eaMD5fArhbQrScxqYR1g\nu9NhLE7qHTUogNHxH3TjfJaoq+qchPJkekoL1zbQ3DGA6ib3KMd0hUHbvgJ/\n113qeV4Z3lC/9h9Gx1Eo8FXFs1/ri6zj4HmqBz3yJsIEXDIQaUd/1yCiyWuA\nU+iRF4KkMNbVpwEgn83JrIRJfmYuQjc/HSamXHF9yB8pOL09WBitkPfNwPqw\nuN877MsZom1J1PBU3vzk9gHoBH7vfbqKG4o8w5dHH4h2rGZ6wv7k1RR2V/2U\nl9FXFyOGXBLnp0RnZzIjo0xq9OkRVB4UnVKqy+bUG9TENzCDRM1pfeixdlJz\n0YDh6qMwNLUcuD7/BkUbrkuAX3LWvhFyG+2QccxVgWVctfvwL8v2zyXElMkT\njvAwBdSv4Exihg05zFhMeu7FiFTJDc5E5bk72YvfpkOBhuremCmT7eovFkZ1\ncZfxVunVrBpW6Zjuv5hPTvPYq8wO56LeTDoo74VJfWrCp5YOH/P6h9E8XPrk\n1Q6p\r\n=uF02\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"47a105398030606270afeb2a4a036cd2691843d5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-28b4ee4-1582806433549_1582806492824_0.4641529762373633","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-973c20b-1582806446205":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-973c20b-1582806446205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-973c20b-1582806446205","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"df1e12ed1dc2a4480a65a7d759ccdf3d0c11f6e7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-973c20b-1582806446205.tgz","fileCount":8,"integrity":"sha512-4CS+ZsUb4rmLIA2STNLEX2gnh18UvvHasLjPqio5l8wRDHegF/M7j7fA910VEXsV0AeeZKHkNf69pNLpMM51lQ==","signatures":[{"sig":"MEYCIQCKFF66IrAiPaw7bTulmfGiYbNh5RLXrCwO2nxj08Q7fgIhAN4D7edhEWIZSnvncNRjI0xRoursW5ogTprF3H57+uOU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7XkCRA9TVsSAnZWagAArZ4P/2k4h2wsQgA2LzkVpvF6\nwttX3NZuX7cC1aJGXWYeOizLZEuz9y1s+1PD78RF4C1E+LwgUhF2XFtFv9o8\n2BPM7whUGHtkYET8+eyheyAnv6roqn5J1oJ222RkI2guXx+sUd3kCwbq5DRv\nwln0SPF2Ue2ANeg/sRs/bZtIF3tH1V9olYNTnUz1EF7bj60sNP4xA3VsJVum\n21ITMbKixyfG8IY6nUaDR3cDZN3V7jQwBWfdv/w7lq0E2uGaJCHkHlkZTfeo\n5AomziD+il2d2bsNnXzFRW3HugOGHWUGOE19LS15WDjBm+6RAGZl1sOzXKnZ\n4IMFCLlB6PxMmX8nVFyHm77xYFKgIJMi12GXae2bXVNKE0blzqDTG72CRZjS\nt2ecEO0jpb8l7Qj5gRKjMhoIgs0arFse//T+NfOK73T8UsehN2l2Q+4cVMu1\n4PfqCWMBixoxzQB85dr4mnAftLx7QGt65Y++fCAUz8Dhz5t1Alin+huS8E+4\nfzV3tb60k/Mn1aog0oWOUAmmnzYbhQMs5f/dcZRCB6MXr/EfiAwFT5ABC4yQ\nmA6+Rn1Gm6cqXfwZwKVQtCysseaVjPjNjoEjG2lqbAmSqlhMwqI5XYMOkyBo\n5gXhh5Yp3+Y0m0TGdUG4R6uA1IcRVyPlt8pv5tHiFUYOWCQT491VIRBWtfmM\n5oQb\r\n=GHEu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9a8f4ed9a5ca90e9d3ae3018b62a582b33c9174f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-973c20b-1582806446205_1582806500147_0.6583884711083676","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-9f13efa-1582806711779":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-9f13efa-1582806711779","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-9f13efa-1582806711779","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7ed20630d70df9a1ac1aa1ce54a5455d2c2e27f0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-9f13efa-1582806711779.tgz","fileCount":8,"integrity":"sha512-JjG+RJ8IpQJZsQBGfgHtN1l2YWr/tn7OaRpMqBaHTi7w4B7khDL+IwOrNRlw8NYl+UykjyCIJMz7KIBUxFDv3w==","signatures":[{"sig":"MEQCIAbeEMfN/6h+lSFIewHGV2FGA2SZG6gnpRT15P0JLx13AiAm2hZPw9MOWZ9mmtNXOwa+qPMmiy3kJiy4rMfdsfQt1A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7bpCRA9TVsSAnZWagAAWn0P/3COZi3TdIf0mU42SNik\nIOges94sU8zOnDSCD1Iz1pv2ScqMNyyt9G3xqcr06hp2fdAsQC07Q1tN/fPH\n2FfMywEe83FP5+tghVQE8y3p63Ykm6jZvSDPNWrGILUzLAPAbDA2LIK/t25i\n6UPx5GoLV51RbxunIgIMmr/ePKYTtU7JoUapwiqsiE4cdGnc89dQ44U58pnN\no9LFy6cMUP6wvofbV+Ck0iiYzhty8Torl7vVRnHk600G0XTMTfpCgQgbYFuA\nZP+3QagV2FlsP2nuKA4g7aAyd1ypxEOgQsM6VxYBSe9T1bkSCCFJJXFXu81F\nZxuiK8S55bp98aWafiZXfy7So5y9kSrAM51GEpDKvbFamJXGahoJwNqKJpfA\nvY8I6aiU+GHt9wSasFnVLW7ru0h+jgQONiBdB+olbxSnAKpUBcUE5ZFeoxPn\nGZRRtXYTSfoBhvgPO832/X0ozlhvJj1Ukvl1/6qnWjXDgJPW+OHP2Dgxmxa8\nHH+RGGMC39BOa/WcxMxgMz2KOenxF81X2bYf7vPIeYkt6YjRmblyHows20zL\nt4vy02eNQIwqN7t5BrgOhE0JErETputpxviAQarP8t3r35jtgchHSc00GmgF\nioXt6Q9IZccJELswyDZahVvBJUaF+oKaVmGe0AdWoQnZZk3bC+N5WIp7fGDY\nMYLi\r\n=CZsK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ea2394e995ffda7f2bde0ceb2c287a4b40ac074d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.0.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-9f13efa-1582806711779_1582806760619_0.540414058770432","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-fcf1c67-1582806840760":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-fcf1c67-1582806840760","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-fcf1c67-1582806840760","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a5b44163bdac3a7a54fac967249cd8ee0ac2cee4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-fcf1c67-1582806840760.tgz","fileCount":8,"integrity":"sha512-IedlLWOR+hkCo5kQK8C39Iu14WQ2rh8tqEn3CrWyH8ZlT6EMKbbZUmuTbfzFRu3ab9q0ZOlRVERAZ5bv6QRlAQ==","signatures":[{"sig":"MEUCIFEvIMV2JGfbrcDmZk0xOqhRCnValr5IiUVVPKUzaR6oAiEAueeTH22kom4C9XkF1KW1oehD/Qj62604Rt0dP/d5Jrs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeV7duCRA9TVsSAnZWagAAxRYP+wRd9leO9E+5y5jxoNdg\nBn2yLT67F/UQ4ovM7OlLfTQUSmxNxmja/VyfzmYLA3mQvgNq978fWkwrpXQY\n8KZ+PG4LnGg7Tz1gjfcrLBW9NF/zhkKGGWy0omDYitVCynNAr0sq6cILcEy2\npqamBI48WgpkUgvblqVcSA+hIPdka7nIhJSy0rSu68RvEIuZL1lrQFKEyz5a\nUHxwX9IcG74dI05Zrk8s6qAgj09Fbp9WrjaSBnqp0hG1mQ1xageZZaa2CjEG\nGutpTvYdACfunYzpKig+McTUAwRXSYXK9IkUZtgO3FGvigMS74iMWEO0oQyN\nkcmLcbIRuv6MpGRGhOeiPAIEP2jkHG0qSqm5XcKO+71TJBidV2uNRFVmz12W\nGvym0LDUsmbs1wZPAb0F+FgFpLQiavKeKdYxlk8oWGsuMd2dS7LTIO5qzArp\nw0eyZnjsC6WGffSyc3MQjCDJ0I2s11iC/3505mnNPOMmjL8z3Mo6nmkT196T\nVUNCWt5Yz+x9TUF8buD9zGz/dz7cqBuA69uUaceth1wXeqhNQ8sy9zF4oo3E\nZnexEmxhtTONAJxxGNVPKOFQhn1nWPGMb1k28hg+SQJ+JFcNFhneQOCQcute\nQeRhuy3qpLhi+49z6ReI9FvNz8re81i56MLZuNhk4odVXL9dT94ZCRkdb4DB\nWueq\r\n=2IT/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"86b023e36f3f902d18c961fa1efcafb08ccaafda","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-fcf1c67-1582806840760_1582806894511_0.5885317725289312","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-3027e21-1582832223725":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-3027e21-1582832223725","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-3027e21-1582832223725","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3654a83213386445f06efcce469ae92dfd13fc7e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-3027e21-1582832223725.tgz","fileCount":8,"integrity":"sha512-x7RmkgG37nm0arDvha7QC7k5NUUqbXrHUyhxLMHPSfy+shpGjB6R2Qzt9XUFWckAEPklsZIDDeBVPgKEdmfrsA==","signatures":[{"sig":"MEUCIDp/hpCN8aLJ71wpm8s/UnIezmQsa0/kn4333EH2aa/bAiEA2joUclrEB5pyVcgskuZZTW7v/OAXe1rHbxyZA/IGMeM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWBqQCRA9TVsSAnZWagAATZcP/1BEcRg2UYTzMXkzZjf5\n1OWatkmuYAMnqJep1eIx9KV4gta7KX8llAczHeNweMDmF7kUI2LiKEG75C+o\ndFvh0AFQVQbKz8ygvqIxu0cle/LGbPmTkyJ0ZlimGcLNkLhwTpPaIeNHwIJO\n/xkP/BWt8lfvJvFkT1RUStHcJKgHt+GF5+rPpxa86J0s9V6cGUZsY6p3p6x7\nKWGMx8AjZqrvJrVoHS5afetcgWVXaMHdd9Khv/yJaRNiIOIEBKOQ/CPbRPqq\n+Ahp5agwJG2KOSUat+7raOmSs8hC7uq6+tj15gADO9sTqS9s1M8BLbwmf+jO\nBLn4TlKqu8oJC3V/f6Y1iHQ5Kk4uA5vylVpxrrVHl9CGUR5Qkb6O+DEaWIKV\nCdm3UfPCAj8HxJRP29yBsp1uMHPDJ2dXwTWGgQS8cU+KDEfAdNx1IMjxL1bA\n8q24YTA3F8mZXgFDGafXpeWVYzSa4/tg8GwRcX2UjfZFiyUKqT6ZIv6/Nx69\n7KNs8OfaqzVsls8u00PSvaB7y43aDkT+Ae5eHKSu5FnEJ14ZOkCdc2I8iSA/\nVdzU+QWAqZW7GHCFYUq56XObsNhMhvR3U2hC3NjSdZBoKHxUuKkzXCCJhoCh\nrJZ0TN7uCjFrlPYxxzXjszGqJ59cqgyDisw68TW+flAhnzVjAN8SV2rbZe2g\nAWyj\r\n=irKW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1601c4bf79ba35b3460a3dae2bf0ea453a0be84e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-3027e21-1582832223725_1582832272203_0.3213759011621149","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-bc6bf3f-1582866476413":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-bc6bf3f-1582866476413","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-bc6bf3f-1582866476413","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9f9615df285762f6fa0abddd6cd059fb42a9cded","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-bc6bf3f-1582866476413.tgz","fileCount":8,"integrity":"sha512-8yNS1XQp+HMHe0o/a4QCRnljFGH4y8s885ldGSVQrIJgrsAwi3LtDdOa98jC1lygcd8dWT8RzFY4NpPvib8kEg==","signatures":[{"sig":"MEUCIFGll2+ruEKjYVlqWpPE+qp2t/ADr98MSpao3V+8VyydAiEA3a9j15S1Zm/sj3aJ0F2TK5Vp4zuGOlv7gYB3DoWvgUw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWKBcCRA9TVsSAnZWagAA+gwP/0jkinuczrYsQbakHys+\nS3IbddOwkTk6A8EDs58Mv+v8iPbedzSIgPIXwz3YMXWpwRJR91pepWcOfCW4\nuLSC4Dv8P28LcZaR02th1bCw7hAOf27Hl1Vyr+7atzjIlASvTKKpx3KIdC/r\n6qJ/3GCbLAxA4I7cJJAzpXMo+vscgtT5/v+691O6ic2jT5s8wxQIRq4Yq/qE\nWYjR+bbJf5HcQf4EUgBqsL7uyRaW0MJWaBR/Fv+7CpcgPh1CRck0z+Vbk1cs\n13kPgssCnxYG3qjpeBuIU1VyNgWCHICmwFqoOM6hCAklkH8EMbcsiVWOSHGv\nXiJ8zB74oUbsgwaEexZjqDyXxnylaQht2yJQ4nErpNlq1wYKxI7StIA53x2k\n+tRgFUJXqUZ7fXJhZon9Z0mlf7XcPZVFkgBiAmjwb6Ix1z3nbicOYBJAPFMv\ntoLFjob1WZchBhn34y11lr2A6YsoMlsJ0yvQs4n+sfSSBsUb3/mFyvYn+4m5\nda3jcTJJemhiFYVsgS1wZ8XDSmHhxQuj0MjAvP8jFUc+U04wIMOK7Srpxz2R\nCpL/P8kTKmMcNPetDvDoyc//gIOKtBzQpo2G2sYv69HZk9Au4LVodK55SIsO\n1i3bHFr8lVMc0gF3fGxG5MLfcnHNXpaJfijZJ5c0ZcRRUB6VGkamenqHVhPT\nC34a\r\n=lFEp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c1aeb74d11a956f2ca431feec188b9cc1357649d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-bc6bf3f-1582866476413_1582866524329_0.567692827792774","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-9bd64d4-1582877000927":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-9bd64d4-1582877000927","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-9bd64d4-1582877000927","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"927598af767e146a754549bc5974b20f33d851df","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-9bd64d4-1582877000927.tgz","fileCount":8,"integrity":"sha512-xB5i3taEMcfEkkQyPCMmVe8HbOvWlVMR1sgQG+gQpPDYTzkziqehkOnOkiHd3soc4pzqm5vEKc50jYXwuB/2GA==","signatures":[{"sig":"MEUCIQCT36gcWrqSsIFl04Qm0DHOaI5Iv/Yc/WuZ80wdAfrsawIgeaiP4ZLdaGC8DACwCuMDw4Y4AGcB5Zx6TRWEzDSabxQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWMmBCRA9TVsSAnZWagAAVn0QAJUlKaKawgQH51mC9v9J\ng1q+kQzw6zg1X1A74dG86W0rvLs33Lrv4S5RGlu6itCSzTII5QxeZPyDWuEe\n5ADWvcLBlBZjdbhc6bvb5Z7MpxuaHJ5wz8BXEgOxoKC5sGPuTCXCkYOgK9L9\nw/PnpT4EZcE6njr/KtIYFGAPFr3l/zTDWMuybchEHR8fmgBBoxryakfCGkwT\nR2Rr8Mt/YMxMSwT9fWe4Vm+prigDwgCXWV5ya9Y2TSSjAhlM134nLsMwT2Mh\nw8OyZYeXq07b/3Krw5ummOGWI+i1RP4ZR4z3qLpzEDX9FQvTnfNg2oPtguGY\nKmQvhel0lOFe8a60ToJDLceSViL62X/6gysADTgwkEE8TTgWSOd2aGaSWq5p\nN5DdtJ5/2pxp/G0M3kmLAc/Z3AxBWJTwgsufHK/M12dv+v8g31qAuJg8fy19\nQXhkwhGyfpbncFEIjZhYRpJaOuejABG+Ssb5evAW0EzNIO1uErI75hlVKVle\nDBsil60ZZjH8qADUlBwmIqYPc7frDO8QKWIiuzAybbZcmQs9DUPlBADCIdBq\nWPxSMXBhKSiC33+PcRtJIVQmVAl/j7QGF0HQY/dEuYfY9hGxu+zutbkIpjCr\n7vWflG/2SJO46gi0Gdeq0JnkXUaathesoswc9iGj+vHol4S10FzgENXHtywG\n/fG0\r\n=EbDQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1000dc5428a0059f18cfd44a70c1fb6b73974d7c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.6","@types/jest":"^25.1.3","@babel/preset-env":"^7.8.6","rollup-plugin-terser":"^5.2.0","rollup-plugin-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-9bd64d4-1582877000927_1582877057338_0.002875184665676489","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-9e008dc-1582928488626":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-9e008dc-1582928488626","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-9e008dc-1582928488626","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8455434f9ffb41d4fdf810822ad8bfd4ca8855c9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-9e008dc-1582928488626.tgz","fileCount":8,"integrity":"sha512-tHRcARDehJn3o1Aa2E/vimvKrr6if4T275PLpKHWH7YcUNPRw8GV4ih2LPQE50P2Y7sN2ejKbvNvw9PDDmjt+w==","signatures":[{"sig":"MEUCIHWrZBzrYbak2HklA9Icf+iN38rNi1t8vOLEDoLnYxTAAiEAuTKbPCNQ35iSkWWuzNCZODCVcgkkkSXXSlVyLZ7qXzA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeWZKrCRA9TVsSAnZWagAAZ6AQAIJWv2Qqr7nas0+BZFL9\nXBWwtZOMSfqQn9DRIuJrumqm5Y9QOh1d2UaVNSsFQBIznhEh343kcNsz5/He\nIREpUD2+5fofHZglmbHR0Tf8fxLfFyzYL0T8aRbdIRvjBxUQXJgdZfMXKZTR\nBOLVohxMAh5fW6oGHzDiRThcIrULpwE0lyrIkVfwNAXi+GbPPaQ4k4sIjFJj\nfasruQlwpmUs+9YikUqlpIdSEi/UOArTVOsebPBEQ5XvcuOnToOTobcTHqAB\nG0O0hCqu35689g1cufJ6ANQC39PJjzJT72pa8SSNW4/rYApI6SUY7/lHGFmF\n5+uMgvyF1S92jRUZNN/3qjhO+q+UQiC7RA1ehCkGdrAhZV3keNB5BSgu/Xog\nVGwR3x4ECFtLulqnYYevI5GPyjs5//niZ9q6N2Fftyv5k48HAsGs7V4XKMmJ\n0ph4cjweY8MqBnBZgzjE4ITCTH2SKU9Hgr69V6Dnjc9N8ipW7lzvnRD4EyQo\nLeNpiJmRg3oxz35nXy65qGNLFQlAwtLGOlwC8VAubmxZ7PD2GAXYN1NBeZ6+\nt12EaHBruB80skEx5CctWezTERevMb9/3iA+I5RMy7aywM3IAyF1T4g75J22\nTBhh/Ad7h8rNGgIASeDdV10ElBdvYKwcY5nbGhZqtiXzvhmA/k2kHs1+5nCf\nYywy\r\n=4GDn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"29dc27fe7580e7eec103c7be064b71e09ceae475","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^0.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-9e008dc-1582928488626_1582928554971_0.8388824098729046","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-61701b9-1583141015960":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-61701b9-1583141015960","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-61701b9-1583141015960","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8a9e6d52c7b2e5dff0ce9ceeb924939bc35a17c2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-61701b9-1583141015960.tgz","fileCount":8,"integrity":"sha512-dm1qNqGN+fNX82R8hWksiK6gkc8SsYnZqiGuEB9NtpMGY264f5n2darFEF7rOZoD+3F4DrfoIg9+JqsuBa+67Q==","signatures":[{"sig":"MEUCIFSrI1/RorWxc3HEEQ/FZ9JYH95JPMQj/UA06RNEokq2AiEAxDPSKQpTWIDnqoUKXcVAStfmhgs/G4KSVP8hXCquRq8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXNDPCRA9TVsSAnZWagAAfoMP/RPYycCX+UoUO+Pr8ybJ\nFwWL2LjbS84M4rUwwa8yIFHyVrVjL7bBpf4qiltuNJzNGBw89NWm4MdgAucP\n2fNXH6112xz0vE6FLpX31/ePkmSt4ipbFN4ol+hq4loPSShgI60r8vN0Cri+\nb9m43QM9OLyJUJ9TOenszdYYWj/5KB90HE9c86ihojU6RY7aG/bZ7UkRRZGZ\n2APuhWu/YEaGaMJFugzHxtz+CUs4Ne7aVlPS9FHmZ57jS3EOEoewGNI1MdSB\n3qIFW9GnL//cALxVHd/sL4RS7Lb03+YkpO//JlRf4oCWv3S2zqlO9klmGQzT\nscFyHRK/PWAV8gciUQX3TWhBsrGKYZUHbf3IcX7A1hMvSPes+QF8nbIMwfuH\nrK0yLCLtyaTTZyUGYAqNlKAmabVbK5fRAsVOREEpsn6EODBhuNRCOuw3Eal8\nOYTYArSnlG4r5O19rV7A71gPQ14Ax3TupXeqZOgvBh+9YgNhQVhi2Jf3mx8F\n6cOdvp7ONez0eDw10yY31AS+fkgsslQWFEmlBpxOeO+AKbLX4A4RUXCP/+Ag\nOQGc+Q0ZyMYBb142CLg2oPjE2GKI42H5THdWNT6Bm5l+AvnczXk5kcNoh7zZ\ncQ3Hmu9z8ZkSddb6RF58WoP4pszag15EUnA8Ta5CzyEBNZ6PZkXg/tT6DHRv\nEDyp\r\n=A/cw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ec879fb70ab68fdd81bcf13064df64cf052ef5ff","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.0","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-61701b9-1583141015960_1583141070918_0.397330547235742","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-c3c8d4c-1583223011922":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-c3c8d4c-1583223011922","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-c3c8d4c-1583223011922","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b3308ef86625fb5db0af32133eaffe6d273b3614","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-c3c8d4c-1583223011922.tgz","fileCount":8,"integrity":"sha512-KR4kkg2i+PZGMbOqzYcvz9RSEKO6Ku76RvIpFJTEaYpQTpTM7ykVD9QIp06o7PxNgqDzpl9u4lRh2sp8bmVFFQ==","signatures":[{"sig":"MEUCIQD8EegdMfUX9frLUvk44oMYnrUKjhBDrltkef9qqBRnLQIgTaI7VF4epouZjQtop5BEpf1RymuL2PHRDrVqu0d6+Dg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXhEdCRA9TVsSAnZWagAARZMP/iPfA082f1Awth5/fNVo\nbFT9tpuc0CK4GmAE6vjo9VV1JJdm+UM3k2ndWA/HTROULE2b1hH8lXijtA8g\nduKAHjOKBJUFWcf+UEqBSShJDJhT+hI0eXaJaGI4Y4Zl8kCTGnFLBKgMlMOt\nVynLtWEI7YgdGo/w96OWKituYZh8kmasnowz/ilDZWMtnOGPRycfiARxidH3\nheUu+mQrTN3vHQznod2QtJFNgMR6RCqvUZYBNLTDemsJQ2PmYqA++37mklR4\ny1LQOYeVXNWpHyLGzLXxnJcelRtFWTLydZrLYXiHqzSDmosDXTUREwMrP+az\nq9RNPNk0QBUFpY4J4FhQFiz/DV32fsj/hh2VHcvY7UGT6CoIqPlExDPjuZeB\n5yPFY/LJxX7C+Iu2Hv51bsZBuqwwwhOv4A0M36reoRRkooiyY6twD02ZFkMb\nbcUPAUP2CbgEdsw+rVfWXkww5oCVzWg5dAhirN5XzFlBGanxdvi2Q6CmwjfI\n2bmXRyEkQeDSgdDIJ/xG7eUzoHn7/Sljs9CVaXq0GiCsa5hU4J9QeugR7zKK\nubyFhU+V+ijz3zYadHFL2dA1Cs2xFhHIemf6rb01JRpf85jqVviMTH5oA1IC\nGwbxwbIg3/5ZJCUewHRyE+n2lwhnS3MhQHJiqCuArxmIYMmp/75n+pvZzo8m\nZjDo\r\n=b6GY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"147852ec98f06e626041dff25e6d43e82ea73c61","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-c3c8d4c-1583223011922_1583223068875_0.7727572875060569","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-5d9f1d8-1583373815517":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-5d9f1d8-1583373815517","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-5d9f1d8-1583373815517","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1401e2ff59c1dfbc4161fe55d98e984043777ea2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-5d9f1d8-1583373815517.tgz","fileCount":8,"integrity":"sha512-T4a0Qg4NcdWNGrNSzF5KNR93MK62YPD72SjoF6sUDe/YeA5FOfYwUqmdbbCUdyNzpq/PiCwABr9ZZM88TmTIew==","signatures":[{"sig":"MEYCIQDlj5+motFPX5ri71DwKpzsgZ4uoQlFjyRa2GL2YuQ3NQIhAOub/umB7mJYqRotwT6MNtk4xca0gPfDkDGkQHLRthk+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYF4sCRA9TVsSAnZWagAA0d4P/iYm7E3J3cdoIM0RfOaL\nOdanmYEIwBQ10SWPlqWLx17XzcBvoslE1YzjfNgRL7eSSPV0UqredqXOO3lS\nJZ3Fa66n4+Y5x5caemdp+lCcn+e10lS1hjAN3oig34qdimKKOfbeIU5qG6YV\nrQSA1rU8Sk/5ikypXbQuVwYfdnVp0QjlNViJsJJi2mUKXEZxJJWObmhiZPKm\nldsSuy2FG1bPapqG88mwJghGRFe8T+pAFDmNh5GNQCEtRebWkx9qvHRCygg3\nQnJlvTEP27W7wIvTBVLEUftDrFU8W+Ei9cSNIDgE0RrWUDNRaBaO9KntuPxY\nDopGKisN+QLsIdp1X65XwQ8ve9D1n3WsmBFqeYDtUZyr9UPmQ8E0Hn15L4ab\njBa9cUMaLCtfK+5sySy0tYjHuAD1UQ9sv2Sn2wzkkZWHmC9ICT8oE4LacVlV\nWNg5/A6ptvRgkxqDMue+ibwYYVWRdT0xGw8uJ1Mb+1gQTmUgeANuA9CqqwCX\nnlw4VKDvZyPCSGKke0ppceXJqM5zkD4zSmdk+csotKp2bwNyctAGnLrmo51a\nIunNJ2cCtynUqqTzq9dHQx+Yf9HqjODCbq9gxI62MhPO7k1MueueYXW0AiTv\ndDvdV0lCKmM8OUhVuQuaW6QV6iTYSbeFkm82bpCEqSF3dvK+SP5TcVJL8DPt\n5jwv\r\n=D5KV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7ec277acf2311ecdc7ae93a1d2a6a8db810a3a64","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-5d9f1d8-1583373815517_1583373868324_0.14288574855276281","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-0ebe9de-1583373927689":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-0ebe9de-1583373927689","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-0ebe9de-1583373927689","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3e617c841906aefde7383af00e724b0a30ddfc16","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-0ebe9de-1583373927689.tgz","fileCount":8,"integrity":"sha512-1+30MLRD3bnuAiAbwhrADhaNGAmIh7VshrN22ygr3LWaJFxpa49dd/ybKHCQ5erryjIZhpSVNg/xJvsiYjS2Bg==","signatures":[{"sig":"MEUCIQCJBtsxB1fWGalc0iFn65Zgt1BvRD0rUYjSXI5IauSgQQIgWqkd4vsFFSIy4vRJ1ZyYJlAIdixr7xKgMUaBlP71m0o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYF6iCRA9TVsSAnZWagAADUgP/2zQ3e3sV7Ig3xE7h0k+\nIuJT+a0G4wPsmWlr5K6WlSTo1Laacpej6YaTqVrXnnw6mfP4j6ebIrDSWYmE\nLs2Z2aJw3ML/dA/VwmYlqVA41SWfJQfbXw13oGEP8fG68I+EbrZv1tBKOuGc\njGQJMZ56csNyYRS52YuF1Uir63fSBWxpLoDUJhlSNde4SA3mtvbylKSHyMaf\n1k1QLa1i0foBC1Ffx6dS8M/Jby5VqBn5bHE26HkycOOTqtL+u5XID+lTilak\nyr7ozantwTVQ/BfPkoFw3gQ+O9EWIE+w/FpTdDdjdX72oPJWsT9YJlmfwgS1\nwqOFgcbjQ/Tget4v91BYR7K4heC+p2T2dXIPUyX9hVXmviPE3pyhJUWBHECJ\n1CsqOicLdFr8JOBcWEe5LfKfEm3C8CvDHEu5cVU+betsggGmdsDF7HoTKVGL\nbRjc5GLMGF0skRc+Wz2K5EA0EX+msofDQwTqLt5alnpxp/zQKflVOW68ItwA\nq9FO653JayRkfDVPeU0uTsLXZdw4mdDo3H3o30wLRMy0WC0oYhhvdowht3CD\nH4D3arNzFzByJGOIhHTHQNONn2zCbhH+gVRUDxDimNCQWi7GHWNg8rbRGVws\nbzfcCjaeeR7/+w6RNTSvmf8W9yGYCuL4idLn14mVkiAD9s0NkxzuaNTF4Uif\nRgZu\r\n=Z50S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bc218f3e56cae23400c08b636aefeac76bfbbb47","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-0ebe9de-1583373927689_1583373985677_0.91060230118825","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-b3511f8-1583397702323":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-b3511f8-1583397702323","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-b3511f8-1583397702323","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ab7946336ea1e8e22903e357d395a63dfefd9b98","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-b3511f8-1583397702323.tgz","fileCount":8,"integrity":"sha512-Ii5IGWlahNn4m+9+kuCrPRy58Ao2xXzpwVxmWdYO5bitbgCThy7SA6Ut8GlmRTBFmVlRbKk3TM290hxMJ6XXqw==","signatures":[{"sig":"MEUCICUeZxvj5WcNEAUTa8bAQjGJYmsbYsRJ3Twoe41zCA46AiEA5j/w7Ezv4CB//le3k7mKU8YvGMmTsuY9hAETSgUCHzk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYLt5CRA9TVsSAnZWagAAeboP/0w8R9l5fIKeP17pgBMY\nioOfTeYaY8OFRei4pVVzLFK6iyVVmaxAYlgmqmB6ESF4xcEd5vP2YR85v1Os\nFOO1slZQgYzBKqK+43V7Qh8kpr25KmP1W8NxUzduBaDT643oMHGf0sa9ZHAK\ngqxOrQXyr9LBhWV0Jf3hKII+7oWx9Y+EEh+d6Xjzz6On8Rg3ctgjJSGLBAxp\nSnAps975ljllOQ7Ivj5xvRgWoqGxUT2rTdwCL9n2uXk79XBTjM5sQl2FPrBa\njFdtos/8pJAbZBAifFzXKyvmZDtpAlDYnwYai8GJ8EpgCO8JANAS9b/HsZQJ\nFeRAQjDb5wPqIu/GrPI5wv31jDMAogq0dnX4o4PC7ui3wMBqS9pChV4hUYE2\nGAq8waIb3JaYRVQDzYB7wV4cspsBrxuNPoMAWpDnZVF03YZ7U2TcEp/sdwSk\nG2FZu1Y4cJ1N/aI3lcP3wdMbGALWWDP2Pwvq69PjDFA5irdxp7lMOoDz9BWV\n6LPDJxafoCgQQ38q9SPa49AcbdbigfXpxS7rXkDmlJKcsHbx0RmveJcA/2I9\nulSVxEk3VtMhn1vMBQcby1EsYoo+iKht+d5rjj+vgWmAHbMshO+bmoM5thGD\ntveKngA2A/Mmtcd/0w4IJ7KO4IhxH9Yudw7p1t+qDkEKpkuyqUcNow81gmzE\nJZ9Q\r\n=inPE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2caecef0b61f97b1ae73c66a57123a066e62210e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-b3511f8-1583397702323_1583397752560_0.06536381655193901","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-5822793-1583487565496":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-5822793-1583487565496","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-5822793-1583487565496","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d38be49569352d0f302234847fa6d5215fe43a63","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-5822793-1583487565496.tgz","fileCount":8,"integrity":"sha512-+BQ9nLHJo8yEEaJS/4ifu/2bw9CSHDmXlmoCrZ0SGmA35mE0dxViskBtvL//2157jIVK2JEdgIROS8l7cKexZg==","signatures":[{"sig":"MEUCIQDz11B4Ao62CxB6VqY6HAFuXIlqgccpDet/12xBLveSfwIgCgJW3i2QGBCHhvl0fjh5h0UdY+aqoZTxztpn8BstvQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYhqKCRA9TVsSAnZWagAAHygP/R2xRv26cnBsK19X7wqN\niy0a1ZRTzoemUfwyDlP4l5ptoVwNmpCtqEBXzzjfV6JhbEomWZgLnsaFvqYQ\nfG04Sg/TrOir6pqTmXG/zZwzADAZYdcFjqRomSL7r8qodJOFmqXLk4fBwsbX\nXTypfAv5lG3qsbm2UBLJ10oU77IhUGtzahH7DKVnK42OJJjqNAUyiQwl4+fa\nbZrGW82is6bqbaoMzs63DjhUn0AmenVylpKDlfDUWQX3QxEloD8tYWjlK16n\nYXGXCO9qCq6eIrFlkzglInovr9hTrjUQaK3TxzbzDYM5twp+Ig+c/Z7WSrme\nNn+yBZAV950BIWyEmzJVsLBoYoSeMIX7OnzB/3SHelDycy79FcmsLeYcWTZU\nMm9yG22lvAchU3U2IBsj2FkQnVkjkAoM2vNaBqBH5MRs7TRmEsRe50IW0Qgg\n3ERD4frz33tjIMy0t8pDGzQDnqSQ2jste4ee92Bu5n1uIU4XbwWe1X+tbjAI\nBus7vLLdDSYmbzY+dE/uayM4FhC8vCs7gPmMG1m6o/4syBRh6TLkZFqWj1vp\nLyO/LI7Poc6pz33Iyyf3s6NKUQutkfVq2h//U76J+yRX5aFp3GE8q2PcSaeq\no/jWT9ItX+UNjONZDIejCy/CUp2Nvf+tgyNbIEX4YIQ6jpurJr7x6BpL5bpi\nVdiN\r\n=sEKS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f7b179ba0a85746d7b4d1d066d55bdba6aebc827","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-5822793-1583487565496_1583487625916_0.9430666896179802","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-1a6ef57-1583546259677":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-1a6ef57-1583546259677","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-1a6ef57-1583546259677","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e8d399fcad757fd88fa22ac7a82f1e1e92c73212","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-1a6ef57-1583546259677.tgz","fileCount":8,"integrity":"sha512-KIAPmhMaFVJ+GhfMJXxhwVrNvmkcDJ5Eh8m2ubgnwBw8NngV4+FMWyfpAV+OCt4aPzlgD1dzsvcv3mRnn9MXoQ==","signatures":[{"sig":"MEUCIQCcqQAC5QO50cE6wQmxeT/rnhSiE2tbapAk/dFH0ADlEwIgOj8C4Do4pi6tjeb5kjZQFGcCFY+zO/I/ELN1A98L9G4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYv/JCRA9TVsSAnZWagAAXVIP/1/+GQH73z6S2EkwaJvO\n1OslK0cnLWaSE2LOtfCA4WvGz96RZrOydM+pDlO1RQ556RIjHdYngZEYu7qG\nJiAVarkkbkh1MqF4DKfcnGaRLSOC/PgOavrvm2oVY7obwM5KHJbT5/EeOWnj\njs9ykHLfFw0WylaBtO1FsYXpN+54Rbbo1XloaePR4azxnK6NgIacMVsmi9Nd\njuJMsoKfK6bJOMtq8t+Dg0SSK/NXVksb2joy1DPl7Zx3aU+VruNfhCg+D5De\n4n4YbFZ+TX3IqQv892rUZZ7t6udsOalHoLaCI1nYKIkmwXwb5u6uF/LX0Mff\nQU3n2cpN+aWL/UA2bIdchdP6zB4NFpdDYKzxAQuqxV6pIt8J8hRquj+RB0/g\nBft+KH4kVlV3LEs6yRv7DmacTs87iq82rykqLAk8rBH+z9H6h+vg9I+7gkOS\nw0R9AsXRgWkphwqexZisAQ+RaymBBPeyw7BC1CtmFFRkJX0sDEX1ep/CJfo5\nPWJbpBJrprnE6FvNES5smNQ39JOitf0IwOfL/hAWMdtv3dFcVqYG0mYRtM6p\n7LfA3Xm6TeSMSXTkWVg02RNYj8FDi4DWYhX8/CTQIICu3y9VEL5w3uvgs5XV\ncytRZMFQ4f/TM2X2NMaJiaxhn54oq9/ZlHwEsvjFHCutCC9+K+g1gR7dQLtr\nhUjH\r\n=8Nb/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"13314191f1551b85f2eaf6b8c3e47b96585bfda1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-1a6ef57-1583546259677_1583546312734_0.7525649164801282","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-67f56a3-1583782697351":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-67f56a3-1583782697351","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-67f56a3-1583782697351","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d14124eaf5692358784bb26367bb1c5c34187943","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-67f56a3-1583782697351.tgz","fileCount":8,"integrity":"sha512-cezrzGI3+Z58qv5911lNRU/lGrqCV8pk40aCgBDoNx6BMDLgT/n/wDCilyESP/MboeYqP4ByhPEMn9ue5zSimQ==","signatures":[{"sig":"MEUCIQCaVL+0A9Zynq/B468C5ISiLneW/ri6eZq3YBeGb6aX3wIgRPHcaVCIoBaLJlf7ob+ZRsrtSANjmUAOVf2qmG7oocQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZptfCRA9TVsSAnZWagAAOkQP/1n/kE6AFVSe1zRq9FWn\nYuPEmJiDYmzQX5kq6N1Flh+Rk/+/RzSlSzI7yxHFsNC4VUBfWz6GR2iaW7t+\ngqRuBVxnY+M12NWmOc5EqngomiJp6hXcbveXMjWRw+ZYLPlkQGPAndUyf5JX\nOojHxfjRsOJ0p+uV6ybg7Dv3j/kFSkuhDUPc1M0pTiv6xa+y27loEJUy9xVv\n134azgWbEAy2bSeh7oI9P9h7bTJrxZ1SpOKCkmF85GnvqgUPBtrOWtEkPoPC\nYgbZFReQTzSx6vg7IKWJl/WrYPGvDlynPcilATJ9EiX9V5qZyD1zRiLw3XTR\nKGm9FARvN+y5EupZR5QYOw7TZzZL6NgGNgjFiU7M8pZkOS/FeXcaTj6vkkJF\n+XyzRCIoIQ63DpE6c+JwJDkYNbV3jB6C7+48bKJk9XCnbU25x1ucB8Cx33UA\nP49uBTelFxDyCo3TZpFt1hX5ArYjQgs0BlpNSSOfQazJCGviJUXrplScE+NH\nWzaOTtIRY1GY3LWOKz52GHV7f/C6PiEvr0NsWDmEObZa9/KtOdhuRtsteN3j\npWD0UhwgQBwQHsi4eO7vu86nJJobhKJikjfkaG10JSzymO0vk40oISP4uof3\nTreSDaf9VE+K3lV8gd6f+/UNh7yeOhfAyZlff/chtGkX/p7Osl93CRE5N9bK\npA6v\r\n=0Fbe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"27fb173dcfa5a66e1b28ee27d5164a02753e07f9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-67f56a3-1583782697351_1583782751310_0.7185084044945833","host":"s3://npm-registry-packages"}},"1.0.2-beta.4-canary-c03e7bc-1583796076250":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.4-canary-c03e7bc-1583796076250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.4-canary-c03e7bc-1583796076250","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b28e049deeda2b3ede0e1eb8eb87be3d40817b51","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.4-canary-c03e7bc-1583796076250.tgz","fileCount":8,"integrity":"sha512-wcRgrT5gUb0zxfDNetRUkylwhGbtVUtwz29AsjSFmrFcAbUMOywPWyNZ1OR1zTIyhPR4TEn7577zfUunyP10/w==","signatures":[{"sig":"MEYCIQCE6lsOxHOrd7HA4p9SD/DawjONHNOxAmSFMRv9hKYBYgIhAMyLsDgrev9bnr6TPvFniOGEk1ccR8lzFnm62bZqON0l","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZs+dCRA9TVsSAnZWagAAAfgQAKCPa/HUwp86uHBbj14a\nm3RGjtQN8eq7enARXK9DykpaPnhkSbUBSWZZ8GC2/bU/z3Ccz0MYlpIuJNje\nkqxGBLq3kWJiU18BQlutPWO6/FMSOwpzfMwQlRPJlLegBRaJXPyIBWZmG9EQ\nbzc3O1v5AK5CJh+wYYZX7e50GrGu96mmLv7xfJJzgA1ubxnz5LxnHlIL6r6r\nEPwKQAr0mUvWf4i2oEbUKt/Gei63Ho1oisHOZVXCtY4qNiA/TteSmQCH6XD+\nYBG5uNHAo8vLDz/RKFcATHRQvOUW/V/2WJTl7pr2D8yS1ddWXb5ijP9ObwZR\nePy/9dWp4tJrTSU/3THpR+THoY3kGT3jlNpfgtgfiOMDcxn8gWmju8Mh1OOw\nezuK+k0E7PMAYvpnNpkHOP7ms7IyWfy3m7203Rc76neNzY2KSCqY6LihFt8J\nsokXY9hMMkaxEvXJ8mEisChK0r3HyejUO1ctVGyCtsb1EFGNDRwU7l0mblwE\nJp9j6iZhMJjXYA9+Dak7ZisxRbiuO5KrTmjIT+ewFj/ox1YnwXbsdGThpmIY\npguJiAcwNvlm+qxfzEGDrGqb/EtUEB6gJ40V+QlK6UwHolf4abieSaP6+/Ms\nIGbN9lFDRmPhv34YlM7NTqjKIczB6sq+4rn17mpnXIvukvuYIn35xOaW+5rS\n66Az\r\n=ZVuL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d2334570625fa58bff8ed3f94a20c8af84b268fa","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.2","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.4-canary-c03e7bc-1583796076250_1583796124612_0.11584221088578217","host":"s3://npm-registry-packages"}},"1.0.2-beta.5":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"43d5ef040a2a16b78d62e3427e4b37145753c8ab","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5.tgz","fileCount":8,"integrity":"sha512-KwWgPMQamYO7Po9jXH1wKeV3+THlw9NR+PzOIbZCfdoa4Ewmgzc4T0t+ERisGMBk2nWah2L6JIzWL2VCNZG/OQ==","signatures":[{"sig":"MEQCIFRxvvJekU1zrGvBiHmauGQAH6ydsrl8OW0KWdpecarVAiA9hsxY4esWqun8CMdZ9HwUBQQC6ia+bZozJJJzVLHgig==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13921,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZ0RrCRA9TVsSAnZWagAAZMUP/2UfBczamo7wJAv0fES0\nOnKA+09U6BIXZOZXi+Mmp6H20dCgcVchK2jxoC8SxcMC16ZvClW5HUBkjBtI\nGNy1VDFNQIOZ2sw2mYLZfwTCySxy3YXNFEu1Wi14j8BjKXdZ2f4oN16qdklW\nUi9SfnpHlm0tKpT5cZUnvpd9Z4c6XSAuSgOTg0OhC6rP7Wl6yZgYtVf4Ra1G\nTd42FnWt3Q4y4FJxW53ZQA5mwbsutk6CF+eB8KuRauybYf7vCZyw84zi/GQp\niomgFydWRjyCHCwuwG6+QRudwIFTv5NWQQhFUfdycfZzOEtkIroeba36FsBJ\npPtmDJhs6q+VVzMq6hjEi15NQ1ehC+puU2lAu/vnsOIO/jBG3fZNWZHHrOlh\nO+0nNrAkQu/uVZhan5KhDpZVsihywjSomQtj8hdJswpEWEQy47UQ3p2Y+LJM\nIH+HkxM0OYbavq82/e19Lvr/lP0NNtlb3aaMsbke9tr51nReWnfNA+oHoH/s\no8j38qi/vSZxkZyADRkKmNbAeYRtkwG0psG/z8w5yvWTpC3F6Rcj949i/avn\ns+hhSfoHAGl8JuxZ+4GPmZay+APO7KCDdg0IlaJZJvdDh5GGMuxqoNwWtRQE\neb3orKMsnpeY2We3m1d8n3lojMgR+2i9UfCVJ+NipkZcYo0xxEKK3Kj+wRj+\nrBNu\r\n=HCDa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"572b3b5de49b5da35f7b22cff8a05bb1d578b4e8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.2","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5_1583826027106_0.6276932066535528","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-073ecc0-1583827567037":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-073ecc0-1583827567037","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-073ecc0-1583827567037","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"abbc59ec6147b56e500ee74a0c4a61f301dd07f6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-073ecc0-1583827567037.tgz","fileCount":8,"integrity":"sha512-x4Pcvl2Ss77uAj4DNy1l/SpAL2NS++DXiCyGXqYeotO0yukC/G3S4e5y2quH+cbbqftePpMAjLaOkBLArNuVUg==","signatures":[{"sig":"MEYCIQDMG8K/+pZiy/1Aoa+2LVHQO3dx73aHpAinbYn6uDDTxwIhAJm2AQCqv87Z1aUEaXR7slMm+TuhZ49MX+2VO371BNQp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeZ0qyCRA9TVsSAnZWagAAId4P/3OhLvyG2v1/aKFDb4Z7\nDIHbccTN1GOOGis1ZlMwMdM/De2n5CTq7M7VjNiKIAyWLA/XcR6W46JJtrVQ\nzZGuJb9QPax/nJlAdu114cpAPDX8CZ5453iYJV+2Y/LG5LawuSm2GOWrOSHw\ncNjLWkAjXC0g50uvSr+HOLssGOuEZma47UdnyazZhhjKNb+cpClaimp8AxHQ\nGqUfNd+ReDZphKVJX5bMP1klodza6hJaMPEEnegSQTczfkS8W4LheeVVYIps\nKYmKykuU6KZAyVT8LuTIZ5A38J16dlWYIQzB8+QnlnHamfMFlVK+h+EZATUo\n1NglxJi0si4tG/h7CKbMPdmdfFO37caU6CWFGq7ZugKCl2XkIWTJ4jTgK1+F\naqkjFUn/1hoDsY6VDNu2vzoh6hI/OiNJLKC2ZRH8Poy58fXwuXfg8BSwSAKX\n6X0oCzXd4eOS4I9XeyDi0RmhpMPBFenDsjZSbu0589X1Y6+mO4DucC50l9gf\nFyeJJ5cvWKXKFoEMIrJQABTXVIfeF860onkcMQVpxk5nrI6xnQnpXqToRii1\nBTWdjkWHpVcvUOTmrfEH/S/qjmFwd4Y+bjwdn0jChUUv4X/ZM7Qjod5QNVBh\nd10veLW2Lm0DucqfcDRn/5vGJUmeFpDFiyZTFRr4abKAqEoJAifCdaWR3VAh\nZMUf\r\n=kaFk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cf93482dcd801004e135d43c985edebb7ebfde3b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.3","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-073ecc0-1583827567037_1583827633983_0.4690575629085263","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-70d8677-1583989794731":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-70d8677-1583989794731","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-70d8677-1583989794731","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c189e6051259869113ef5d873d1e2627b50efa02","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-70d8677-1583989794731.tgz","fileCount":8,"integrity":"sha512-JfsZxXHvPRknwLNV0cNlGOcJwJc+mv7Y0Sa3Jj3k1UZkJo0UAu0ZNlLb46WzxZQhMaU62WDDPHHfpjnHCJe23w==","signatures":[{"sig":"MEUCIQCM+YEuHCZ29W+V0SScc1/3UvquhW+2RG5KaqbCfJVQ8QIgJciNZ1JeyxCMpn53CNxd8eSf9EKHl9N3mlSHcpS5n14=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeacRRCRA9TVsSAnZWagAAmkEQAJh2pcXLd0kNGiBEky+v\nT/aFiDoeocSBHVQdAxGRoNuns1j282380KmRQakxBSL7z3aHnGs3l9u/Z2ye\nGrE1c5zuUF5WLKGRiYIJ/bRYh3fnrG3LePxSMNPGtdvLgQg8mGc2rdko9v1/\nZ/ziYGjcOigdaoV+4UlAh5XmM0N5mzZp1KoUkTxCVLRUog9C9r6xszOCLKr4\n/x6TK8JqfCIaLELVY4kwClxT9Hh4VByalwG9PIqJpfng9hqp45L3YRlHjfqI\nMq+gr97lgqnT8Z3/HLoP2snGIWYWSnhUBQxqXnZC1tPz+L0gZ5cbPOo3J35w\nh3ntiI62n7I9qeSdJLAwYPO0nOJCCaHqNj+CgX7P+SV9ID9GB8fDWv2lzXV0\nix2Xn3b0VDo5LnA7CZJH61nhdS8vP7SFmPy2iquOhyEXhmSIJxgMZh28T3B7\nO7YJy/ZAmFpr0pssEOnhocsfdFvZ3fP/Q8PHjz9Qw1fzxASLjKV8s+QAGXmP\nDlNm/vBzAmy9czLOmfCwSOXvhbK3E5zUsw/4Zm4CTD+JCLfgkshk2tzL6TUX\nOK2GDdMYv8uMqwzb+8WraqkxAS2RKsEpyBjegNxqyaEvl5qaprbAar2T4ne8\nhO3ATTdJnzHHihIKAGEtE4fPx6VedaH8NchezhKCRNYx6C1ItuAAgO3UkNaj\n9Oxz\r\n=9wJs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0c3efb6f8237b26b6dbbcbec8f913b8af7c4d26d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.4","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-70d8677-1583989794731_1583989840624_0.5876586714065934","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-3121565-1584002949437":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-3121565-1584002949437","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-3121565-1584002949437","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ac9be77a5d3da68009823922d1a8e7714224b8a0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-3121565-1584002949437.tgz","fileCount":8,"integrity":"sha512-QcwiqivjbJessOfvshQ/gcSwgVKGXekX3utBS4VE+LSHDCD8S669Tm660b8sOGN+qwYZ0IVtbbpx3okRPbasEw==","signatures":[{"sig":"MEQCIBjkohpyhSwvHWYUj7j9o6D4rSX5/hk0savIFMkM9AFyAiA6Dv1eTaqGAK7LdZlQitb5bhx0O2ouGE6o8/A4UI/1Yg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeaffACRA9TVsSAnZWagAAghEP/0Onsfafa7wkQUZGytOk\nj4Pkd/9WPC30A1WgFceq249wLc7/7if3zQE2Vs5bOFuTkae92pHDxwXRLE6b\nQU12I/ChiGKcUVBPvJgK7MVdWEFFq9lxhwiSa4upVNySfnuHPkR8crVCPeaY\nZF9QkYmYjeaACX0qh9/6gdk1vEF39eGj0XgoBSSb0m8pAG4vsuvAice/sV6F\ne/C9dPs/K242o0wN7BjtEDMFVlcWes5GV9nWZvD5a7dyaqns58j2Yqe9byP2\nPQPUOnl57oHj9beDAFMyRlgEeILTbNqikLl8frAtLIyEx/0hJmhIXHyAkxDa\nclHltjotpszExycGasbQjF0jEQasFNd7Ng8mmb/IQyFyfq96V+DuKQiSAFdo\naulKXGQfpQwBfzIQedxFE6urIbIVCLaD4QkMPgzqbAhBIDcOKEBdJXvIAtbI\nF6uHhc/QM/umu5PAn2Q2OhTRpoMyxx82ewvA1kjQiHc3OUh2Lz8JyO/YXc07\nu2GsuajttedpRVMpASGGXoCYc0h2BovFEAL1ZD6b3NEEv/letSIvDH4RlY/P\n0bbcWmVyfoIPcOocT0QiOmzfPy7AS686UzL7IGjHBfa1c5OXXMxQnXZGFCOl\nrSWCSrBegIzyASrlOsSbVQ+qFu+FNy52MtUXdtI7ufwNHceJCLa6PSipk+xU\nkShA\r\n=pP5d\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8beaa3c9a7666580cb76585535bbd6857ed46f54","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.5","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.1","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-3121565-1584002949437_1584003007702_0.7154319126366495","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-ded2299-1584025903922":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-ded2299-1584025903922","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-ded2299-1584025903922","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"43aea6dfe53063f3a27bd64cfbdcb3720fe32c1b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-ded2299-1584025903922.tgz","fileCount":8,"integrity":"sha512-n3cmvx/tMw8QIXn+qMtf4cjX77IFZ8gfD/YV430hyJT3i5v2foC5Uw+/XvdlRaQLt9ZbUsnAjty3g8Pb7M00HQ==","signatures":[{"sig":"MEUCIHzDFPHxjL32vi75huN4fvTGffdq+iOOpCL3t8KGy2KDAiEA1xN7pXdmubh+n2cg811B98Gt1bb+HZFK2CJaZ61QHLU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJealFsCRA9TVsSAnZWagAA48gP/RmHXhQvH8r13S8b3Cs+\nJJhuCsLsbe02e13CyPF1YGNcAfFO2dltVeYfTRLW29oYj3klc8/LvFpI0L9p\ndeKgOWhNJW82QBq8DuoseZi0cblSYZiI1TdO6oGA+viO1BlI1/9SjblYjXe3\nyEgWsDTd9I0aK8N7/ntQNPulecOd3AKYsV3JutJ0zhVy1Pe7BDBmkhjy16ZV\nRbslhzN1pGDv1ZB57k+WkD3eMYWtkU7ViggearajkGYL6UK4G+Dpy0/NDAn4\nFIW/jQzThZm4EdtIypT5KrDXHnWSrliP4+GI9fg/CeOMwh4PVqncB3/OU6JI\nRfs1OEV+4NO1YBgEnjQIkmHzpCUOpDdb7UDfeFjw5J7fWDr8rQvy+6h4SeWI\nikSZaqI3rWeetdvy4YlB8eXjMZoQxdgd4c2jqI/lGRLNVUuEmr8M0qbrFAEV\n+tMrK5Uj+ZG7rllogAPWBOcCgzWIQ9qPPeDFwvipDB5EqfOLVUC/86wHhpd2\nvh8If5/xP5MJaYwYo45GKRWEyYq94SBm+cq8t0DlMQVgGmuc514AGt1zovkw\nvCDOXWx39hTtJGOshP3swIOA9ReEfzcWsUQx7Npj3p+0qkbXZ9jb0pga0CKS\nxQ3upm7MSVsdOae8mcBz5BRwG8KnnWPu3ApsF3pIIekeqdWv9VbrsyG3FkqN\nWxQD\r\n=0Hvv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6255ca8d4eea878b5312ad37698f8e08119112c5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.5","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-ded2299-1584025903922_1584025964295_0.07782913090247745","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-29a0797-1584085771246":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-29a0797-1584085771246","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-29a0797-1584085771246","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"29119e0341f661c5b82bfd776b0ad547384cac04","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-29a0797-1584085771246.tgz","fileCount":8,"integrity":"sha512-a32wiLaAO4FmFBY1rfNBba6Gte/VFevlAkGbGzPjdpQe1HMwMcC7zTvbuhiz57xjrS2d379hh6faBBXdLvfRpw==","signatures":[{"sig":"MEYCIQCxBAJc2lsFamLn1x1TFvudDu6AHa/mofU9+rAvTZ4IxgIhAO+WSrhm7KnHPmLFSXX3UcaFdGy3xDqkZfgn5PZiG/Tu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeaztACRA9TVsSAnZWagAA79YP/0Xm+d8mLXbLpUPDQL36\nXGFpS+cBSVDqHOfKPC8U8i5GJ9lUiMy9mYQ5+sOfJYZR8BhNX1nkB7GEqMkz\nsIt7Bs5xUMBo5OptnpDQsZY1RtwB64z2l1tIsYE4A0CPeLZFYSXCW5W4NnB8\nEkL8lK9XHTvBOxS00qGSfUXSTvzZNq+Qp/Y+FioX/pTDYQLhpqV3gRKoqcEO\n4Ayea68ChEe/QiYeMOfLbz4w9slZVNTU9NZovdxOjMX81VElzyLLeO6SWTxE\nzDJOvcO6ZRRzzdaBp6jLf76oO9NGKaptwyiW1EN+MpZWGAJvXQ8lNKTHv+oF\nesJzyf/rFN9QG0HCsMrqtA9VpSpnE/Dm1QIUuflT6c2eM5eUfsbLzHg2kzRj\nNJTaFB8nLqFbIiORGEATsuA6/HDi7ZeeggXsUYFJKRj7ymh1WYRham47/3Yw\nDq8VRTRBaz/D5P14XECjP0UyKLpIYL7fcgWyAZgA0NQZYTnXF56u1eVZDwGS\nXi9wpiTccTotgR8Ctlr/qYrHGmIY7ozpZYd2AzLRx3gdyBbiUNC4UP1LKWUQ\nvl+ZLJdYpXfjzB51f+rGF229I5EB61TPy7DRvUfCG4X0rf16ZYK2lgTqpOkQ\nepGbKzd27Sglj8e2rX08dSVC+XaL4dGPHxhjdQblTW3ewOZWIAsdozezRfqy\neKly\r\n=YXDU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"51527e9eacd11fc6a33531100d25c0fa81a674ab","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.6","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-29a0797-1584085771246_1584085823560_0.5711485345116851","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-9c44638-1584133638444":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-9c44638-1584133638444","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-9c44638-1584133638444","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"05be1366cff0db017c335a1cd817365f9606a7de","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-9c44638-1584133638444.tgz","fileCount":8,"integrity":"sha512-3sGF/lVtoydnp18xdAzxYNdDbP3Oeqfekyl2Z+CBut0c/VBdXWqbcpPvRBBorypX11zHU1HdOX+V8gz1KTVgVA==","signatures":[{"sig":"MEUCIBvJPVgjFKphxNgK2HFsmSH12GedEHqTRdvSBpwaHXpoAiEA17KSoUSODypAckMUrFK1S3VdvgqYdJbv0uNbEx8FZQs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJea/ZBCRA9TVsSAnZWagAAziIP/iXF6DCh4d/u9RrHACyI\ndP5BwjJ9cVlK/WU6kwYa4j8fUfvQ7QAQsPX17K+WxKKPKs2cQu0jtN7u8/Lj\nOevcmKmmQMYq1xCx8MQ54dpRKk2onuUIi7Fq9t5sQcSmYhzVaWqnAYXqt/PV\n30VahuJtsQUm6ZpJHakZoT4Rrl7vMdSN9Cny6/MeWzCFPNLKAtbA4AXByRgQ\ndtQT0xN3+8n0DrUH15EFmnrIAqn/tM9e+5GO3SguYbvMecn7GSh9HV7C3Apz\nI6cFQ6WhJ1CG9+XWBAzLxMPBnehxtzo/J2JwifOy7RzNq1FWN2IBpZCU2mlK\nJ/CH2fFaZdbSwYcN0DTVAcOb6Hj+YqomMhLy6rXZtY/zw+4pYW1MBzdxnJsh\nkoA/TyV92dP0EVAclJuSN4nAnswyAttm+5PhyQ9WRcShNWkdawjnNXrcaPlN\ng8Dv7IHhz0AuPLRN97VZno2iCtTLYwip2dULxNu3cfGUAbzEc42Y+g3myG4w\n/DrhTjD7DrBQdYKJKDSSFbagtIKayU/3iAd1oJSM5jpWtbGXsNKhR/EZfY2n\ngWR0XRY5FKD32GVpI5/K3s89nOozr6wpUn4cjWZM5yJngC+RQsef9md8wCM2\nJNS5lV1A77GSEMFoZJ29/mqfuo9BoTsXWCIPu2D5tzOJcMe2rjq0hRadtIAm\nHYJf\r\n=zlOB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"da528102522b2c4cd28ff2e0c7bb246ec78d08b5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.6","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-9c44638-1584133638444_1584133696854_0.6215670083411611","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-e82e35b-1584314543180":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-e82e35b-1584314543180","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-e82e35b-1584314543180","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dcffb4f224712bc8a5b858ac6592e9c949f1d976","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-e82e35b-1584314543180.tgz","fileCount":8,"integrity":"sha512-tpgnct9CdSm35kxEU0thzWs3GZzNfl30gL0WWTQcszkrkrYfIo7POewNMRebqqILiVZQbvT81xFe9tZeduKAiw==","signatures":[{"sig":"MEUCICEdTluTTfqH2wiIhgAW6cZtty1wVSFrG6ABDESevPeaAiEA6n0ff7a9rUWGIJDp3CnwMFEndpoVWrhox1YoPD5mIBA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebrjhCRA9TVsSAnZWagAAmhIP/2BVsulby2B7necLefDd\nzhTEmVcNS78QAZLd4aIp6PTcZRhlwfdRISHavjy9SC/sJewbSsPX1XYMVzDN\nmdLFyW3ki5rDFrPEd2oP5rTLNUqEKCsJYG8V6+l7BW4umBZPhzlsibhrtlyj\ncB5DVzOL9gDNe/KTwbeVdSjAmUZd1Sbjqcj8kJ9o2iRwFWq5wwdPufCpEakt\nk4JY/aA8QZLkiiXeWRk8bQ1yV5N1dl7VAi5Euz5wAclDyZhuFynS+X8MbL3t\nb7vXNVqJ7B+TS6CvgAhUXlpP/xIz+ZkjRv26O8XOcDMNLNDG47lfUrvcDohy\nDUT+ilibDUALmaJuGStPllnzk7E6q/ENTZz403oaeoamV4CQ3N/iRCQJuwiV\n6YNjbMcKRk/9eeZdau7zq/im6qyj8XriGy1Yk3dZ68/S1SXQWbAqacfFHjLL\nbBxU5x1QDkVzzvYaR2ipX7NL2bhvl8vXA33cdxeCYWHWILtI8y1gzS1HjPTb\n4tQASeERlzhwBtFjUAp460H4vna1Xwd/TYMJnvAlBtOaV/5vM8zTX+vi1BUv\ne28JeEGlVIq0sXm/D7uaCWHpbkQFqIGGh1MphlmshAxWjP56DLRtUFF8Usqj\ntkEU+qe1sATWaslF9sh4cxn6QScu8ALDcc9Kl3BMIuAFBwl/oLa6q2woZJKp\n+US5\r\n=SAnc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f656636c28955c67aa27c8f420d2b4d6a54a5179","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.6","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-e82e35b-1584314543180_1584314593143_0.8450204578017464","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-b340863-1584504499281":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-b340863-1584504499281","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-b340863-1584504499281","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"93b27b3ee726c225c2a54b6f023f9a9a53dad604","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-b340863-1584504499281.tgz","fileCount":8,"integrity":"sha512-8XzddeNJCewiFxS/RWTN+BlbbJzWwCCe7ceie8pQZC59OG3rXCzsflU5ziHPqY6aH8mfZfLQ3e7vUZMPbdegXA==","signatures":[{"sig":"MEYCIQDM0zqJgCAJsMURNLnBo1lKU0baatoQmZlGLVtVGfpRHwIhALP4O6t7cfhl1xzwM0fVkBIpeAmc8kxGgZRo3oZChjdC","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecZ7rCRA9TVsSAnZWagAAwFsP/jO4Likso6je/n83RKdz\nmJwFHuh/mjn9amZB+n4l3l5lpBu1YBhgusO+8uVaoxijzeZ69iOYAPBmvAew\nb3owVeOG4/cVvg8aKi5a11b1EP8A7cZxthMhPKXE5mEAZP+viPrf1hdzNy0c\nudJ9FaeLNvi7nYRNalcc8YC3VNCu+GwFMpZmDAXijeP19fAvboy9o3UYS+mt\neq4vlpibDepBSVeefBjgaqIB6/f+0Up9EgBWtPgjPe10keffEfZ2KMfmT8aw\nzlAQSTtg6dtAqAeuiar+gDVy3Au/lZ2yAS5MfJeNbIVb4blcPqwp3S2/19Re\noQg5I52I2q97k32qkI5EFgxXUThOecV+wLJam2LAjUJ4DMzAUXNSDbXS7oWT\njVKTi9adusdRewzn61xeGVQmdiKOL+kS9Z33PLEYoc62qIYbdALaeJFTntWz\nVPKLxjEM60U2qSKl2tBgvsJjuRBDLS0LIEq3LtPeWESdqVi9Wbz9BgU4ElIO\nVPPJACqORg8g0coGCMfpCzFmtJROeiMe9bJIKKpNyiWTs8MqiJOvLqetFjtk\nqF+u++10ccEwQK0g5p5YCKpwFUGhpByrXsDujRldjwX0mBMVuDYxhQff/rRl\n6evdwpN7B6+yRODC0qaiKeXN4NKQci7qgPRAaaCnEXVSRDced46ftXNKrGjA\nYqQr\r\n=3uzm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a7ec619896b2f0da0c82692451deb31eaa8f166a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.0.6","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-b340863-1584504499281_1584504554777_0.8822105175811188","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-29c8eba-1584518489585":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-29c8eba-1584518489585","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-29c8eba-1584518489585","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"235aac8a979b6db64e3b5f2c4d7d603e65ababad","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-29c8eba-1584518489585.tgz","fileCount":8,"integrity":"sha512-tBAPzKXaty8KWd3LX/8W2MbeqG9fUfESBKfPYGCDz2qtgBaY7w1h8CwtLfdK4hqlCIz5y2HxyqW9kXIZMY156w==","signatures":[{"sig":"MEQCIHEjzRrdaPbula5xX1Jx4OUsV4HT5uFl3wBVGtt9ydxuAiBv8N+pjuw3dGHxOOMrmkLydxFeTXxSPd1oop9Bv0G/wg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJecdWTCRA9TVsSAnZWagAAcEMP/3BGI/LnQ0HMOxI8MUFB\nRmIfqLdEvKrl4+GO3Bt3Q6v2JxH79JEaW/9lUBjo9HWG2kOAaZJ8uboV+VWD\nkWsZ/J9+aqJuoGFZGBVjWrmcve/SGDFFVdVUh6Rf2z0GYlPJBlCRGP3qbOTJ\nlxbG4KSUKDtxCaxNWhvqlFre3t9Xlgv6iQk3IdnvNRDzDgX8pnuFrikzMrhH\nbhaLaankzqz+0Pd3aUjPyLaZ+88hOb8YOwoCvULhk5Qjrz3RT2JcxEfkv1G/\ngrLja89ywn5wuR8nxAO8CA6xIDzzd+ssLlcuX0VJwp2ATeIcv6MgQkYucbjt\n+0igsmqMJvFZB/tuGc4xuGKsJYARJNiMfHDl9Smk/6P17Qp0P52kkROuidAc\ntk3PDlt2qYBg+grZVb53o6I09TfXLng6DwgQmekrdXUsfUOuU21sCKu3ijiT\noPAzfwnr5NPmUFnq7eCh1MjqwPMVP/WEKQqPO1soZIdvIB7VJ0Z2lGVe3jG/\nrAOepPkzi7Dkh8BJDpVqsxroCM4yG2xoYnOaVOckxmExs71XMV/8b1Oag08m\nr5H1M4ulcoy36SkBIJGnqJeflWXy8iI9bklOG0si8U+EE2+sRb3vMPvWRZbY\nwyHeO1c8xNJ1izjPdCz+hUG+T9QH7lGIJDycjScLokV8v2mXSngC78JZqD3g\nqvf8\r\n=Pn2g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b6ba23146d61ef2d8edc8dd382e2f3e5b62ab9f2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-29c8eba-1584518489585_1584518546995_0.25060823840602","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a7adb04-1584719250948":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a7adb04-1584719250948","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a7adb04-1584719250948","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1a32b8bcc914283387856c537bf45900566593d3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a7adb04-1584719250948.tgz","fileCount":8,"integrity":"sha512-cFL7GSwqYY9EEQqgey38S+YtGrS1T2AV4NXN+zBX0P2K2aJJfzcfoGFf998/SIJURq8qamfy6fxpOacZjoeSkg==","signatures":[{"sig":"MEUCIQDcYlEpyQ1I8g2kK4H4S6giQlai/FCrBqKrYjub4f/scgIgAW/IfCcr34Me7tcQZAtlwlByKrQafIOvjeNZLU9FGYw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedOXXCRA9TVsSAnZWagAAvCQQAIyM2+0JyuHVnKCeHMiI\nSqTD5ZZRpHiNDr+blRLvWt6abEc+9lGGqFK82wSpSCFJAFd6KY4owBH8iiNc\nlND1L+xuqPPI9PZfPOyySbJAVOExwiOPmgoZUzMYffBHa2tPdeLAKblsyTII\n4ZgeQRg1ZFwPrCtgFaVN+xa+iWFg5KptFo947OKDxTiLuhAa07M91RMjnl/+\nTWzHAEpGwzzQWuL547cVXfzlGvrt+qeQ2J2cVxAomOsMbw8mjVy9C9dg/SS+\nlRG6kLMNSuYTUPb0Bej71q/IL69BXqmO0e4vGF3E9hyYbgn5byc1QDxLCkPR\nCVwT+F2uIYM72X5cUg/iecYVLLPw3MW03wgFEJNnONw6wcWzwdUrfA8ztEuz\nFDn6VJNxwVxYdz4SY5Ocgow7c/TCEkfjtmgBsrzGfcAXPheEiJCJUtaJFOvC\nSG4eE1fgrqVNio/mOH06sXpZ88rTPfwHbqrRQ/k+4Wgxk7fSGvrwRuM61Mm/\nlk051Y9mRIPSDd1Jbc2CwVgU/xwLeom/fjptZ72+Yw8gan1zo/xv+/ll27uS\n4DwcFKdHoQ0xgkAdJcM0D4E2bYRiBWg7oqoGvtbsmfeJaJs7URn/k28XFFc9\nn5i2sUHcDvUXw7HlERYU5zU39R1aZ6Mwo0pvVlGFh/RZ8sR1v6D8c1O2Lp7j\nSLL6\r\n=TZ2y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e1b0a78ed6b322fc57485a30a67f1693a561f6d2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a7adb04-1584719250948_1584719319085_0.44177841177439436","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-c875153-1584719510030":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-c875153-1584719510030","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-c875153-1584719510030","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"51badc59fad3483de8965c086ead5d3ce9cf0ff7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-c875153-1584719510030.tgz","fileCount":8,"integrity":"sha512-CYYnqoJ53XZ+XfMtoLbG+4s2FJXM9rnZl398NhkFg6eSgzFTx/iPxhM7gxyjuJ+JANiLBvusWB+RC4oXou3gpQ==","signatures":[{"sig":"MEUCIQCBu2cWBWJcuwqnzBppYsNKVGHa34z6BD8gVPP7SpDq1QIgZ4CMfMR34yWesh2fg+VJ4zU34znvtA2w3UUoeMkoGgk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedObNCRA9TVsSAnZWagAADVIP/03ZW0N4/uR1iDfmUJFD\ncNAm/AD/z2DxcNEOS0TnD2fFvSbpVETg8bzUEefk9JTnoydKsWFkEkXmIrA5\nf6fmsHiWeqQm8IHB2oO7E/SOYwdecQ2vRRnEmJBtvgR3eLQ+8F1YG4d6xH8S\nXDddxZQZjhWaFW3Be7yu6x5JdVfW2b46g+Anst+/kJJ33LfasBNh9gYgsBwS\nmCK7QH9zTY9LmvsxmclxsMTjHe+vC5DpOz/9DFhgwfWPFWANaxmPf/SNeGv+\nMZiusZampuSPmS7jcZmARRHqAyv7ogBTse4aRCux3LmBiDooUiMBvTbXwlc/\n21PD2RgPOQspGqT+NmJDRgxrFn1dqoZrodsv9iQTNpsA8lVDnnWJQQc+JYBn\ngf3xRiMrfTpc91mYoxKygfUNcLWIU0JzxPwS0ZUfCVvGS65ApJJ4fkkzNH9E\nJ2oRUupgz6IvAANFj1htsw0h6GhBiVJK6MPmOvcBcS/jbwDzjCSzzSYGSULR\nh/zY1Oc32Lld1wtQICD1WQm1MqhZsLkpVamT8LhZdCpn9/xSIJ9vdrA/0HDn\n+euqndDAOMu3bCdb45AN4sYoil+pVVXPLEveKfWlMuJoN5Nu27KAJPxNX7fo\n/jUMqawtQOOTlGtRN1biVSkHXV78500MvOPwcWzO7ybu85RHRMNLy/Vmlgav\netRm\r\n=niJl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"15ca1a241975a32fed2262d390b782017ffc5324","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-c875153-1584719510030_1584719564584_0.7973015232200471","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-09c327e-1584831868407":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-09c327e-1584831868407","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-09c327e-1584831868407","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"62ab458fc0fe1406ee2320a1ea490b0229a022bc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-09c327e-1584831868407.tgz","fileCount":8,"integrity":"sha512-nWQ4wo8jA31VAoICSpGp0bWJYuNzxaVgEBaecZdL9a0XsSfUG6T9WhUDOhQgdXa8tebUwkosuByzaXWz9NM2Dg==","signatures":[{"sig":"MEUCIQCGo0HIJNO3mAVSe3vHG8N2ORZ+dfoHGhczOvhAvlRVRwIgGm/1XRoz/D4kTgVfeAHxmsTts0MqNoxd+Q7Ms/5TwUU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedp23CRA9TVsSAnZWagAA+2cP/1981KOfbTEXZEMkLrXw\nbRHveDJVUNzkcx9YGT6+Zm/lT9DEOsETOk6BycdRyQeiGAVQ59XHHBTMg81c\nrLW569YiSNMGBDIFjfVQ86DE7u/lxCZ0fo/jcpbyPWDzl5g6FSPWtPrDJvfw\nUEM/VZr+fR+BG/+CVTkeo5v9B/ydZ3S1MYZ2cfLuBd6vk664PwTqeHEKenFx\nfjXNUUcImha4SVft1igvrg2KBTHnCQ1ZbRWRuMsabEOt+mzygWNT7DPOCXE6\nxuPNIsarU/IH05z1XgTKQ4FyBVfz21znKets0Xf+l6UiuK+6aKGfSd17h7Kx\nc7XvjHJbQmNxX4ZFkhrbXaPIQjt95ylSObyQC7cpqCnJMIY1jIsw4nN+EQl7\nWHN9ok4n0c+PPmkV+5hUDg+ncHaDoZ3h4Ofo2a3fwZY7vwtikj/fzg/Alt/b\nrVJgCrCohZUSwmYhc3BEHul3/IlKM6qn4SS7pfHkODLUoWNoz0SwoRteCG4v\nu30vW6GVy4ocFA8y9giX685lwjtTmeb0xAK9JcJeB8u5ZRgrMvxFcsz4Fwsq\n0o2AF/VqdyxWaHFvBJ9Ted1fKicclQhbzPY3iSBh0UqyYQibnFMfH3PB9kEw\nuZFR4z/a+FBYTS7zARcZ/tnPlwZK5BxQrnRSsos4NjMkghjXahGRBviNl5vo\nNxYE\r\n=l1RP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"292c69712c4c92eecdcaf427789d234e0d003dd8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-09c327e-1584831868407_1584831926568_0.854899913780991","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-024cc3a-1584852484945":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-024cc3a-1584852484945","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-024cc3a-1584852484945","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"62748c60cbec61837fdbae82a1c2c7b85ac5b1c6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-024cc3a-1584852484945.tgz","fileCount":8,"integrity":"sha512-ogaAy0IErmCGEQJRD5wD0A5rAIkj/UBtozJoYTvjMU95DbX6vFYy3Ji6pz9aCiyCorC+TA8AiUpB00VBE9+kow==","signatures":[{"sig":"MEQCICabNP/42vkg1QYNcJmnsQYXQZw4CAckuMs9mTrkH4zMAiAMi2v0IgiXMz8XoVMNKwu4oOM7aBPXYBqd8hiE8ha9BA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJedu45CRA9TVsSAnZWagAAxuEP/2aUcV97g0zH69jyz5Jq\ngM+Dpg3x0BQLu2gZ7O9+o3Oc6lGXbJM0RIzz1FNFhYiaTGVS5i7oiKIph0mB\nBMHd6A4ToEpq46z8hrEdbJn6XkzJzM2eWgpvQZZmylWsf3MJZKq3J9H/BoQx\n2pkco1+nzYFyAGFzl5DdD8NeRcW68dCCY+Pp++WmOLjLqJqe5P3pvfSXjnc2\nEx5R4pYT68tQsSmumJ/ZPOY7CvYYHLTMYM1I4fJpsVLI6rXKn/xNGL+ACCrP\nlFyou8jXn7jfsrhLRHSyykI29u4RrurkDTugj5yg/LNwL+BAlJMhTBSW1KlH\n9xO7LmETw2+hIkxCPovt1buB+7F5i4rETbnqNXgskSxTuAqC1TxsjRWSwtDn\nDIr3LK+rY2i0kcCJyT5+maCxeBpfWEf+xHCWgoUuEVBS4F7B0k/C+TThUtD3\n807AvI2OnCWVL+GMFuYQcTIhOkbDFx4oJxOGHs1O5Mg0M1P17siVO+7/R2Oy\nTvZVUntyxwuRLuJFj9VQ/aCGEnjdSOboXj0KJIhbOsHNyP1Td5QgzQSr8CG+\nQZu/nm84OGLmX6nbFwE5Jsl8IkGwOcQAm4OpRFnsq6ag/OTIehiJf3DfIlOG\nj2gTSR8TQETLwj51uHxIyo05OxRNZaCCkp/j70MvKMEnqbnll5k3SoS7YRny\nZSXI\r\n=VEdg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dcfd71718700d98b0ea1f7feb157e70cbf41f58c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.2","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-024cc3a-1584852484945_1584852536637_0.6996005703846631","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a2a8e1b-1584876898818":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a2a8e1b-1584876898818","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a2a8e1b-1584876898818","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"319cc89937dfdd3e9239522d18f2b95704bdd5ee","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a2a8e1b-1584876898818.tgz","fileCount":8,"integrity":"sha512-G+AKPkUGsHmrj1l1QJ+kEDVpYcAnwjNtkwgugzfZgUhsszgOKsLkigMTb9VrBDRJfJumFFYv8hc22/lS+DyWxQ==","signatures":[{"sig":"MEUCIAZEMMVG5CtGU87GESAU3B6VkJAS9i9weUa9uRrOwfsOAiEAj1xsa8Y+OShgDtUYBYokGK311jJ1OzyG8SgbjaYJPyo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJed02XCRA9TVsSAnZWagAAH3sP/13vNzGkRvGj7T9qjU9r\ndhOa/z9IEie6S6yyzp+Q0X0jQYebdXfeEiTLXw6asoH3YQf+sQaQQaVe8fw3\nLCLWvnnh7C/tXN4geErrh9l3JcIdzrx54BrBi+3tcrUSOKu9S6nwaepGdJpa\njvzPMPJpzAWDAR9aiKH6v0kxFpHqtNO6Ui2K+FJY8k0aI1+FJnDADtl8vXpH\nkou580MgZdUT5ogD5zZvdbIhEg0BleFQ+BI7bqgY7hBbowx9LdtVsVNOywVx\nK74Kj43WWj2tgCxXfnBVT8i6c6xdr66S4q8TV9o7jjY5eP7UL9JIU7N1pvH/\n09+im0bD0ICI7pIp/JTWjTjzoHkPgMYbqQCv/CVAjggG40Ws/AW7XF+XYc4i\nDOIt7tTL8Oxe73WXsckyCXUS10QDKbtdNtNKbcQiNwpCOfen21vPw/hy7Zrp\n3wqtkXNaKMBCC6/nSes1je3Uiy/GH7JhxPW5aVXpAlDMGgKvZ0MnYfsfLNwR\ny15VhUxmZRyQFyWV9SpNhHR5BbFgCElUNulvp5LJisgjjNVaMGcSRjFsCAJf\nxccdXuoGm8SmyxMJ2IsOkNfSY4ZTxJgZUdiVp9vMZ3GNpAjvrKFjbI9lXljU\n+nM/mnWJ1yYSd/kwROz94wNaW8zSsPuZ5M+qHHQIfNO7G+NYV73jx/L4Irk4\n/nq+\r\n=w8Mh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"31e3993e80e927a92f925b0ea2e8e4b43d57d345","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.1.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a2a8e1b-1584876898818_1584876951197_0.029926187058987308","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-7dad17d-1585065999095":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-7dad17d-1585065999095","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-7dad17d-1585065999095","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f3f96f6dc17ad89ffa4b3c5b8e073b6e918b2172","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-7dad17d-1585065999095.tgz","fileCount":8,"integrity":"sha512-4wSxc1KCAfRtB13QeG2zkKr4dNu0LqwCupLSs3xlLdgc8iYw7Myntmp9gyRbhCF/ZhtUf6p3PxxE4XQIqci6cQ==","signatures":[{"sig":"MEUCIG9eim5AdPkj+FtfsRskodhpB5OhXsN3AbI/XpUpg52mAiEA96bDY4FL0026e1DF08MIaxCwnqvJJ2qn8jsWBAeNuFg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeejBJCRA9TVsSAnZWagAAgHMQAJLZA+SOGVcjAcmrtt4K\nEWg/hzotIyK8ozB6R9ID/XrKtxsfmhHQsYiAiDI4kCwsdLrwgzmLIQQF+5Ir\nbqPAPK9kfx+79c3dqvjofDp5AFTE9ori8jaXu3rIGnuEHrweTXn4RjQjgsy8\n1zUQS2na9QQnxRKsDOlatMgQTx2Db9mCVM0u6x8Veess9E+oJTnVe9iet8SS\nVmWsXy1JHBFSFb6GT2l6tlfqfNqXcyBeTRPhcyXDCgrmFQDE0Kcf50JdKWAb\n69eeXygNkHsc5Mm7z3ujkkYAsCjsKOdGrhVHpXcZadkAcTqDwEvWlTOgWPoE\n7O8KjpN0GDPIuYiRoJhSkDGiCUE+UcuD8DT9ZD8Xx6FNOytm3E5poFqKK3vq\nSSnKbHHasKdcK8LVQGQraOi67v4tXGUEk5cAvGKAJHyzPZD0mA3Ixo+xwLzk\nRrpouKXF2ZkPujHM7/Dc4QqTqTyLVRCOti5dkurLu9wBmjYLzUOh4tsHOl2s\nR6OMkR8io4svPkud/Rf5EJZYcJYajc2OZgIYZfJd2SgRG6pD5zFzEEKBpHku\n36Now25JmAulLsezx0rfgbWflS3i/zvTnTrvGLkSP8qbsr0hj0Q9N0PGtoF9\nlwgt7s4w4oCZmUO7woAn2pnKPc2cX8pDFUv3T9/d6Bsrig3oC/NYTIbHf/Od\nnWAU\r\n=pWiG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"06cde68ca3454bdf3dd2abfad84d2bbb94916f98","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-7dad17d-1585065999095_1585066057057_0.2885940093692918","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-58883d0-1585159380708":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-58883d0-1585159380708","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-58883d0-1585159380708","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e0f4e4afedf2d66fba2c9b3dfbd31fd65a675fbc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-58883d0-1585159380708.tgz","fileCount":8,"integrity":"sha512-YPH+6LUHQMXVIMC7dH5PHhLpZ3xGQrXROX6G+GY9zNH9jvbXjJv9SqhGqFHHewapVgCWAzBNdL45+duyUO6ubw==","signatures":[{"sig":"MEYCIQCgDwYcL87cXIPKBl1A9k9p1f5p/CF2AKiIABfUcvBJVAIhAKmTNE6BUgqKfLULKLL5XiuwEibKr5+VkZEWlg5AtZpj","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJee50UCRA9TVsSAnZWagAAfBoQAIXpbYSlRPBZGbj64Zjz\ngSzHAEugCFr+TyNVKQBduaswUfq1u+2mgw3zix9nAYLzKPFEMjIbdKRvTq6F\nAcyG4bro3pWwwxA1vawkCoebfs2Mf57BYuoXrSZH1kr4OpJoVVjweg9C5Bq5\n7U7d06fM0eyFNRrbjGPuraRaoc6KFzm6kbajv8JDQTtFtW2S2vete9ljw62g\nG4Xt5+K1VWRXDga1jdLYnwcuPkv/t6oUfnLPoGg3zorL/NKX1/Uc5uhIveyu\ntcXng+FF27HR//3nTbKJmQY+v77OVsv7hAb0hhJiTEr4kZU+j0EbK8SU0ZIp\neCfyFkW6TFAeJ3RW1e1YBgdP28mx7dzEPYf9p6xf7ZJJ6jaTJ0kK0O/kq5Jt\n58flsqUHz+WkTrNiqesLaI2DR+Ind/r0Z5LfInKBT0CUtZwEfpNQ6WHOAh59\nZy9eNNFO/5V7Vf7JJz9iDeL+UFmTWzaEQC4hRadvfIVDUnd+0Bq/51NvSKp6\ngdzkhhNvi/MOkq7qeOgIIcIk0nd2QCM0LiYbMLE9KjEzwyw/o4+pIGScGKsC\nZZOn/pt7rJD7tEg4h8VVIjpLj7zMHKDz1a67JvRwWADUspZFOnIrekR+aiUg\n3pRN+GcCCTxXsjXOnu7PQ6AtDk+TLwHSfbYXQ1QBTn0pDUvn19wdJq0U/sPe\nM7lw\r\n=eWGt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f87e9eb8f34af6638274813942d41a90ff5f0cda","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-58883d0-1585159380708_1585159443458_0.12631285101825718","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-33fd1f2-1585160147428":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-33fd1f2-1585160147428","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-33fd1f2-1585160147428","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a01ab49a0ec12c38ccb1eb9421bd914eecedd732","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-33fd1f2-1585160147428.tgz","fileCount":8,"integrity":"sha512-SPg3ph/3iY7AComkVwwxNABZNlo5edHerOgdyYYwrAS6V3YZ/qqgyw0xlGV1jrqcJd6pX3SxzwIQq9x+0n6aBw==","signatures":[{"sig":"MEYCIQDjq88w/aWFCo1UGH+4rPjv02bGxRoKvmO79yRfxH2CNwIhALJtPHH7W3wplHktC5MYJL1/4zXHz/6JNkonr0L+nDwf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJee6AKCRA9TVsSAnZWagAAGDoP/1Lt7WvXrKJjxOD8JRN/\nTuFVIba0TJzLnQXhZdT3sNWImYq/PjzRw+zQeSJTTzbdyAVGs0nJW7BsXLoQ\nEyBI1JfJbHpjW8XoGLKxOe3D4LBH7GAG7wbpDTOuRnJbFYPlxHa/plcJNxt2\nMjhtL0/0jH0dKwtF+3S9a0Yk058f2olkT+pA7x7wtw6mt2bQsE6xSJHFkEys\nbW8NGcFaqbUbi76qWmRu2frGsT7syRIli7zhglXLDNvrerUzlYLH+t557G/s\n5aUd8J079L3fS0ZtSc9nXtearbnmtV5vNj00NWiqbAVWLO0Pp48e+zmlMuvV\nMPzETf6Nj0sZH2G7iq2WDGYJpit9K6bZH/lqnCGiwZB7FN2m0p2I8qHLTESF\nxFXHuFkyCN28pa3pRTVTqRZDsHo2S0NC71lR10LuDUnaLWd8UmNdMUal0Bl1\nNIgEUlOKr7TpmNc6CakbWikrW06xANLVzUQVs0R+WjLG8PbJh5niKVo5O5pm\n2hPIHw2KFvRIDEISMm9Cn7naT0/pKuLVZKZNBNIRs/aBlqUtYgomxQwJigbu\nEYNbSLZZvuaKQ5W18Lb10LrIIBm9b5pkK6nqYOohcmHABk4UzYZD2iKj679x\nc2ZyZ52ZLkSkR+4xx0NuoBhKP9eCJNj8D4nvsWMH4wY6lF9ShloGOKnIeKMw\n4TpZ\r\n=SpU9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7c477714385cbb79c8ee2cc7b045148827d62f5e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-33fd1f2-1585160147428_1585160201543_0.9873696143946373","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-64628a4-1585215564804":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-64628a4-1585215564804","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-64628a4-1585215564804","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"53965c1aab1d9c4431dbe7983ea275eb9f6c80b6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-64628a4-1585215564804.tgz","fileCount":8,"integrity":"sha512-PZfMGTIkP2pacEVdFQmN9FBE3A4LvBQxGZve2PeRFREUlRLkd3HhLBsEJq9/z0UYRVmR2RThZXtKr/TADujlNA==","signatures":[{"sig":"MEYCIQCQBuSy8fwTUUKlaszyV+2KjCSD2u6aFarAFLCn9mX7bAIhAJih223lxCvhrEWVakWgR+OyMoDJF98N0J05OYxl9DCc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefHiLCRA9TVsSAnZWagAA+DIQAIEiDLBeVz1dJgQvRrpU\noYuMS/PbAVxzPrbtw/R2FWsHOmCHnRehEbTRtpVjhaHAcJTcAjXAye+ff0zv\nXWOSxc+HEO0Hq98f02LMgkWa0QnPhF6FMIZNW30j/Iric866EDm7QmyUrmJK\nz9De7eVsEykZW0WFmc7ZNGWHhLpgoj/1GvliQojLS2MV2IE9nAVb+09wXpxV\nPDuf8e03cofQBjixk9ESvDz/dPjr8vxxJ4YQ6yXifYO02vOF82/kq3zxfjGo\nar9YxMANKXxQt91cyuxwbkJ8vwVcMKfUt6WdZyaF+hxi+d1Y94lzyBRbC4Wc\nBBPekDotXYw06nkJ7DGLsxtn+6dOAEqA/cAUKKcS2kJeEOzbEVsyrJvXDX2g\nHRL0zfzcVxHajdPxGHp66cLnpmQZrx1B0YDzD/KGyQtS3iEl+zURWiBDteMo\n7JPmQtaQWJ6HDVaNjl4/k27nTyiIFdXKDkIT0XDcOISQOjcXvtUT/vrB8WIM\nXU+m1cxkvq9OKeYRDEfBHbErX+zsSQi/hrIpnW82ZBYhfkTLV2IdAMr9cOoS\nydyQYjarkCmUREEGng25pCvcQBxiLOpJ6VqlMPfcoxR9Tc+tgh4hQfo6EkDM\nWrbClOfs7Fea4CVhh7wtOKGUCkOUbTaasdq4JHNopPEriVkJAewutDMSuc6H\nLHF3\r\n=mL6i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bc40a8d248d8cc10b4fda60b1722a5d21d67f288","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.1.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-64628a4-1585215564804_1585215627389_0.7458846931771137","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-f85fe06-1585215584641":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-f85fe06-1585215584641","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-f85fe06-1585215584641","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9fd4e56701e0a07ea7b3f9f02f6ada7f4c5bb656","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-f85fe06-1585215584641.tgz","fileCount":8,"integrity":"sha512-c3XH37wgKPm9BVg3vrTtbvBkf9I/8nJFsXuOr65GKANBOh/trDnwlkN1+uPsb7jH+/DNA0Hcf6uPi/nv6SChnw==","signatures":[{"sig":"MEUCIHIezYi0arkgbaaJq69IuOHEJTX0SMdAve3cfdntUXpmAiEArNn3cOI/z4QSuq6Q4qUW9sPGXlZyBj/W1kTZa8b5Thk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefHiUCRA9TVsSAnZWagAAsesP/RsSJ8O+WvKM3r/2dEn/\n55RnniLy5zJkgdpeykE5b4k6+TCEWt7IZjp67UqhxqOIjGA0BHRttjvjExaG\nGxp8e4OvJzsGxZC9hMhFIvy0aYY26ntAz4LMBTqclkZ4pzmHKYRaBr+55/2P\nVbYyJ9HZ1vqDKLoVpkX3E73bzk0o/cXDwyE0IZt82jcjXxH8tlNL4w4tAggp\nbAwUynrofgsZpuPtfCa/6unc1eU+B5trcum7i3YN+LweqZ90ZNeHxyzJ7ASD\ndkyaqsvWvJNruVJEJ7fWSWo2IsUvSfmbxow2yyJbNMZoGEY5XEwVqO6SzKPg\nB30U7IjqdgvfVrujRm2Kp7GnlKkofX3ajv59YhNDJvoRppE7N3gxCVGafa7z\nUrh7pEUrWin+gZevby9zDypTP08sAGrtOAOVJ0Lt7rjtJhZNfaAN4a3pQtiQ\nEVnCv7SAjcBsr8NX6WYLWzwpXFinZad+Xb52eKh69fo46tby4bL614FEZlal\n+6NL3N0U4HT60DDS8aZmWdQgNBVSqeCorw7gf0aD5/tvLxgECsb6BruM1ZRv\niRLKBfULiZVhrBivjtDA5UbksNTYDqaDRxcgbOZDFaQYt96iDAhb/gAl81ZR\nuncqmB8UkogRosQM6maaBhlYqpKeK5S0tXcrwTKn7xOs3b0ArcWo0INJHQ/t\nIKg+\r\n=KoZ8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e9323012aaea766d9058cabf505f2c6ca42f4a0c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.1","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-f85fe06-1585215584641_1585215636166_0.17123336571692316","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-5b50d3a-1585239960903":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-5b50d3a-1585239960903","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-5b50d3a-1585239960903","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0f6d843566decdb0d858f15252246cb39ad71028","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-5b50d3a-1585239960903.tgz","fileCount":8,"integrity":"sha512-wCe3M+DCiByHMVH1gc7zzpVr9ssNHqau14oyzXvrBE5R9+6asqXGzmqrbVQjesmKDicc4NoNYOKIVnlBPHupIg==","signatures":[{"sig":"MEYCIQDb5M2Bqv9juHtNX4X7fogHrLRwLMpg5t4Nx06EmIJT0AIhAI0f+BDvwgkUqvOyRkWjQ83NDkoSVIesc4J1ieUXYl9E","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefNfaCRA9TVsSAnZWagAAL7AQAIvN12tGlCNO72RjSsSN\nNSqpt20v7SBUMVVBRcMEN8f4wnd008stKqBEjYfWEmD10aYOkvFU8I3Em4xq\nDVCiySZsLHX/vco+gi7epuaZI2rlIoSlY09KpC39yNn0uJ69Qv0CtWvQ8C+y\nXxbM9MTcqqXxABTh+g9Sse2JTymwSbDxIM339hxV8lijgm6seg0MaKHxNFeB\n4udAqKWqxnfRmHqluEOY3WHIp33qqKJcy9MvN/u7a7E6uZwXmOD5eKWO23sY\ndj3EESyj0Yg32URJkz6r88GCDE/SgrAw3vpCl9KIkHnzlN30S0xE31zMwM96\noNVpx3xEH8EKdiJJ89wHUztN8obmwAMstMESzT3MiKBZhrX6ofFrDNZPSoxm\nc0KAE3ayuD+bnthhTHjaXzx3j3PWHn8EbvWRK4N8uNcv1gl4QVydiY0uMZ0E\nJw2kJqJLmloTNfRzrtqSVwuoc3xrFA6WW/Cx0ZBGPV43RhR9bdlYQDknyffq\nZ/9P0O7l072/LX3usLha5pG7mMpaHXbgJAg7p2Z5p0Gv2VXHf0AwirjypDjN\nnJpjueuZvWEtzBUL1q7xn3BviZvuIrdVtgNKcGXg2PCO0BHPhwW8/5CZHqiK\nuudPsS6OICbNzczBA40xyvH1tldOA6XtX/I0iwXpuPpUKOBKjAaoZyIMaTby\n5rOJ\r\n=FJL8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7eeb0a64f8c9da6cbb92f29770fe04465d2cdc58","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-5b50d3a-1585239960903_1585240025446_0.18881423522684027","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-4f85072-1585255148983":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-4f85072-1585255148983","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-4f85072-1585255148983","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"cd06b9babac2d9c4798a80dd31b2bbcd6ac5b749","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-4f85072-1585255148983.tgz","fileCount":8,"integrity":"sha512-pYHWpToJC2ZVarGUXJ9ZBqKEnfz23S837zMKdLjS2LOAJNvYIq9McNPqzfo1PnJ0GMh/QmhccQWm7d6in6q99Q==","signatures":[{"sig":"MEYCIQCfPzpk6N1PSDMIJhVr/LE6tqRLNcqofnM6rFj1c3HI1wIhALtkWxZa6K+pGOKlG+lMGioDX9tWsM3OPVWoes6/p+SB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefRMpCRA9TVsSAnZWagAADFAP/1gyVrCzwpwZm/K6pL8V\n7WaEYvKnAcyAxaeNarvFMmp7/eqP8PKRTXVenypjestT1u5UjDW+8sRwtIYG\n7zKdM/uI7F+sRC5jIZSRYQntnJQ5STFtEDCabC7hArMrVaf9hvWdH9h7vIke\nFOZu5qFjupZ48nXQOZ1bznkw6LBs7hNfWKOBddSaIP9KnQjXFIBAf+Ry3bWP\ngtA20uCIaFG7C6hrUj+qLyMpe/zS6dydP5Q5cQmVb4mLZSAoPr/aCK7uUqyO\nSG7ckXfDWUxCzJk9adO/gZSAhmirVzBhjn0NbXxzbOPL9eiQfOmsDmJ7tqQ1\ni40Kz01+jwoR/nKgynZaiggPJE+B+JKPzbhRU1PWGJ1GBJc36w1ufkhfNDCR\nu4fZWGHqW3y9ZD6RFHhMF/N/TBA3huTLSGs2veSiNwT63R/r2snlEP2iVcjI\ngIqoAS2KoLrfHeyNsht/XYGriTaKmInhD86zWsNWU3O/hz+DoViByBUdkcai\nH+7im27XRBC0d9fNHeQORdXgdkFsB8OxhcQzVok/nyLJMz2BotAdemKCgblU\njW79fjSOsYFT4x5P2vXSweji8YOI5pAXdQendHVQN+2JYZnJHApf/2GwQaU5\nEA/cwCsOa7dNQYawFjw+Bwqa+UQUBVDrs3Vv/tXJaarOFHanwo2FFSNuEOm+\nx4Yr\r\n=v3XH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"951563e86de525de8815984b74127c609c790892","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.2","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-4f85072-1585255148983_1585255209047_0.788783168751455","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-9956bbb-1585255171123":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-9956bbb-1585255171123","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-9956bbb-1585255171123","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"db1606e717940f64ea15874d63f790264b2ade7c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-9956bbb-1585255171123.tgz","fileCount":8,"integrity":"sha512-Bs3cRRMQsS4kHtd9ZYnHkRhpR400VvvMhJSNv3VXV6xt6ZOIDHnh1MwGvuHRc22j7pXicrw1FYkNKfShP5bvvg==","signatures":[{"sig":"MEQCIBfiyUGdwKAi/66C+a9RN+4UokdUwg638iCZzbZucwb+AiBtc6i8Pvft1Ddw3rZ6FB6vuS1Bu+m+ZedjnyxdIqvQaQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefRM9CRA9TVsSAnZWagAAwKYP/RgOg91wX2pQTOc12rCl\ncKnvErLVka1lYSNH4hVKGGmtOQ7eTWpflWx1bcYV1eMs7j4GTdL9vYF2NlQy\nyT6pWetcpBMe2yu3rAn26GIAeriAQwz4Bt8SaM8wZXV5d9HUE1rG7jcrqOkQ\njLGEr9HVg0oOj4COxBjVQnfhmdJOdgixeIkhlWjW4c7HQax4JebX8QjOsVtP\njWFWinVN0kMnQaUxlK+Pza6s9p0VWYdWFJg4sFn8ocePQWfWwKjcJSCeP+7Y\n7gTlk77JELlEXCk2d6I7gwtSoTqn7kTGDmCVyWipTTRZWxkg+2KQNHHnFnW0\n4zh/dFIAsjkRNRZpCaflqZPu8UR3+/KVTkLtEEl3UyUZ+cKdUrAOMVmi7Yam\nbOqMSFWkCOG7oc7TPARlghRXyZuJHtbxensmKlY1gJzVWQCQlv4VCCMcer3w\nc2UyLz+MAgkRuRl4+76C2CuPfaXnS8oPZWzCX838TbRe0O/tsj8qlsWhyvCI\nYadHbXaqUqUN1m1COqki7msohUnjo4Sc6psxF0R2w62Uwtq71Jwoen5pVb6o\nD4hxoaWkI4asWy+xkb6LeLDTPVuAq3x2r+AbgiQYJFdufSnpa+ybBGXQ0IBp\ntpPloZbG8msfgfNYCCGNMgvwnNLU3xVME8CJFnppSzhSx5quc87pN75UvU6y\npllW\r\n=H17W\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"22f8f3454d3d08de49e00f9ee714c89f3c87ef14","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.26.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-9956bbb-1585255171123_1585255228779_0.9900364616719366","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a350247-1585296748232":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a350247-1585296748232","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a350247-1585296748232","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"de40e83f26b6834dbee179dcc4116045fab22ecb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a350247-1585296748232.tgz","fileCount":8,"integrity":"sha512-Byrqnef30uOdrckAthbszp05ibh0hfS3PGO3gguvW5cJljX4hWdGrBNyuHEbdC5K1hKR1CnZC/AXluLuK1JROQ==","signatures":[{"sig":"MEUCICxjcc6ZxUDN2qgvRJcbqcwortuauz99TLfOVt7fJvdNAiEAl8ieVzagtJs6hN7AadljRG8Zv3aG6Www2NNcB/2R024=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJefbWjCRA9TVsSAnZWagAAgMIP/RwGMitpsSAps8Uwbd6M\nOnM7t4PPN6081wHPBCzgW236k7hhg68jJvbxjt4VEeLLlvdpozmLZOpI5RcN\n2IhPuZJmDwdo1amTvU9do17M9FxoNdRQs8hsXWuCeqyw4E8iDsUCdTucihwo\n1UlYCj6FrEkgf4PPYJsUm/Ma6+86NkLpz8dOYCSlovwanQcO/kIYo5k+QVwo\nPuP8VonX9OWZHwgFfh5J5MN9T7hi/1azpn5FRVnDT9w+ZLZuOTCZsv1jB+qs\nI6F/K9NLGLIurWw61UOASx8yr0yfxsgbAFgkkeBoCM/83+TIRnx15uhy4lR9\nHGMgyVXiqDQwkgeDfEw78H4fM3s8ZrwheUKzstGejwaKiSxU0h+/M7kncC1n\nOcZQnB0B4D36D9JFb2s6Ib71qNQmpbmi1fB/MOnd3XDtpdVdvZ8bp9G1MoDb\nGHH4/4OiPygBiCB6EXtper4Pb0yoDzHcvEX11B/xzp0y7Dr4rwOMsMdsN9c2\n3igT1vQm5Yx74at6O7EXZ7XrlaHHPHl6rAJ2jrYU3mlmZnIgAZZlrH4fz8Ku\nfUtYf2GI3wZfEROipYaJ4pZStFIl813EmHUU3xRVx7Eg2d8YCSkvVHFmX7T5\nBwNp5dUttxc08dpppwZd0MIqFI7tB+Bu/gNY6kaWiz6fMTmiij5JajsjZDq6\nRLRt\r\n=kKEx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c9d496a7a55e374c0dca579b3476a8909f754e87","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a350247-1585296748232_1585296802976_0.16362807762721077","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-df43901-1585510987354":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-df43901-1585510987354","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-df43901-1585510987354","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4f684e4f91fe6e2ed86955584e61a9207d0d4903","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-df43901-1585510987354.tgz","fileCount":8,"integrity":"sha512-o2geBWkNWSACUimUv9SQ1/Rm9GRVtpPgwdPCmMgGZ/E1DkX7WFsaYxcHGER1HGZJyii8qbZqb7VLzGLmFQX4XA==","signatures":[{"sig":"MEYCIQD3auSTJk80ODRtPoBnWySUJdwFlnXWsc9K+dRoJTdJ9QIhAMTMJRYgp/xYiBjcpw6XbEoB7FT4ra3FelE+cTt/QMN+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegPqBCRA9TVsSAnZWagAAO+YP/j0U2jz4nQ+AXiwan1hb\nxt7UejqObsKyMm5kURoPbLmnGwAlXsxJTPvZb4/YKuSY5IT54ontiZ52kALw\nhWfuUjLoP220nS/H/2dD1Ey3QAZ7zqNUa19p+lVsMv7h/5eDBxthTnQoqmEe\nv8DH/017WwYT/PVD3awwI+qTW2gH+jFhhYZECn3bKAjmGAKBqhTALFPiTTSP\nM4vjFW3kCw6VE9sjgWAsBKPlEoqXL0VO/Pd8wUmaxLhNx0os8XQfD6lVEVzg\nR5ltY+Pq1HpUt36fAF8xWm1A+TBMojMIOAcM1wMCQMC1QiV9viY2zw3DeQwS\n7dY/C+diUER+Y2J1gfKYsUv0aBcl4q1ljBQUx2LBSEkqnK0IHhhX7EqLRXBd\nYPgxx2Ri1kqyq/dnE663EHFDd1ns8nT538diLDLTscMJc+QQ0RerpbDVSRPv\nuwePp9C838ntLy0658C0QjK9MbvKwY18sejnujdhJhyEXI/pX0v5ilf/VgX/\nLjMsOOIU/Hiv7HXluJAT6T6HJIYzGJatB34KWYktLIvNr7DR9U5E9vhi2J6f\nAaRoZDmNz3aqwqf+nh0hphCIQ034yEe5cmgX/D5Y/8F/voakwTVSMZbjdYrc\n1HIsegJhO9dHRQgF60hu4cDCirZX5ZwtHrkSrCy9bzs3TRriewbUJqUjOpqB\nyeiu\r\n=ahTy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4a59150b2d9096d3d406e6a8a0722e9c70f02b41","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-df43901-1585510987354_1585511040497_0.012030825218652064","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-93332d4-1585511177742":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-93332d4-1585511177742","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-93332d4-1585511177742","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"85f01667fea397ce919c34048db73354bf52a158","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-93332d4-1585511177742.tgz","fileCount":8,"integrity":"sha512-+TMyY7gsi8CJbUYFLmf07IJl4T3+TnYONtzqSYnODNGy2C++Q5THBExw5Kcu36kmoOgkhODWreXdIMOIJhnT7w==","signatures":[{"sig":"MEUCIQDlk/1aWQkz/KIH7k8kF8iVVcQW2gEBaXHGlYdqICJs0QIgPhXpbc4lZ53W5JgOUCjGNH0Ax1/CdhOmolcdxYBc4LQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegPtECRA9TVsSAnZWagAAymcP/3mwvGgwKAa0bD7emx2r\nY2crzVIzk/OEEBTYgt4wVT+1C2L1akSU38g7njqSVOh+A9k3y7g92qdDirCZ\nDbwfGY/StHNpHyznNBzAS7YgJIqWtP9nf1vDnU7aTasNU0hzVawqmAJ5POXu\nik/WullG19sgdZpR5HsuFRP9QZ6hNd/cQ7iAMxdfpGCOD0IBu9ZqoiM0lHh2\nxztYzWR4lH4J2UXiyM1rCuzFMFBUU+BXc8qk1lC3fT6ubjLUnwigCobixbKE\nznhR9pBQBzAzgDZ4AV274t101ZIF6wIuenOFTp5/0qkC9gHTPO6+MvCrB7bp\nkPau59HXqNT5+v1GTdHYTFBCWxZK5HY7WbTzjap5QxRcnF+gGVnATnWpBbqk\nl6ptBXF8irshyn5ut+KeRFYvCGGzIkjfSPBiNqKjHE+fIVNQx1ytUkU5VCkj\nzwexzGFKabZeXg7KR5+u/ymI+LDT/k4j8Yt6B5vCfhr3R2O9JSlJlu8pIt2p\nqnhm4/Y31v73clLS+IBeD1o0KctJw6WPQynn5cXf9fOPAH0mcS9asOLcOm5M\ndExKcdAh4P5rwyo32lDQrLVhzsHsro5C35s46OQ1y4wgy1v2ZDr4iKRiqodn\nMrGSIMNWhQ+T0fyhya5XFnRYfGct2dunu3h+43ndW1Vy/13hXvXc05XFqQBz\n+v0I\r\n=0zhP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fbf1d6db9556e54ab40dd8aad5aa019cb9ae0215","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.2.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-93332d4-1585511177742_1585511235832_0.15471583167511938","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-efc3428-1585513774336":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-efc3428-1585513774336","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-efc3428-1585513774336","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d48eb193f25aede2b9ac674ff922574e1055785c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-efc3428-1585513774336.tgz","fileCount":8,"integrity":"sha512-i2Imh5OcwgY15r+PbAlUCMj3YJKGPdsVQoAYdWkzOF2PLJTkJuXwb5gGQTIlg+ULACX8mfpmd+Q2lDwKZfm6ow==","signatures":[{"sig":"MEUCIQC3Ntk62UYJgaVJ4T/WJ2RSEFT4XcMukBmrvVT7+a1G4wIgWcEn9tPEY9TK/mk/UJgbtJpgzpHf+35fU36geMFNuNM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegQVuCRA9TVsSAnZWagAAkgEP/j6MTn1U1g2jEz0zhbeC\nCeZs9j1mhOGbdvoCFYLpIu2gTm8hAccINR563iRHzQPMPIxeQTlNtbZYxx4Z\noOY9lUt+hoSPVtvka1s9LBX3IZcLUwCGblWHBITq/cS+VL9VSbQYNtmYq5Ca\nf4sQaVq7iTpnJKbIa3s5eRspUi1HU0G94lYlRCwXTlcFJSLcVzr1iPF7tiXy\nRk0poYdf44EvGwhFjd9Q8s/FWKdNnk6FAuDJstHgumM/yTAfVJsZ5hqnq51P\nJnksmETMIvEM0GeliyvoGd4FdSSY6ud66pRdYp3MXJnZPuiXLH0fPrZW9ouH\n31HEqdvkvoG9/j+lYBPuyRK2B1DfyX7F1bDJI7uXdtYfwNxhVXfkj/41eBe1\ncR7OEUhlyVDNEBNb9Fu8XJZt8nb9E0qM7m2dZ+PyN2u8UsFO4Ad5AxQ1gEtk\ndso7Y2ycb7NfHa0tBtqWf52ISn33sS95lGojvhllrhc0fV3JOPbsRBZ+kRr/\nQVCryZcSmDac2sbI1z2R+6UlMVkbqsgFuB6S1SOSCqgZqZxJh5nKerIWAY5f\nYbMbKAHWZx/jXNlmY9+Ngp54d18VXkTJHeYZPxu+nlneSMPRYMJtYyLb9cHY\nOJNxNAzMDnrqB0kqLB/IRAYqAjH1ugBJdxwTEU5E/euaBbRek3TpfHRAvN9U\nsV0b\r\n=NgAp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0c1b6282ece69f666a1782c7f9edd61cfc885daf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.3","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-efc3428-1585513774336_1585513838199_0.1218455481012426","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-87f5d3e-1585549622185":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-87f5d3e-1585549622185","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-87f5d3e-1585549622185","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"da43e20485d3ae1f4d98b70ff2450be14073c8de","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-87f5d3e-1585549622185.tgz","fileCount":8,"integrity":"sha512-DpmjySgNkEtGaInjAJYZyXTioa5w1NUxZ56XB7usxvWooJ0m0BhBfAu3ptqaYyzRSl0m5x+jBNggJ2ZSa4LxZw==","signatures":[{"sig":"MEQCIGuHKlDKZDVxWbSKcL8EaL3eFL7iA2j4gMR5bAm8sDREAiBJZKdx1sgNjZPUXjtYCwnKw578U7XUW+jimB4y0q6dXw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegZFvCRA9TVsSAnZWagAA3M4QAJOwtHp2HOyp2ANNHg2+\nxz/hdTO4FgytcAZUxZq5xAs1h4m+is0kRxyoN6YhUtTVKr5Lk0J1yj4mAKsS\nrRyD7gyKG62VBZzl+gbFVeUdcffTvvHWfukQYYsWIq28OXHTNdAGeGx3JiaR\nrkfVtHBPO82sv/EMRufyRwcqt7FhLti1rTLrKGd/SwsO5IrOnWvneSQiI8Lv\nkbilAG4eum3qeNRm4FSgnRvPQR91feo55ORPOeQtDpuLFT4lBTeDgDJT599K\n68T4t3+dfuQXnij5habArOehYWDG/V6UfW6Bo5PA1SCcNuwodVVYQxwAbWJD\nWrLcRgI6Bn9QinvGlLOPf2pglX5uM4xqF6+iaraT6nxUnAlLsgj0K/Glj0DS\n0awv/hrk7rlRtGqVCo4UNR8O5bLhiQyQJ3nA4KUywqJapl4t2SwhKAENzvrk\nMRW1zL82X5I2dbbvk4+CF7vHASpSHZqeG4HZy+w0vmhniPDv403i2l2DYD51\nwEY2NmuRRM7zXS0FFfI2l1rELGLCRkTwAthvdDf49JPIJyF8aklPHA2U79sM\nAiMlQxFmOPM/7/AvoaLgZBWkew67KooTFjCA34kj96KAykITJ89VjWPFXKUD\nKkLayPDBabl3mpT+SKYomo6g8AyqWb1zeJ6jMUYyiTig0P9QR1KPxL6snNN2\ncuNg\r\n=ge+f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7dad6c01e341fc5fe67c8c9500fce711f31f2c6d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-87f5d3e-1585549622185_1585549678722_0.3408803430746905","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-78da5e2-1585560770677":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-78da5e2-1585560770677","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-78da5e2-1585560770677","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b376352bcbcc1316ca6249e0e6c961390a30f66c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-78da5e2-1585560770677.tgz","fileCount":8,"integrity":"sha512-TOdVLS4SAyj9CI0pJJI7B7xU29clS/mGuHaMiQMQEVSqwe9XkSyPz8iHWVYF8IIv90giJ8wl+3JK51Ri5FX47g==","signatures":[{"sig":"MEUCIFGR+32w7sYS1NYTfL4t4zLjsZglZDO7rmgxHHeqbwu/AiEA6WNmiQkwfIxP6vCfqgfCiR1HI2cHQwc4lm1K8YRFioE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegb0DCRA9TVsSAnZWagAAIJwQAIxi5sJFcmklB+QdHLRn\naPJWaChtBwEc6RqPN9aYUDYbDOaI4lNJClN35SaRhpPrrkpB3zQ4kmGJLIOE\nV8amBsZmmBZxW7ssnhDMgmb+L7mDu4zv3f5PH2fXIb9zQ+WfqttvWTPR8Wcf\n+cyFZ8bUBSNae7wrzcQZy2QZlSRMmQAE31pBvOM331fdwxcC+ijvlx0oxGtx\nor+BN2AJkwUbEi/fcI1UsiRaTpi9fF5EJnf5JxqLLOXnmgbREbvSfH5ygxv0\n61+lFDkVLFMDqFzvivqE2zKT88ASojIley6QgR12JVmBhqkqe67+a0Yysq1C\nTFq8OKsi0kwq1YHajorjQyu52zv55RduCrqfphs/aAZuQBb+hhQmYSArrLZq\nCI4Kfl2RbCD8tMFHCg4oS/kMXXQQVTJnCcfRhOvdBMPy2EcZcWiNG88jJNrd\nzNvYNMqlA36H73/dU9ZpbbOSXXBfgO0cw0kqOz9natXpC94rpppCXvGBm4Kw\nZ2j7Tcq0RxsNTbMa7v+h37XrCNWoas/2CgwDvJ6sRiFDY+J2DR1mTx/b60R3\nhgD+0joGZRnIaTF7v+somonfs3UcYTWiK3CWfDlYTdi6NqMUe+1rw3yu2zq6\n3MMY1ImE7AX3WYh8q0/M6Xb9GEdSPNhvPoaknVAd6don0QCEkXk4S50uUkNI\nCHGV\r\n=+bsv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0b2f16040581edb5c76957f103005719de690c14","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-78da5e2-1585560770677_1585560834771_0.6925147033766215","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-8d68c0a-1585565474369":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-8d68c0a-1585565474369","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-8d68c0a-1585565474369","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"04100aa323e7d2368ae84ba8c1efa300d258027b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-8d68c0a-1585565474369.tgz","fileCount":8,"integrity":"sha512-HPn5uuFklb//O9gQd+kT7dqyvVfH3RccDsikhe5xy4ixna6AaWlY16tk7V80auzdFkPRc56vlAwxOhMZmwqgEg==","signatures":[{"sig":"MEUCIQCEt1GKQOd0FA8agK54dwd8YJaP7EvkgRAZOAn8M6tHIQIgIkjVGbCdU8vplHkw7CHER24vKL0OF0bk3jUMI9VTgso=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegc9gCRA9TVsSAnZWagAAm90P/0sb76Ey0yKiD+fzosa4\nx9afMthPDZwor1X/ciFh+57f4zottgZSldPuoXVLTMhr4t/WCAqBre7zYj3S\nHXUnOQ5VC41tr20n6CxJHONDWF9+l173bizJ+DdcKO12rcNN5gSj+YGZ4BGQ\nIiwBFlj8CBlHf27uRjfDpOFTmU9/AxOGWDlT+97NQQbbPdl9ROzbeq7diHN8\nR3hWx4cb6db/z69x23oKeJyRio4dZLCKw9mRjrW7VcoRqLBvIsRV5QWqCmSU\nBWLgWYWd9OfHW+ExeFHhbG4oYSUlVhrbOHt33vPDBat0NqIykbWHJqbalICT\nWAnb3D+SDW+nzD7zLDKvma83uFJAQ6Jy+X4YR1K3QnoS79L/ysLUGsS/Yw69\n80Gjn8bNBHiULGrBOzIwidhKuUTYS+4SZJRnDZLymM4yjrv6p8zvAgNkixOb\nwAHOqJTk2lXu87c/w+INyUsWotxyUVJ96//xYoswBNoeq8pCIT4/g77bo9LJ\ntjrPaDTqIsE9nTE3z/0aa54mbuMWQXlgkhWfmupMQBN0bkPHm/I9rvD0RC6t\nYjUG7xJk1gHKYdg4Hfmgnd4KPvZ3L3nvN2obTjQS/jqslaWCXnKMexEui2ld\nH6JoG4olPIvG0nIScHbgk+3Whu3cV6Ky/PVyVwC5kll3kSiPZ0Unn001JxH8\nIto+\r\n=kolm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"746b9b08757fe13ff2892c9e261c70efde75b6c1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-8d68c0a-1585565474369_1585565535534_0.08558441025785024","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-16cbc82-1585597646849":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-16cbc82-1585597646849","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-16cbc82-1585597646849","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b3a2f2750df065c291bf30ac3d9786decb71c4ab","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-16cbc82-1585597646849.tgz","fileCount":8,"integrity":"sha512-on66B7uQXDeo6K8nASwh4n3zUUxUwsjD8r4P0XI6hEOjB6eIh9BQzJsAX7Cl/KArb/U+faipOd5jBUd5jazEyA==","signatures":[{"sig":"MEUCIQDaQ7NfZZaR2FNrHf3xGd3A8FP+INa3ZD19hSKFYra4qgIgS8IKlKNdTguiC3wYq3A2KwvZLOVbLYCsJmi+Z9+ldW0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegk0HCRA9TVsSAnZWagAAcs4QAICxqEr9zlilTfArCI+V\nXajtOGduCfoucNsn/exWIjXVm04QqYNEzZZ1SCFztSO1XdobZz/W3uOhVIH7\n7KxQ7g0kQieviO3dbNfjv7GY9tkuXxv0XiIjenZwz48OhKXEwZ17+HUXoO5h\n4Mrfnmnw/aqGvrmRXsmed6UIbEBGhQNQ0kOLc1RMCFwQINHXYIhs8/222aN3\nZ67rloqL2m0/CK0m9UsNy1133NZ7EFuOd2Eo0X7lbPnyZNCqgYTpyZ6ZQe0v\npRlM+etkYoJ4ah9+pX/D0sLrgazEQL5wNmKfn9pe/d+MWeOxfjFGsF6vlQnx\nwY8twvJj8CwapW2JRv2QQN+WOLcUrqJ3Xandirmk30EH11FBFru6lCHGJIDt\nOpBDko3aRFoAECTbb+6HFRF1Vzz49B1/lpAcIUeDZpq2/R8SJRy+b82yX4ZA\nUlcP7dfzjazpE4KbLG2uwwtzDwNGc9AtfoQVi7XiB6e29Mhz1iNSQ/LN1gSf\nPcnAWfhbmlVK+WiXNoZA8NyMDR27WFHVz4olDvw0W+vNAj/o5ol7npo51hFx\nNZGYsb+HKtyPLTyYguQYV4JYUueYha14svMMVc2pItxoK9FheINnb9UYiwl5\nn4/3dIqD7JlWoB13+RsdCBla9q6oIbDZyHLjNbwQXJWOnw331GE7kpC9Bf8A\nIj0o\r\n=7YUd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"25aff37eb11cea78bb1f467ca2dc5e4fa6dc0eb3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-16cbc82-1585597646849_1585597703065_0.747610019851932","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-233cdfc-1585687816372":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-233cdfc-1585687816372","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-233cdfc-1585687816372","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7b8cc6f12faab4e9f41fa0af5d1fb23292812b75","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-233cdfc-1585687816372.tgz","fileCount":8,"integrity":"sha512-6ynGMD622viyHm1i/C+bRUWguM+eWxlBEBYqE82//YN9iAr4Wko4Zr//oU6UwVeR6A6tg15jWJTxuj1ySO+b9Q==","signatures":[{"sig":"MEYCIQCXFAykOCNhWKsbXja5T+HAOeJeEUCrR7tHuztgtNnZpwIhAMBkNJ58mZWJeDWW3VoS23SBktlZJ/uFh4yvXj+JzxeR","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeg61ACRA9TVsSAnZWagAAt7AQAKSUsoYPwgDA2P6kcH4p\nRFR2YPC88Y+YoHE1eSWcnp4hZyZ7uSzK3O/Urh1JjPwcY8++ILFNhxjj9cNO\neQv21FKOUjkjVOkAgiOQpOACi/Z1BsTuhurLw83oYhFJxoLlvIuq0sZZL0vg\nuhyBDipR2fJCHb78ZfpwlZbPnldDGJQHiiLAOM/EmSJLqOMhVMSkktty11oi\ncYi9nzz7F0keYUFI/AZsOIlU+zj05vTYj+XMPCwrzpfrDThBTGNisMzF0jcn\nzvXYWMb0J/fND2e/xBAStMpnFXsi3riLfyIpgPf0cF67pwC7UW7uYjtOUXKI\noXP5n5T2OvvHQ22Pf3sNuoXzEBwFzgfij7yPHxG9+esbYLPrO8FljgSEkDRz\nLf5+mX/m5le+27uRgQKtvFf1WgvxgzVMlb4wZuYiaHvxagLhNjpmr9tNbePu\noWmEJaxA+N5g582udPRnpmIdRPqTEuu0TCuCxi3Ee1KdPhokiZ6CuEQw6ppI\nfW2Z8iUpegTUttKYwfYrQVadJs2eVQb2NFWsvV0V1RTC/KZh8pc9vZpWk64E\nQSPMd+pcwYVNfdnkBEBuU5K33AgvyfzKk5xtDJPLrlKLSJ1yi+PI9BYVKgWw\n84LHlHJ0jt9C+9g5WKbg+m4argl8bvhaPzQk0L/nul3FMgRWAFfnejlRGRYC\nVdLe\r\n=4dob\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f7538deb12aeba6c3b02b91a27b42d9c90021de1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-233cdfc-1585687816372_1585687871567_0.0687684601668892","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-dc20aec-1585824246940":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-dc20aec-1585824246940","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-dc20aec-1585824246940","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9534cabeb1399d1a181906f512f24d59511c8c27","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-dc20aec-1585824246940.tgz","fileCount":8,"integrity":"sha512-AnrN3I7eEFmFW8Ut/837/5xvjiyCB6lzkIeegG7iPTMLtQrqW5GSGR06ahdHzbKtK9heg1t1+aOrokHtfLcufQ==","signatures":[{"sig":"MEQCIAVMILIQiaY/JNltCWvoyChF7dAJ57nqmzBqf0/hYJNIAiAD/tKbROENY8VB5zL7vEqQRUCFzgnqfCRZ5ifZbZv1Ig==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehcI3CRA9TVsSAnZWagAAxJUQAInm8HLDNSBFoneZf7T4\nSA/hORxBE2zWIIcP8v1KvCXmwJHdzY+X1JwAh1N59rdCD2V7uRiD1rKN8fPM\nifZhTQiWEKB0/aKzP2iZbjObB3JytpLbHsP8ZmVky85CvAU9P655jvjRXbvb\nxPX59vtwhY5i2CJoRTxBp1tVlHxe1E2cd0A6ACIHbivVlqqpO4QGMh6Hv5jA\ntBLOXQXElq7CPr2w71un47kOhpISZuv4uXW5FcyLvRGSW5S1bXxgkooAGT0S\nR1JX6mtVZyUwIEVVOxTyhSbszFRMptsuWdqxrZQtrYUEljoMrCV165WFKQJK\nhF85pes/5sjpLUm6337XSOHz6Kpy+H5+QOBoEKXITR3YE6ewTEvFV2q1UOvS\nK2oY73erIUdbjnEGusQzD0If4DWsdCHVwkt5OR1oC2wR7A22UTxPyQSRS6O0\neDzMUzy1TdfZaennO+tW2PXrYPfFIrNKph0wCAmFVakyAp/L41Q40mk+w0XB\niDs5zEoIw9EMK1wyH7I4OnqOz2OvASRrpwUsN5a8hmsGD0Npm1N61bbEeqi2\n9R4wp9H/pCNinbH2uEC5fxmXhAH9px/wN99BsidTZ5dOemeWer5M4NyBnNqk\nGaFfEolxHgljQV1dMfamW47Qdl91CvB6Xs2o0CRRZB5bSEi+O5+6fB6Bz4q4\nBtSL\r\n=JR+K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"36b10c16efb20b9205577d3856c6e6d34808168c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.4","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-dc20aec-1585824246940_1585824311270_0.8821857260346357","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-494caea-1585824454592":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-494caea-1585824454592","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-494caea-1585824454592","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a8127cb6b9333deae36853d39c2d0cab1d27511b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-494caea-1585824454592.tgz","fileCount":8,"integrity":"sha512-sbKh+f0KOOSDTtCK9GIEuwmMTv8rqDzKBT/0gns5EI01lkpFZqmV47tjujM0yG0lxyvF7MX4Wz7hM9Z/36+SNA==","signatures":[{"sig":"MEQCIHAZSOsm5/EYC7ywywLl2fXfXJtQl83OFbH0j86mo3s/AiANrTk64eBiDpb+LK8X5CxWDj7GJnXX7BZGWB6mCKF7eA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehcMDCRA9TVsSAnZWagAAhG8P/27bFwTCJaNt0PVA42Tj\ngLiZ7cd++6WwaDxyXR5b/ahD+0xu5MI2ku0Ej3IEhdzsz37QqyRnTYZ/NKjZ\ni3EjmmWShgwj3O4hOF2K3QimbMDle1oy4qYxqQBk5crTDjNfQJk4uUWjhyNH\nzu6H9JCS5DrKuhzqAOcOvxBOJb2uQUA2gBOO+ur6oKB13Xl1Pg9U3usWq6cQ\n4pZS4suZVuKI1b3ASXu3xx4L3fhoKpNMNHCQXyolhIe9o3G8jkxY0kYo3m79\nwEq7gM1Nx2q/7387fWwthr1XnmE4gARpqR4bzjdAZ333Sx1cd83eYDbCa1Fe\ngpMCBmT+T3VS8ltCiceiNTPMMv1OYy0+q4cp9F2s+HhsRlwbLrKkv3cTMC7u\nvgJnIrwgZErItPXMS1D/F6MLFY3wlIC/8O8xP/Wl+1LhwgPo4RlBr0hCxdpM\nZgzFRrtjC3eeDHWjvEST7C6UcU2sN61zC1eo+lmcRR5WtjlhkE7YpVZ3l52V\nACCLbGZkLatOxDu0FtadkaWK3LvcYQxdZt2VzIxi98W0XV+gNAhTFW8hI0w7\nZfA0rZhgiwSsc7aGLAf8vnrZQznK8Y2q5asHJ1xERnpd/XYmjRxWYd9X2x3K\novCJDZClxZPu2vzpbvJrnmJ+BPWgjk4l4GszhVAmwbbznWuMBrC1IhyudeXH\no61P\r\n=Nk/i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5a0e4e1c233ff2047c703d7a204c92de8a938fd8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.6","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-494caea-1585824454592_1585824514585_0.3017496402099822","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-6ad0f06-1585847004845":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-6ad0f06-1585847004845","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-6ad0f06-1585847004845","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8c24908508c909044eb5f3beeb882ae236277a98","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-6ad0f06-1585847004845.tgz","fileCount":8,"integrity":"sha512-APgdOgh6GOeNv6PvSpHKeH3Cj3qRhDd2n1RlaKWl2R9fXoE+HMSzDc6m7s2mR21Q3lFzZbErEscofVmBPy6aTw==","signatures":[{"sig":"MEUCIEL36gH3mnAyp0hzeXZVMSsqiKln9uvoq36jephMcaQtAiEA8Ncu5OEzt74rQyjuvkxBXp+lu2nL7K1d6QisguCXqgg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehhsfCRA9TVsSAnZWagAATyEP/3RAmfCMG521FlIh2ZVU\nbg7HG2rMKS2cgKWTfqiaCvtzqGasZEWLhP4f9LM4yuqXHgx/PG11XtaN4wYy\nO+CGlVxIqFPHmtXpnbuUlfcRuUH4DLrfVAx4ZOLzztZ6LFEsHW9jW0ot8Vvn\nZcmVb9TEqr+aBIlDVCKKgoSDMhJhDZuw1BesPWKk55de7JmhseDLCYHEMbxB\neEyO4INrlS4d6k7DzyADjOSsaZAuSSQIGiDNZYMDF0XmjvmlITeXO6cB+6X5\niwWyy0Ma6buAZg0gsxb6imtpFZkmdj9axwBRjk27v2A6l4SCcg39DlYdVx6i\no/Cyh2J4sFS14YqqGiH6sZkIR58l3CXPwvRFKJpSq2oPP8vi74MkG+SCWUhs\n2L1wjoRG9V05MlSyhEzWWRZmk1nzXUVnNJXfjrBmJNFHYzJI4Cqs8gg4AhTW\nsX+TkVcU+p+lnKHsQ51447J0j/GvSY9ogg/ZzHkYre56W+1MOwtu1lFGuiDH\no3jQorHGfA7KolhLjIyflsNn1C0YQIIwNVio2uPllZisc31ZqSgwHNmm9XwA\nB42Hh9D4ncAarjUpRczJhE9etUXXBVzIR1PDudzE/8fnaIOJO5jKOq8P7swD\nQMS7lUPB3rP6ABkcRjWKD+mKO0zhPG/FpEQmd/Mm431gUNKepIaohg7MOfva\nHMun\r\n=VVhp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"62e7902d8635411fd4225095d4eae98a569758a6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.6","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-6ad0f06-1585847004845_1585847070833_0.05589097303457913","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-00da276-1585903938133":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-00da276-1585903938133","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-00da276-1585903938133","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e7762f042d9f80f8c09eff89fb2f093ddb8bf40e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-00da276-1585903938133.tgz","fileCount":8,"integrity":"sha512-HiD20ocEeBZKBmg93/8cy1jSIhAuDefgOZ3tEeCkKTfcpWx+rDccHhrnQy66+bAptulXN0qdIEou8+vH2wqiww==","signatures":[{"sig":"MEQCIDr88QpRM4v5N5CStl30MUIGy56hiE3UJ8nrYbPGDuvJAiBT1woaui/Vab9sX4wSLkB5DtE9NA4NhQmM4Zf4EDPbRg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehvl+CRA9TVsSAnZWagAA4GkP/Ag/45TjHYzoNIDLDIXP\nNv7YAGDbEveI1yekYXxj9hjyNb0PCivC8SL1qi1G+RH8YOER9w2ZTnV5l2z3\nCYw1Ryfgx0zDNAQUYY0/+YOIOGqmWHXTqBqopPiGz9Dd6gtqutUCJbrMxPb8\nkck7xK1VDcN1zN41poFeBMYeJEqUWnR7AUf5GOCIXC+oBeg2wbiYIpAnf1LX\nHFgqH4WcUafi2gbEsbAla83r25jQ/mfjH7oowUdZQg8CKSMPt/osGbnnFRLP\niP6QJunADVVoATU7xAO1q0L/3kxbfumeKJcENeWLUB82c/YnCQDFommNaAK9\nf0gu6Yb5V4bRATLoEAnxx3PZtR1wOs3KYkOGjFNABxgr2XoqhMTeUTYTUF8d\n2v7Soi/T5NHd9bz/Nt259Ue1GP3ez1NGG/VYooCiognbfzNNTNH1UDbnOFdO\nyREZdSMu3UDpyJTvIo6vCP5sVq/rpPPOMEo35Su7ensD62BfUZXr6Yvjb5dU\nIP2uXDAoqIgXm/XAm+ERWke5+foA3Ugl5oJ+g/Jh6TbUMglIrtvAJd6AeRoN\ntDxRdcCd3r3vmxzzoyj6rXZ5pFgNgL3SWU4X+WINURQkELG8z7c6T2Fb5z7f\nzeZphpa58RQ6gy6T/L9UbW2m/mZgblO58DAEpiP/0pwcSOSmJ3w1WG9jnJqk\n41N6\r\n=IrN/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5dec80f4884873b38968c3fd5314a768d8109c27","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-00da276-1585903938133_1585903997415_0.07463052894883226","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-07c03e8-1585926926584":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-07c03e8-1585926926584","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-07c03e8-1585926926584","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c6c6325e4c17080b585e7fdfce853f87d9332b3f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-07c03e8-1585926926584.tgz","fileCount":8,"integrity":"sha512-0KgwjZOjIUdbMun+WdycykAX6yF+dkiOEeI0n4qkdl9leouYuzSuHZeQOlUZjDvkN6IRB1oJ2z9nJaqwqcd0iw==","signatures":[{"sig":"MEUCIH9wmdJs9ey/hNe/iFz2rKvu1C+Ka8RnlLC1f992EZo8AiEA8Z5889hablF5plJZCqZXb12WA9uvjwPT3jiekNkF5rI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh1NJCRA9TVsSAnZWagAA3c4QAKFRvj+0jNtQjG3lovBy\nkZxQMrdeKaP1lJARieMS6pBW/haNyUNvBhofMjnrnx7mELjwnrP/s+L05D1q\nfJaQmYQV1LlqGasSB6zBVVOG/hUmD7unBAPFdhsh9V/EJZ3BRU9eAEMn1g8K\nvwzUe3hZbYOAJS6jNwDRLIHUiYaeqHRVBVMZv2MM+Ityv+29i9yjGhKTCXxa\naEQ7jo7RWjiH+pspbBZIKgisoclGol8iqgsmWent4e9U27boL/9VahR1VO0Q\nnWqau53qtUkuv7b+rpp+u7H13J1qcECjVpnC4E5/UE/lM61wVZtPtb6+s4zm\n3A2OnuqC9iqE5FAGtpeSHAKzn62SGsRakIjDFBH2cu8a9uAOt59eDPlRiP96\nQQ9ii2pKS1nQScT5lDlDAwSjTIVD5w7y5yFCUrFmIvaVMNamCbfkowWWD/Gq\nOPL0CkUrKbCdgZiZ/7X7WaYL60jXAzZGpOzS/ztLUOEEbZBRcCy0dDrETwfk\njHTianBUhhD5UyhuIP2EAYPWV/2i96Y98hd8zkNewlg9eqGtRoTfZt3AGpxq\ncoU7VcHauGuYAUTpmlI22MnmZXGo+9XJ3LBtekdXn2UQpJTqBiJ3WHA61f5U\nn5/8JtcsMRZODcZmOL8k94hJ3qgg11z4hspjmeVmqLJCANZ/WUuzDn8g+86y\nowl4\r\n=T+aq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"21e18407fbce1274bfadf21ed6fd33a84f0cbbae","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-07c03e8-1585926926584_1585926985214_0.9289064266649689","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-2e3cd2c-1585947765082":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-2e3cd2c-1585947765082","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-2e3cd2c-1585947765082","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d7481ea4733391e0b864cf52c13e2e9e0421de11","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-2e3cd2c-1585947765082.tgz","fileCount":8,"integrity":"sha512-R5qY/ZtRj9EimZSpNeA7VT3OlSmJ17duZElpXC/MHV9vQHhbMLuuPD/dlTZVyMTvVvz8PkThwernBtg+OEebaw==","signatures":[{"sig":"MEQCIHBV4BnBYdRqjaerZ1KxYv2t03AbPwWU98Yl7Fxzyz5NAiAQQDg2ypxIwzkC9+SAGlP312Bgmm0xAhmrlHL08k99cA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh6S2CRA9TVsSAnZWagAAGY8QAIhjzrI5qfw97pXd1rna\n6Y5zY+rwTe1aApZr3v9ntBYJhpbPZ271kBdb/tc71hojVcFRpmLJcSy3s518\n6X4H+HGd8x+Yx1taHu8uBsXmtJiI7bciD0HeicmcEAB8QtmELmbhuspd5LAd\nX3oy+mWhSE3QXdA22Iw+L8g9Ednv3W1UhAYxEI5LcwYwgrtRu2FgLab2vf0P\nbR/v1lB4E8sEZ7P8Jv7Sg6FK3i6Vst6LZoSxaFzeEEyoegDwSedX4VqbBB90\n16/hMW9gl4BjnSDXwFvktYvpD0pudVRU4Zi1UpRL2XC646A+8Bt2f8V/bq+Z\nlr5cPa1q4vCNE7H/SdjKPKrCqJtopL/Gstn6wAXJoNOHTNbhgnwSwmAA37hi\n9NF4d7kWT/Fo52Svz8Eq26lxVmKKO7jo+G81mMQr1u0/WMthjJQ2k8uWzzfV\ndmx6KRP99R1aRxvt7xHWmwVAmr/j+ehbCEpB8QLznvywjjHW5UPfju5F83iG\nGwTvwbCY5FqH0uXCcsACsyRBfQhgn3MOO3XW9Rz4NVK/l8YCEqTRA+mwafoV\nC4iO4yq/nhz4NMR/I+VHuQojL/w/qoFBa0u5RiOUuNB34icIKosELUChwmDF\noMnkOJFj0/rfcBGcgBuAY4fHQC0OYmUonKVmvhSO/57fvTfrJd8U4CYZgyFB\nMzJ6\r\n=Jhai\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3c83aa338f4d42b096186360ee1c7620513437da","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-2e3cd2c-1585947765082_1585947829969_0.7220577563296406","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a46d0e4-1585949290385":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a46d0e4-1585949290385","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a46d0e4-1585949290385","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"09476d8a65d686fb6f302d0082742d34b4324131","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a46d0e4-1585949290385.tgz","fileCount":8,"integrity":"sha512-uWKFNIZ0RyFujEN0tp3JqKwYMA1Hh2h5Z9iAJOCTluYXTw2iJexvDdCURMw59CW8/1WsrUKeGldrX9J0ivuY/Q==","signatures":[{"sig":"MEYCIQC3s/GcDhtt1XyWs1h3m7JltHhZEnr7Wy+SzGcisifJ1QIhAKoPb9ATxooiotEUWxCpWvODb8Uq2zpWPekaGW54jwwQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeh6qkCRA9TVsSAnZWagAA1EkP/247J4SMtjg8cqIR6beA\nQ6m9LH7qaqaenSL3KEbJKmwU8HBHswvC1ow1D/ZfzVQCfjbmY6Lj5f/2N0HD\nFvMeAlx/CT7U42q9n/7FYTY1wkNVh7f2DLSQERfhQ00zJwBNZyiOECnWPw1Q\ncmE9IeWVBJRvCJzQVcmAyQn0bvtjXIBUMUAsKpvJF8WVRFxcHgAWdxAuLLJ/\n9zLyMDY3RsRdZFA7ZZzTLhFxO6ih1YkIBeEuofVL2OMjY2rBDQ/fm2REhGSI\neUlH4l24Shc7eafQPPc4eU1SlueyYNlwNNTKWfZXjuni/Jcd7ANJKGUJno+P\nc9j1XLU4DAkPMQio499Atc7bBrSD2ukfPJTqUK2CQZb0nS1GHp29MsVzyQB2\nSyVNuFqtJc+l+UeO9uQt/JtfmLkIYNpf2ZitaSBi6KNXVmVgjuy3wXq+6UrA\nZQBprYsBx15u7XMJuZIjx+FV3ZRSIFTshaEA6g7Wc4z0TTHjlU/HIQiKWtLK\nO5G8euVj4FiyGCAzi8iG9z/U+BEex5KzvOvYbXDfqhLHmw0SFibYe48k+Ttq\n6YcYiwsy7WCgbVO9aONy9e4Tosittiw1WxydQsqsPQUx9bMUeEYYhxGzay+9\nZ6RlKB7uUUuGwL0riWX5A4wtI6R2fxf1djfeL0vKy2FyW7KJF7azccMztEkV\n9+To\r\n=VF+n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e3d39e5131018c54963b1cf181d006c52c40252f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.2","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.1","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a46d0e4-1585949290385_1585949348343_0.13919032745647653","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-59298c4-1586040691809":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-59298c4-1586040691809","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-59298c4-1586040691809","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"667b2d4fc447344944e21e0fd445915f4e0498cc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-59298c4-1586040691809.tgz","fileCount":8,"integrity":"sha512-StmqwsxdNLbyh/cP32ANG2k/HJUtivhu2CLKoxcePE4kWWoPdKm/V1yDVz6fWXx/JmZ/nkqOkSUm6buHHUtqqg==","signatures":[{"sig":"MEQCIHq0XYIvOvMW2Zrt2LvoQlcvADW8BugiLPYSKATw3v69AiA4Y+rgGMoOc57yth0J9LJvTfociIEH/5HT0DfxisBIww==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiQ+tCRA9TVsSAnZWagAA/hkP/R8IpeLlliWJ6CQhGNIh\nPAhqD6U1yRYS1r9zNYrFfIymzLXeTG3/dg5Jro3tB9N4HtP8njw2cg3Zbwyf\nSAz7uwEtDixH8F2NGXDj5UD2MfijGkE9/DLL8v/SzGDZFiuEmSa93QsPFKiV\ngNBb6axmU0WChnbNWhkVJyW1bXFq4YdF6Mu9hUlye4ngIX3uhkffH5nuRwLG\nqlUu1ZfrUSOuvfE1SsEtAZ0gkrappCXrEMh/XIcbo93mY20q0SbvEeIsTB4n\n7JyrWYRcQRnljb23QL1jFx+sahBVbndqb1LQ7yvG0qqqwJqZSS4FqpwODKbA\njCkOPZbbuqKAQdoHJYf4wAvNvXdE1lWnr0Nbs7gMB368oMfarrTk39rxMHNX\n9O5Fb6MJS1vCmRtUXlgfPgCUEo7GDphXTbBxV2Lbw2HT4TogtTyDTRF5Cluy\neMeZ/C/FoVNKahpkNjguiP2zr0r4z99cLaGbsShjsAzFAPr3Kai+c5xauZl3\nI2QiqPJi3mUodTIdhwB8aBeK5UkBMe5R/AxxzpAvc0+0kkGkovzbpqAemUVn\n+E0DlC+Z7vdl9tp6fplYYJ6QsruA0Dnl9p+VA9QTRkSMaVFoBK38DpC2ebG8\nRt8Kj/LIJ3xYzsPxMJmIF94Qv63a8o1agoOLxfyJQY3AcnpeZE39zupYkfN+\nPZJZ\r\n=Ybc5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8d796f9ca658068d76181f4fe2d498d0acc0c621","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.3","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.1","@babel/preset-env":"^7.9.0","rollup-plugin-terser":"^5.3.0","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-59298c4-1586040691809_1586040748902_0.7077655040448507","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-2e5733f-1586141282355":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-2e5733f-1586141282355","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-2e5733f-1586141282355","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6e41ef4d9f0ae8f8cb405a1f873c64b88df5d372","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-2e5733f-1586141282355.tgz","fileCount":8,"integrity":"sha512-Qn6iFp3Yq8sd98J1mDn3o0ARV9pemkRv5x5R750FyApGLANDbLax9ClSFaInDII2czk60pjSuAZaeYsbWxxSCg==","signatures":[{"sig":"MEYCIQDUiJMLYHOI4EeSP12EeC9b8oi6ltApRmnc/li9rzDSfgIhAKhHDiK94DjZ4qVnV+jJkrQZS4+IzZuUbImhZIiqjONP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeipljCRA9TVsSAnZWagAALZ4P/i8PeHUnQVBP5Bc5dK2r\nu8wox23qHmDdHsh0B4uHpcjoIvTZRDLgmlF0oDVNYFEKwhYSwYBM3MxGP1De\nCsWQvab6UADej0KTv2L4VxghzSZGl9AE5xhcw5EaQdhYZU7nPKdTqQB8Inui\nuaFaaAcXW+XQMmF58uYOG0kzmj6XgRAygkMNTHgixIglzhtBSsTWtsQdwJiV\n7fKKeqQ6+OV9m0QVHGvSN/niuIBD4U6PCsw/Mjshd6eyHHuJF62FIsg0ohPe\nlcVLkVFM2J4zJQ/Wu1Ko62JoFxtt6NRydSOL1D26FokF9BqBDvzFPK9rDJhd\ns7IwUPslhtdz7/7VMEedFMrdaZ18XRQ8mCgX8vasJsBBI8zvgAAvpuUOX74A\nuExX3acykHP+AvS9Df1koL//HStqiHUEy1DaoY1YMmQDPxgEcqlo0cd2cpvr\nYEegWxauD8aiKKi+sHtD7Fdh1eHPFYGyylaezbnKtg10F80Dp5MDoD7YEHDj\nzmBMyzMBV37XTyIpms4DrLb/BcfIPSMQAIYZLCFYIOJZwHubxVU2fftG+3/0\nK8DKHq/8H1TrhVfSRw8I+VQhjTTrDlz3nv2QUL1H41BbsXSpEa1QR4sLclIy\noOqKB9Oms2uuHT0JzIyW39HjRFP+GOiMVrTXxHlxnqcVPT0lWNRXksmbVMxx\n8hJG\r\n=Vzh2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"417e8645b168dac9f4af1f92b4302811c9c4c769","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.3","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-2e5733f-1586141282355_1586141539122_0.8890475768519406","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-aeff84a-1586289027384":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-aeff84a-1586289027384","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-aeff84a-1586289027384","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2d82ffb21bf62d9bfa834d025dda055bbf82d1bc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-aeff84a-1586289027384.tgz","fileCount":8,"integrity":"sha512-G5g244SBb1UYfN4yXGo7gFvuLbEzKlFP7IXse5VjRD9XYHr0aqnWcEUdIHRWeTdkJYASq29ZQTiEEPiMOsqeTQ==","signatures":[{"sig":"MEUCIGbJNnsDC95LkZu4k/a7Jm5YsT/2fICVnn8PD1TUO6SVAiEAuBMXkZbxH3I6hnoKbEUSy80O/G4MlYZiqyS8WLUOsW8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejNm7CRA9TVsSAnZWagAAX2IQAI7kO6iow49VwX75SLRE\n9OWSpBuqkAn8bOyhLxyLH9wQ8RJYGXpDqH6UMQ6UXuMxyzKetAl0IqAD5xXe\nct0B3abOExF+9OFyozl8G9VAfMtyOkF9bd4LGqm/4C+PzZKqcACCa1eXmO5h\n/v38VTR1gM/2Yto3YTocdF6bEjSKTWLt/u/k43v+tAFC81cTeLOA8ujrOnjq\n6C7GU+JKXLfJ4mlGbZpvvid+RkcdenUrygq95CshY4K7ZzWye9gy6ZN489ov\ntxubilkNS46b6FKN7jvuwbEJ/aFPwcRla98lJtchkesVxui3q3TA4mNWg4Bp\nbtQcLygzR0mZC+4Zlv9jpGlZf6uqxeQqtuFI21CjfTA2GttLCgk5oa3c3uOU\nnaQSyY2l83u3Tmz/cPWe1JHDp6szC8onHsl2HoGr9/UfUSVYW99TJT+fdabW\nZnekowsXKfmSRX3MLuQkiOAxqjvD5ynQKNLsG7AXHgDhkXFn4gPiRRojj2BV\nVA3NSJf+jKHxjWeSiM7zlNrWBUrsfOo5nwTNNyM6HxX6Qbfn5KvQKPPmSIMD\nMDP9cS6NYjqpeIShHw+CUrWRS4ee4FrZFmLNg5XKgkeBM0wzczfMkZt7G2zt\n5RRmoAbCuu0MW8p5a3bVhlWBhZ4dJ+ZvZoSqPcpxd1s6wIArHdl4KlGbYE79\nalFh\r\n=D+jl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0d00e8e9a92d2d50e629f6ed946b939dd25d5166","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.3","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-aeff84a-1586289027384_1586289083154_0.5634127398001014","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-f03835f-1586293426880":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-f03835f-1586293426880","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-f03835f-1586293426880","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5dc33e6cf4c2e019a9a32e231dafe80a56bde808","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-f03835f-1586293426880.tgz","fileCount":8,"integrity":"sha512-46pXsPF1hkXb7f+evlVnRQf6bd/EBYq21mijOGSne+GM2uA/H57VpA2cN47sxQCdpeqsNxqyQyO5vjjM7Jl8Fw==","signatures":[{"sig":"MEQCIEr7TtoGaHWMyuAigU2pTGV9STLgh30NrcxZmyRZNk22AiBMv/bjkYLzh9ujBh4LF0p8Dwp6nibKyq6eOcD3mlwaZA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejOsKCRA9TVsSAnZWagAACaYP/2+lFhv4aouBEzBXF3tJ\nCdpXLIdmyjTVD6oYjeD0TXU3ZsBhGfq25Xkx6k2gW0Z1vJaeNLDtSve1/MVE\nzLuKyTZILjdzBAl/be2PurJyhBRZNrOCAmOw9h1EjbC0OuJEVD8kXJ296Jbl\nW/T+/FZ0p9o4Z4YtfYwEr4iUeGy87jf8Ab+P2GKmaR4bKADB9/WzdUZB4FMg\nDOtbyb2d6wqhWgOgx5+QqjzsCWQfarfbhxykmcMDKkpNYkuEB5hb/sue7tbL\nqyzN07NsT6EKOmEyyz/EN9c9cJfMhoRAggRnR0FZQjpp2beq2pcmLw0hMNiQ\njcTZaO+yEl+yFuUqAdr3Z2qwry6dNlCG+KMJpSp/J/vBLm7HPyXlnKSGktty\nrVaF86f4loIDYNJxuU3sc3nI0MzLOdjdbkphGzT/xcTpvr98dzocGyS5U/Fs\nrkrt0+oR1sYRHdPlYUZCJ+POLYGt/KGR9KBEpahH8VJEXnYVaHmK/ieBliYP\nf1Kx7peOFCzdO/TC0Mh+sNtW++S9JKFlpkDcFMMzgWtZo7IpT9tTxFB3gH5l\nxlltHr2i7uYfWiYPO3Bi0aZl03de7B+RQpDRUcPbZvVqgFvmUPQZ8owlcn3L\nTAPIWRqH/MPJGWu3vgGzRjGgLt0DNpRULNIo0GZJSNB2X49fE708hTRhjJjz\nO+71\r\n=4TYe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"74dbd1dd20c932c18e91a5bed2768408261a94e6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.4","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-f03835f-1586293426880_1586293513754_0.4805220748594272","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-d7db17f-1586352724252":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-d7db17f-1586352724252","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-d7db17f-1586352724252","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b8914d0b137cdde429135f700261423377b86ba9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-d7db17f-1586352724252.tgz","fileCount":8,"integrity":"sha512-BRKoCNBA5IVrnEyfFOWQ9n8ms61yrc67RdLVmu2y/+oQREluUS2sxT5RvHmjFdMVPsAFOHe0Ckv4IbLsPZiEMQ==","signatures":[{"sig":"MEQCICy/xceYJMvhyMxAG7Lpb+oLdH77THuiuk7mik5L9+JNAiBSJPCdFFKsuedOLoeErMNaIvzvApwlhjuAxZayHjFY1g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejdKKCRA9TVsSAnZWagAA0cAP/0zspwAfjSf5aSxCUXjU\nFCSv/m3S58xhntvh/thmZdh1svqQtWgJ0psksFHksY/1W2zRZwn778BECWuY\ngm31jsve6vGGuwxLSmBm09X14Xeactzt8iA19q/2sSiwzzjEB+JNZX48wTVX\n+ZjKEdOiBjhBPu6zocCgpUPGqXP8GieMQP6UVDPiPCeFAYz+i/CRBzbk/72O\nGZMU4o7oMjiAHH8U7t/oETFCOAyTzqGQu1LIelugN3XiCX2KHqURZmZUneat\nKzlX4mugcbFZolactPyvi4l6JKfdMSz8Awx2X7RmwImXWcQCIEkZYLv6m2P1\ngqFwF46vy3TH6TfYTZjj+6//tFyTdO8ZfWRGgTewc4ii9m7fqt+hzK44PPnf\nF33M0Lbc1uV2315Oc/aXl67pTzgXxAgq4wUOVnZVRDlG1syuSgvgbO3i6N1+\nyVfy71JK2pSI+RsoTN6qb1DM4bbXQ89gdR8D2611XTJKT0NN7TpjMYNHFOP5\nxvAUROdqyfxTnagjJK45FrQuU7O3obROJRayDfYax75KxZ64V+o5xUZ8W1H8\nvF9/+2sICuPJvE0wJzriHlZbrjFelw1xnf7K4lRTcjIhjvI9B4Q/E2bpRRt3\n3zpNGBY+2Xi8RU9Ovjs1CAfa3F9fhDDaH20GyxIB4EgdK2SWJPNc39PMaSDp\nerOU\r\n=yeFH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"25e626b70b0a09fb0dcd53b5d780d5518c1c1163","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.2.7","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.4","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-d7db17f-1586352724252_1586352777719_0.26581983730898373","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-1a36d61-1586352745971":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-1a36d61-1586352745971","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-1a36d61-1586352745971","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"49d8bea24c9a507c30e88ac4a482fe99a515563b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-1a36d61-1586352745971.tgz","fileCount":8,"integrity":"sha512-d6r5+zDeHZk2epMqOmYL28eeDZIrxIQwrT/p6T2rJ8YOYedujnEKSDrqLZTzXH9hW9Hznn2Q8lOzJrB9KSwLUQ==","signatures":[{"sig":"MEUCIQDIMi7Vi28oPOXxuiZRIHuj+TQR87kpt/ccxEMCR3NXFwIgCvebmLPVQs+GKKbbXys2WDNHbBUL0qwxxGAQhiBxO6w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejdKmCRA9TVsSAnZWagAARL0P/0Tq0DVLH0v+mMkGhO0L\ncgy0q6Ae2LWVTeOLtLP7CH5SuodJLHdE9NrQoaHlVbfvu3nmuOp2BmkSVtok\n7diilxscG9APpW9/4Jb97FduHwRoeBV3fDJ09a2qdHM4xozUu/tInEhmaYSu\n3b/o4znY6GCqCiSIazJsYJ5vLzZX51v8/Ehldf1ncTWEEvgBp7RYWy/x4xAe\nM7Ap7mRwByThKuivL8z39uVg4Gsao47eSgzS5hSMpaF0VtQkcYhxpLu8h1WX\njJ0uzkczQIFOpTYcsax3EsIOf0zMQLRDMy4ZC4Immg22jV31WSsCczqxz5iZ\nz35PUUMDdzJcZEn84LJyjl9dkfRKdbktb/5gV+Bn/Q8I7Mspif4VEdxuzTUQ\nk+jCU61tkOcf47tUrdNcLw+j8A8OXeG/ivU46jiKAxRw7gQQXXwH5S7pmk6y\ne1r2nqmKqyRExjEC15+HBHjzq9EI+LqQjjA+DdW1t2DNIWYTR3M+/xYDf7n7\nGojdNNS65J1R61alh12U6rTeAmpgKVGzpOsDxzMKrygQzycLj2sN/3iMWJNk\n7Rhbh+YstS5V697lLx2+HfJI16Bgf7eezMA5fj9znZSPbGTVKzNV1PmOANW7\nMsFucCv7+U1d3N7tIiO3y4OdFxB8+AXxouowaontxS1uFKe9wWWBbDi6o1ix\ntAYH\r\n=/3J7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7f8e270661f4ce7bece6520436ac65b2437eb0c6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.13.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.19.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.4","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-1a36d61-1586352745971_1586352806115_0.4429963073075107","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-12acd7f-1586467458366":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-12acd7f-1586467458366","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-12acd7f-1586467458366","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"287276339af5e262e4a64aa7374d5ffd5ebee664","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-12acd7f-1586467458366.tgz","fileCount":8,"integrity":"sha512-Qj6ECDDVh2OBoynsFxiUYHRPhAAvxY3Zuc78mgcD+rjoWmIsPsYCdsqMrqwAW2aDjFcanEJ9uegGsA9Bomm7tg==","signatures":[{"sig":"MEQCIFcHx5I7FgWNAVX6j50yF7Z/iP01LyPxR4W9jOVO1BobAiBYRsJJmxYHNI5HfDaz5UdIGCYb1bNLDItiOq4awxdyxg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJej5K8CRA9TVsSAnZWagAAfHgQAJQW9OVHcWm/beDXF7yQ\nY9B/1C7X3m3oBMoN/ViCg4/GoHdIxm+SUz4e3sSo8RvId3qUFMxcfuA+dlPJ\nTWA8EkvLqTfPuUmUCA6CiQTjNB0JmzEcT9XZCtohv1uVUh97rneO1uDAr8Xa\nbeyJqdNKAgySVKCKzZmmXA7ybvLtedsr+BVFsVOuwlAKYsO5Xo+RRMFXG6p2\na5QblVqc7JAKok3S6IDMpPSvbPBsLwSxgAKGW8twOIraaaWTwAZvkXkSu29F\nT8R1GV6LWDnRX0eB1ZKeue6dh8IqpBx+qUrzN3koPkmurHfJH7tRkemRWLPf\ngugSY7EDgT1pdkHkCa8GA/B5XY/jlI1HR/+qH3wp9o0VQ2GmrnNDlml016Kg\nXMQz/l6L9LNhey5fEAllwWjvwbZzDPOzWd2nZ9kHYaXw9vAHBBeRSc5q9NEQ\nYn7O+yOYHVLROI/J++Bt8QmMPzi95338hIkNWJVRYQRMEmg4PtdU8VhAYxxJ\n9BAjJoEewbef7PsGYBBsQBJut/kAiF5J3tID/WulIjAkVpkUY94mot8s9ZUE\nP5R1sfIim+6+5W8uR2jEmf1gsIM++9Y1zLI1/WRU5QX4g+SAjWnEMSvSbU9h\nZkFYYf/GgzLViZ5T9oHX5B5d0lP1Mg7Q5M3XNzkf43cEoR7mzOMdvQ2o6bZe\nCp5d\r\n=z3Xg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bf32c9060eed0eabd548907423c8f890de143371","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.3.5","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-12acd7f-1586467458366_1586467516146_0.14016277374344477","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-03c8e78-1586468958211":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-03c8e78-1586468958211","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-03c8e78-1586468958211","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2a5550951691a7ce9c265535929aa941ae69a982","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-03c8e78-1586468958211.tgz","fileCount":8,"integrity":"sha512-QPSwo/pL6hiIDguD0H68WOFdzs5XlD0l9/xyWoTI0mNyOmY6hSyxY2rOrF8CgEyAVtzry7IGdbEWEYXEYOgIsg==","signatures":[{"sig":"MEYCIQDtZo5rbMJ0MnRR1GG1gb2MzmSCJ2RnSncPNl1Z9rB/WQIhAPCTpKs6eSIhWoDvkps4+qXDeJ34PxIVwc6UBYj4zFO1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJej5ieCRA9TVsSAnZWagAAO6YQAJRmYuqErCZ7eTVomNSe\nAAVJWADD81ZALSjGqLz60sJC08NBd4UhzoLgk6jV/gzBBDlLML18Itoc2UYR\nKEHmrL+GM3iQyUW+uSknuw7LQQvizkjB2nxatqZ5KHKCZdgcMhZPzPQchVKU\nHr6maK7jY5PrPi/fUJ1u4cvaO0in9IsvhLPRDG3WqeYCLs1bdnQetZWztaio\nHqEjKOpOiaz3aLg7rO82y6NQLtx8UeUCAYLyVWX8FmxXMI5TZKHmkuQfNcj9\nXUS3IZpUgO50z/9RX5ukL9V3l2vUz4lybxKgKYKAH43t0xIces6+AkFxAi5g\nnntEVMJUbUeoZHJG8MJdFZiSZGOqgG+KB948Ki/eb95ne1cQMlvBdMOuHs6S\n3CzV8lW9a/eQwiL31CyOpJLQBSiOl2KZJWnAjW/Xz82waV765paV9HVM+3bj\nVjAmb4HVEZGkJR9Y2Twu7J7QpzCDHvUKTKF3DcM/8KeQFF56aLwMeZSjyFwM\niPIKWhgVCeLIddhd/lv79Y8ofwzJExpoOsNJtiM3qUFauF7g/88G/fLNupSb\n88P/XgrWY/aP94n2g/x2GCTHkrfNpjKS4YaxbMWwI30Gk0zqSya7RaYPccdy\nxbIXXY2x38OJr3G8wZLEPs8DwOF01C7Q4/mEfT9hOWZpsLJAYv+m+cr9p1CQ\nJd4a\r\n=y4+5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3912e6ccdc6dad018e3f4b2a51ef2de7885d88c2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.4.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-03c8e78-1586468958211_1586469022029_0.3262680352602836","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-b9273bf-1586551421684":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-b9273bf-1586551421684","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-b9273bf-1586551421684","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"74505666f147a26d720cac191270dae0b0ef9985","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-b9273bf-1586551421684.tgz","fileCount":8,"integrity":"sha512-BDEuELXxxN12nqyYeRPFwzuy6xqkPb4dMEzMbogWoANV1iiYbUzx9x1o216JtlK6y4/H18VOGMA/3AzU8A7BJQ==","signatures":[{"sig":"MEYCIQCAj2atf5y/GaeQL/gj6Nj/9Qg2vGLkAiTwaM6LBBndKAIhAMf5ZD1+71Nog1yo5jVBLBOkB/e8qesXdDowB/VWV6kO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekNq6CRA9TVsSAnZWagAAkaYQAIIFjB/7Dbm8oi2Mn5h9\n8X0b8Re+Nor4gVHYtnpzgfrXbg1lImtmCmJplQGblpngcGjer5xjNEFAeLlz\nzplVFQki+ayRTMy2d2dLxjBI7wHkUKTn5dDThIuX2drWCj7F8ZuH8FdGzQCo\nOCUGrRHNyioGrPvHFDridmB6nJmmn6c2Ys59sK/qBbQR9nDEcVvDE/XP3yfu\nNxgj6Rc8Sc+vQAfNTdAd0HuWdrHA6qIyi4ppyPmIh/r5v7PW8/Egfz8KCTRz\nL8jHp3+miO/cdAKmI/hQH6hv7/UKtGYtWzvdpD9jFwEpnVV+yOtURbZc6YnE\nVuFrgjf1mebRzOXIak3sg6A0fxBn0Kbt0RkcdjgmO5V5E/bZCTfLU5d3vqoj\nCeQcBZK300KYN+swWr3bFx1GH6vs4M2dzLiVzrJKfYICIpNg4//TD66Vw8Og\nmfGOGxDBRZQNN2OToRAeQ35hozOHnVDsRPeI8oYXXJcwvjoTLXlcn2v6TEEu\nhW4gXzsu9FkwAw+wf6Zfb5AEz9e5D0r+n8kFiAC2KdgSU6KpJ55LUYEIAukj\ntRb3EjsGRk7iszSNsYVNDmfiKheSYhbOQ/bLpSuR5AmGBjZwrKwMNRq1RsUd\n4glleCBrZUQpHjm7d5mKOSO42bZySCz9PJzQOzwoPn5TUBjoklG5ZkBPQKtC\n0fLz\r\n=uvjR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8e6ef0ffb24cca9c34b534e19d979ec302fcaecf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.5.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-b9273bf-1586551421684_1586551482076_0.4229702434836027","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-e76d25f-1586552014658":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-e76d25f-1586552014658","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-e76d25f-1586552014658","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8aaffcf06f81aae666a22face2b08b9ef795962e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-e76d25f-1586552014658.tgz","fileCount":8,"integrity":"sha512-bRbgYY7UMPlDdWtyCyEAD2yWPEZaB/86bwny8od49ki7Dm+1Pr6DV0GSi3c3A260W2V2w0oc1zwFOQpfdtVlMA==","signatures":[{"sig":"MEYCIQC7pSLZX6n3xzbcr3DwNWaLo/gLC7nBww2xJHzdCiM1vgIhALc8kwkaBliews+s9rweDEv5fhxKjTwnVZBRAWMBRchB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekN0QCRA9TVsSAnZWagAANBwQAJoTXgbeeMKFB7Zl+4/u\ngJ3DPuzZ4q2HJYQrKJWOlNsq2yU3kvDj11s8+omfh2SW5jDRfb+dvboyMzQC\nCFyO4/KH8XD6LKiGz2Mpsj62hzHFMvsJSgEsSRXq51VToYj1NFZYDRDYEIZ4\nIaC4HlGe8sbr11DZP/Xw8LqLThen/HlAG8xy0SOgn8Y9sUr3DOG1e9S3cyuk\nmesGpRcf08PH+zZ8sg3bBuktAaFUuIA5id7U/Bn2iHTvSHBKG17lAqz73+l4\n2kK9cf6lXWU54WWV8+ngdcS/yK+cai7P2eXvxPPBBJylZJoDXv/5PblNhk9m\nOIoP732L89lyjQWYnsr+IAkyHN9voAbhD45gHY42IgQ2Meg7tPBTDOPjBtVo\n4AC6KeSDtkB7q/3smdynZsU3ryYL57CzAu1oYcAfSKT/bdvPwUbBbEyn+9wN\nYouneJd3OIPM+g/CkyYc+PlH3bxWmHgqoYOjn0SkKH5sTHVoPRib30egYsjU\neYNR1cD/EYkkZjoiecWO5eo0L0mwzX4K71D+Y6ZXdLp12nh9TPdRBP62J2rI\nefVlg91G8Mm/wAp4Cnxw8jN4fke6tX6euYPcqpNJynFPapT5Nw21rROKhhTy\ns8oNYcSDKVaGaoNeAd/lFKEBZVM1p/fixOLLBfqQsMSoHyopEvC3YKtLOTm+\nIdzi\r\n=YA7F\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3ee6e4a85d28f353b931462e145457b9ad821396","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.3.0","tslib":"^1.11.1","eslint":"^6.8.0","rollup":"^2.6.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-e76d25f-1586552014658_1586552079664_0.41828006493818926","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-b067bac-1586727799253":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-b067bac-1586727799253","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-b067bac-1586727799253","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5582eb099e2ffb01598ec1a9e38106a9511e7aca","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-b067bac-1586727799253.tgz","fileCount":8,"integrity":"sha512-GpzF0xc263vZcKL13khOCVM3SV1xuz0etLZXsuEkv8ibvUHCoDpqPV3Ohs37ZJnY3WZIhe4EvyyhKK+hHBeOZQ==","signatures":[{"sig":"MEQCIGgw9nhQDvg3n2S3S7OwZWwZHCUxSUg5YJn2tzGYCbeOAiBlMgSzJ/1uwLEZOtSooYjP3K5WH62K7bxs8kHeKEX1bQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJek4u6CRA9TVsSAnZWagAAwVQP/iUjEyTfbjPnDQMpLlKm\nNm57dDD0Gp3cHM447uqJGn/bNj0qsFUWBoHpZGYUcaXWB1I9WDE/EYiDlvZ0\ne8JdqRmrxiBYmc8gD8wylSk0BPH9qVipd8FaGUKkX2ise08bXHSrwEioNXpD\n+IqIwfXyZFkD5syFIf2Ks9aTY23gUYld96X22Y+VjxVPR9tMMB2XU5ehVDwp\nXSM506wlsz252I3MmQiL4oTn8GbuPaFZ48L8BbvVx/owTYpDSv2K5RC/fuPD\nursGyI0FNxGJXm6QNt/zQIQYOGpVP8DbMQOzrFYhnuV7ukit8DMTl3WFN9B6\n+tLSUXFCOoeVcoRmm+oi90eWtMYGejuzugQGQ8U+vtXIim2ENVB5jPKHxZOF\nDMnML+W8Gdot0wDkjqDhStPy2zGuWlJ74A0xCg0xBzoZRHBhju4R7MUWr+HY\nJc/+xIiE6r204p8PNdQ4GB+ufwqbFH7IdqbImp8xSjmv/aq/eI4tgi08fse/\nDJ9u3U1eOiR58cfRX7/BdlhAFntnGOd0RiM/6TFPH7hMxjXVL8U2denuQp7N\nNmLcAE6STSLsQzgKTUGsHFgalUuy07XrQzhO5peGKT/ANwhiXPNP5nLq2naE\ncYg3cWsC7psSmlLRfQrjkkr7m8P3CCXXb67Em3gHSqMFanOu6ajJ5S1PG1Fg\nnQZr\r\n=mmZ3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"eb5175055fffa89d6b3fd9e8e2543586f30685f8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-b067bac-1586727799253_1586727865326_0.697559621393621","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-ef529f9-1587112302340":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-ef529f9-1587112302340","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-ef529f9-1587112302340","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a7b53ba3dff8baf24e21f1d301cbba2fcc9ce695","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-ef529f9-1587112302340.tgz","fileCount":8,"integrity":"sha512-b3TJB0JoDPyOn35NKHw8fZIZDO8pf9JeCpTfidZdc6uJg0tDBWrsVzEtkFXNerWEBjYgg0NOyMgPgxEyNoRsKw==","signatures":[{"sig":"MEUCIEBVJ1+MgxeeOuZMiD7t+9BhCfUtsTkYYOwcUPjySVmHAiEA+Baknn1tpOkZ0W17vsPM+4kUh4tlqgVo0g4UYWSjdOQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJemWmtCRA9TVsSAnZWagAAyloQAIKkJlcsNjhBzP6SXI3K\nmJVIlYd5ndlHDiDQHYIb4aibQ27C6wNnTbNbGOnZ1olfU/6ODOpD8Eh1l7qL\n6U0kacaPk1GCYBcxaO/zk4w8IgXamLPaU63QbyMDYyIRNj0AUYJOv+MC3Kr3\n0ixm4LZVgUNiGeXLRo2H+czpntfYV5OWyWteVSHK94CVRn18qIDA+rdPUhkf\nmX7qvIFcRKYY1r+qRIfDEaFXRfynQ2g4hsKYkacMSyXN1NFWZcgJmKcgjTSa\nG0JQxvFSqM2I2SAL6iCWWTwdTgowlY9Sy0PJHdp5pyyILdngveZAufxHNP/+\nM9MnOe5L6XFVmNvR13A9+1fCFKb0O2becBEy7j8jgsoM5ui0FhRqxSBsupiU\naG/shNW4HRFD9sGe6ygTXjgiKClBh7u9TZWanewQlDgn+PMbHGXhHWEzP1er\n8enmBWcP5oFx7gh8FmZxyq/AKJ/loqIYKmUUJPnvldNjxIVwVTEHepxQJKUj\n6eAwCVQ7IvuCY9WWXPI70qarc9d4LPKjkjmGUkChriUAn8VTCf8XixjChE5J\nX3EXCEt431wheP4wuCEnCD0aUeLGny67l9WxvMYG2BJuEY63XTBoDbc4QyBO\nPLk31fH4A0ns92N34ELf2bH5W0mF/bDR6hLvHjJYvVTwLbLIZnCv2mgfZezd\nHrZ5\r\n=HBhQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5294a7d4424282409796bc885fc884a118274c75","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-ef529f9-1587112302340_1587112365114_0.8276747488032115","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-d397330-1587333301668":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-d397330-1587333301668","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-d397330-1587333301668","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c019ca8d629ef75b9138996e20a82ff4f3fdc876","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-d397330-1587333301668.tgz","fileCount":8,"integrity":"sha512-4r6oorNBLPOGKteBvuwxCfkTO1Wz/1RtQK5wHDXNGj2xkc8Dh096gfkRpV7avfgxVIH0/ZK6iI1MIaz8+POxRQ==","signatures":[{"sig":"MEYCIQCz1ZcGkxwr4fP9PNXLMmgLxou/hucar0ypkPP8NpR7xQIhAPrvr0kLGMUPAgYaeh/5uMW9bcVf+o9g68cqnkoagF5Z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenMjxCRA9TVsSAnZWagAAKcMP/1by9PdGEqfMxlY9tcG/\nz68kAyIsplVv3a6oWXg8EHr+ZDOMzcBtu4B4HiffSqgtt4nhl1iEJQCsswJq\nGPJ06RO7J78Tp80cYWV5Fmxbs5By3R9p6VuYNo1fVZ7sNCAjVwhwBsH4dGGc\nRrF176pS6NpHvDDOmhzyyQWKTImoWd1NRypWJcpKKekJPuIc+GUbt2gC+Dmz\nErpxR9AiI5gXh9KV1oGAUqDQwhh4ATFb3kfL0gRzDnlv3lL/O1YIeUzmNW3l\n0z5D1WhzEkEKJZAovA9gUnTGz6aO5zfpwngkv9lWVpVwHKlNdKcUunT4J4RU\nNu7TfU0F1aDO5w3jF/wls6fNe51bnSLZgGADtw+sHs5qa+jiSIm3OPe79GA8\ngJykCtCLOGYgKr9uWZCwEq9OnjeBQ6uLWa2cftHNwMERTl1QuHCa4wMDOnn9\n/3hywKWXu/PB42FzIwNHM0EzGK9KDVVyftSQdPw2Hu5ZNYje+xVFxEHTkq9v\nt+YWCGYKx9lyaFFLnD7n4pNJE6p1dBfab7EsX++yUWkH7YkRssPDLw3kCt0Y\nMTElkXkQ/eE/3qt4N6OlDEuF+sCgBLMEH9QQYeL1omFYVvmFoZSLweJPjCSr\n7soPvxBBZsU4CQSykMxL8zENjJYfmTSwIH6aWyz4sFqaZxGoZ4cFaHXN1R24\nq437\r\n=iq4Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bef3632ddd897b23a13ef7b22e53f765028861be","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-d397330-1587333301668_1587333360857_0.13099645132737203","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-e9cf1dc-1587334338587":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-e9cf1dc-1587334338587","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-e9cf1dc-1587334338587","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5bb865663b16e32bef42616c8c3aa356375bef2d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-e9cf1dc-1587334338587.tgz","fileCount":8,"integrity":"sha512-BQ0lJFkoHe6U7iEb/2Hb3Fs3rKxIuYzAEq9X8JFEX31ph9djacKm+sHDhYmujK5lzsHLCzfAzcp4+gn87sYeCw==","signatures":[{"sig":"MEUCIQDDo/5aQ0qKeiAxgV+UhSxTUWEqkR5kcC53mHZ4QFgDrgIga53IGeEDN1oRKhZ0fRRDP75++yRw92r+4GTHN8jqrpw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJenMz3CRA9TVsSAnZWagAAEVUP/2qR8fRAfpyvzhzi35xN\nUIAaOhsHWNdVu4qY8hc4D0f2pZVvcKsrp+6aTdupDFWLgWU3BCFTEzHJlYfm\nMZj2u7tf1c5ki45eOKUIUU3YDAxDVOg6cgywoG1+WO/atwNpgK4fwO0bpnrX\nLNn+XxaYf4R25q2kMxWdtuLrg2cbHV9n29uaoHq1e/Dk8DAAmf6yjNuZXJUU\n3XhzQHUDc2rsuofSt8GHltbNyYEI4xMBsFq4NnpWGlrMbw+z9bmcIfgUw0z/\nUW4y2WL2847Hj4/Flv/NFkP1kTagY4CvZ/zqp3gHsB9rNcU6cOv6zfsul3w8\nCB/x7CZleznoCfmZBs8GsL4zRA0CR0IiK8wTv+weqdiq/9JotJyldOnlziMZ\nOleAyvXSoCj/BSsw5Gzy9mk9bcwqWiLWAJZBtIHnVQel07Nis8eZ0Ecmck/q\nmDFnTOQQyLMiyC0SCVWwwg83oxJnjY3gvHO/SdArsNRJ6VPIZbibXz7gj2oQ\nK8zBko8J7z6pjBbWoEMarBtz3V8utvtgbJLLwrEiFAGa2GDtcaaMrYJL2THg\ntbc/jUWrJvpCF5qLHRzEdgqr/saVyux+I/GhZK3fbVVsUExz71lxKWY5gvG9\nMeCQpoyEL8o1QMskh1TPhyrzMVpH1r4uBGlIPPg0m9q1k6aMvn4zuADDSDZs\n4mg2\r\n=vHF5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c1f31801fe5314b2a38f5a4a0f6335165f61e93c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-e9cf1dc-1587334338587_1587334390782_0.7208869900216885","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-d75adb4-1587498012278":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-d75adb4-1587498012278","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-d75adb4-1587498012278","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d61cd962761e8e9ae31944ee378f91b12eba2126","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-d75adb4-1587498012278.tgz","fileCount":8,"integrity":"sha512-r9Ygbn0pQAXfb+HJdI941KEOlbbZXwB4H1gJAT5owOExqt/vjVN1+CTXt70OvJPT9NOgIUZw/OZCJphez5JSow==","signatures":[{"sig":"MEUCICg6QiRBEbZW6mUZJ7JnYKTRVAKXbDg4aJsoEC1/A5+RAiEA3+xa90jlhY0WQXupMPx3EOt+v2zuaN1FGa97BUvB1/Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJen0xYCRA9TVsSAnZWagAAZ28P/RAFz0OFMMeRxOOs59qP\npIayKCBp1MnTpgDZTPGfdbt8zP6wfkEuz2LJPSUW+j8vx9E++hbuj72keJFu\n2DAmaWJYVEwvgpEme8cwtI2w1wiswZnILOwzlsuJBkGShfbY5ERHIKoO3bhn\n7vyJDnFkquRmlATxal7y/+xPtmo2zj7uT1Ri0Ji9c54KUiV12Eaet4VezW2z\nXhDiV4o92Sh96rbqX0Xr5BTbs+ri7JN8cyEPk1/hVes/xUzORYMFOrpLiiYH\nSA5VEcP4uLLAA227HnpUt0j3RV3DNH2kBd3rwpuBZ6F5IbgZ8RmIPKLjxCDf\ndC90AH/hZedH1JiKzvzLd2MyC29/x/pDBxBQ8LMt6FvNIYszkj5YissrWwHG\nLpIN7H8CFaunxa0tiAgtXFqaWxp3Egt3L0j8BPUCTr3963ClxMOJ989/OUzG\nVmy9Xda9jv1zlBjPC+vx/XLfGGQJF9+R7OXRCt1SBTzcqfIghC7/0gCoCG/e\niYAhZciAcd1TbM5hqeG3U3Ym2joXe5+szxLLcvUKhn2FVW4X3G0+FA6eKB8O\nHWW82arvkr1eloxf/ditcAeTri7CXi8r6UVdgGAJxt7PtdIueIr3Ft5vVDvY\ngR6LFGLDiMy/KgFjMafVW6XuoWO0P50NCPykHaZT6HD2Ji66XqglPY6XXZb9\n7fXk\r\n=WXyN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6566104388323b59418f32e2b6a98fa24fb7103a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-d75adb4-1587498012278_1587498072009_0.8340346212086314","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-f12c956-1587502643213":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-f12c956-1587502643213","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-f12c956-1587502643213","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bde1fb3855f899e3596b69740095600867dd00e9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-f12c956-1587502643213.tgz","fileCount":8,"integrity":"sha512-iVHhat15hSFFfYMQchtn1HN8FDjLmUQlMADuCtwT7ws4LU3osvQDjc1imCzTSPbcH9FMNDewJoSGJRseYj1uVQ==","signatures":[{"sig":"MEUCIQCXA4og0KClAPzv/plbqK9PsPNL6VVwrrpA+GqdzDmZRAIgUU0Lk3Uge2meTarCL6ImszVFhO7Q4AhqCqfPX6f81DE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJen155CRA9TVsSAnZWagAAHtIP/0kCUpowJr5RrXqyO2sK\n2aQ2KrQc+qhkwf6pbi2QMHEbYU7XOf0zaiOKdc9+8P4h+qg0bx8b1Y68iSnb\nmFQNVWZIydsHDV2PctQrRSPnbApeK45DpqownerVlNefHgFdPc+vvTAYsoLM\nXMDPOKOZ21yVdtng4AmgKMKVRtXSlwshB1koCcXh6tEn1KsrNZFSThyiertu\nSM4NdmzBkFx2o3gslLA1dkgp/3R/m93ChQrC0am6E5E8p4+lcALshxRTwqsN\n7JQPe5NWebC7AOcxsTlTo2nzAhHKr8QZCfpDf8oK7FAhCsalJ+ic7/qNOb2+\nFSqe3tn7O4qQyvAgE53xGYQJg70zD7VPoXBvr75vX48dUIOagFWKEFVM1/Qg\nmJDvvzeNcysY56Pgc9Cb+fd3MTTyexSbbg61/sBZ1kRFnhgtOD1y1JdIL+Oc\nZxu7Eo83fPxmBpVXkfVWYaAPUFWyq3076jSt6bYqdpsHsKCND8ahXw88Tp2y\nJg25X+XW6/9G00lpVxp3ZpSsSr5LFdEFuI0qp8qNYh00BJjiUrV1QcupjhWh\nMCHOb0ij4T0ZkvP4/6YQsY/LXhpK8PY4X+XdIv2kzbAhsF08Qigc9D/0RqMR\n9EViKTSO2aeEnD/msJyc37bL0hyzoke51nqekKBsEyQsWCK9eSYXN9K2EkWf\n5npJ\r\n=pIoF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5eec1563ce4612a490e0eab7f0819ffc5d69996c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-f12c956-1587502643213_1587502713069_0.3539450495782239","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a7f94bd-1587582397601":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a7f94bd-1587582397601","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a7f94bd-1587582397601","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"db7086bc09fbb032b44990ac8318debf24c995de","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a7f94bd-1587582397601.tgz","fileCount":8,"integrity":"sha512-qAmUHufVYHpbUIqP65gyPmqLxPbuTFHqPCwK5DIllEaOXp3fZfRaXgZMaRWXZOzZWEqkAjxUjaeolbTgQwWMUg==","signatures":[{"sig":"MEQCIDDROoA0sgUiKCbShNkbh2tcjuZFF+KXQtZSDRMh/3V4AiBryUcM/n5enwQEDnw1aq5EQC5mfevWQ3U9Mwcsk9pn6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeoJYCCRA9TVsSAnZWagAAEqcP/0uv+ttCLwOuOeWJNkFK\nEsbyR00VgpO0GAfKApKpVqZatnyUva6+e8gbFj7T6ZtnuRBEA37r4cSu0FND\nu21xpxSZQ1iubuZB2RTDJr/gVSKcrhiKkAT5+tux//M0gYozOxk0JafsEyUw\nvaIk7wnKU4FedYTRJ5eHNsQ6yde5YEugw2Oe3hkGjvK8UEpGT4mrJOWc4gRP\nMtC1n/vFs2u2swqFaLAXwxAIQbPD6U8+BKlgCsQYJaUFhOR6b9w+MVAkFoah\nqEGSls6h0OTLJBlCkA+NjT8XX8JLD4aiymWhSR6Cmv0dEt9SoHZa6xr8tZOT\ndHqAYHfAANbGgQAvUoMtdard/+SsvTqQ4JCsCMr6aiPJuNhPI2bp8snpxETI\nrWtG1mtXmCq8OMjMqtHuKnQJXZM6nqIrm7VQQfnTycr2hkx/nV+7uW6GjPhv\n5Dm21HIRL9zr47hFFLY6zZHiD8CFbhkbUpH5NbPJRvQ6x/uusy0h9S+S9KmC\nc8XFJXZFxVdFxbEalqendMXVDDYiQNT7yryV4XzzsSwhYHMveWLKEiVEnQZl\njCTJOAA/ThS8eKKrr7Ukig56nN/Ekwfb5gl+L/LLP/e7oOblG7q/YC2ajhX/\nxYHDdT4iMHwlWqcdrnxzxHYP3NMawXtY4wvZCQnzV/qwPfngllNUHy8BjRNI\nE7RH\r\n=cm/L\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8cae96b9e3404b7c56b6cca335c003b5994e9d87","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a7f94bd-1587582397601_1587582465714_0.5791412735233894","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-65fd91c-1587919873189":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-65fd91c-1587919873189","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-65fd91c-1587919873189","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"51046b46e8c8a19fa43b1d0986103357fddd2d30","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-65fd91c-1587919873189.tgz","fileCount":8,"integrity":"sha512-+ICF5H8Koc9jJbeZ4G6HAHCu/ydjp613NS0CLZK69s+dnDqukR9OagTOMdgLd5KbZT9vGvzAzybFjwY1/rnAFg==","signatures":[{"sig":"MEYCIQCrAvrQgwpuW32CvUtiy8JwS/2NAyvRocsocGtpRXZiRwIhAJ+0VuhOvPiRHFHruU5jV7yr0ZO1p/FVnorYkGvVGqbo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepbw7CRA9TVsSAnZWagAACDsP/i4E/6sVvMDFGfMoXV51\nmTZfwBjgXzRl2zZrJcZOrDC6+rvgS3KTeED7q2NQRfzZ3JoKENIL3EJtkwfQ\nuCDmUQtoRuTMXNdsxQ0CABZaUsBKMsLZNuJB2Ntfixf0mUyZLsyTZfvXPA/T\nuEUgRYZ3LIetP2Q5moYAyO2HeOIZ8UpBZ1D2i4xxuxBph37mrdciS6mN5O/Q\nOqCL9w3yW5qKGE4Et1Ei/Gb3yvRTBZSfCF+IM095UO53MnxM/My2nDCQBKsW\nGatvH+dtQNEzysgFQz/rIyAcSqMt00GkEeLuq9TYRXxPLvu32gXpQOz/b17z\ndljTV1pWXj8I7bBDQdTtBRHf5z7r2SGm23cBo0+SKCC33GMNU1PU9DrLqiNP\njhn3IiNrfighRSzTpTsGTogJvn1Ianb/uHkkUv+Tc/wt0lt4ZiPv3FAo7YZY\nAWhRtqhUHb6Zm2qpDWgEYC0quZEQEnmO17g3pvw8P13jm+/CPo45oarP5ay1\nTeLstZ0eqHR9AdXiJXqqUW9PGKI9fMuNfjjiF2WLhvJ8UI+y+Mqhi7w35AEP\nE3fhWJezf69+XLsKZlkmVSjOr0GZQ5nl5pGYWmZRLwCTaFDoREL6xPdzEe+o\nldWQSF6lpcEGJJVclFz1GehcMAPGeHcXr9vPyHMEPMWP0Wetr2QDq/6f/IOF\n0+0s\r\n=a8+T\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"09d3f3adf251cb1b93fbc4cbd78f6c32dfc20a1e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-65fd91c-1587919873189_1587919930459_0.2812213398067569","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-9ef441a-1587949973107":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-9ef441a-1587949973107","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-9ef441a-1587949973107","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1ec0e55f6411f7ca621cbc71bb764bb1057c65de","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-9ef441a-1587949973107.tgz","fileCount":8,"integrity":"sha512-6g7pY2n3t7Nq39vfsJixtlRedMcB8KB1Ju2EDFGanG9Z+ZX2EUf91PWkqMVeQml339lGmLjiWhpeZGD7+cPAKA==","signatures":[{"sig":"MEUCIEj4RNtW1Vezk4bGYNuAN3ky4iLe80+9pW0Hs3ZozQEYAiEAwUvie845ID4CZcb17KE5m4F+BCmMaxBgHuHK01MRQUE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepjHUCRA9TVsSAnZWagAAp/AP/3XLxv6BVmxZ2R1orVmj\nRzZSGn9U7+T0otp3KBAH8tdq3RTVeZa9dUX3oLSsrIQYUqkssTDQ1YhXIuFg\nL6Ot+r4IXyxmsHG9FEuSGkC/exNHo8TsQkhC8zJvZ2EulJXmgtOd+NWQS23h\ngLoiy85JnoaiB4ZquKahHXz3gERbeE/+Pr1EOKU12B/roipmyfCIVf2CkliS\n3h2e8XCXw3VapGWIcqFf9pz0EjTQqPW4Sq1WG5ppgnHil/EWc/d8G7JpksRo\nhJcO2bFVFtfOsUrPhmqyN3Gk1tKiWdyAW1O01QeygHafyH+yYivDfPGZhWq0\n+V52VbiecdX/GXwo8iYmG72/gybMQNfw0pT4f0asE+6I5xA9EUldOy/P+m/f\nbJ2D/qTmXp4LOU2Ap/MnO4Cn1S1Lpf9ph3gJlyMgbfJ51ytGl9yT20CPkWDM\npkTIn+T0CwWp27lBqhUDQMr6POrim8yaxSAIX/VBGa01qt9H0dIgo2x1XKtL\nQrWJY5BeoRb/JH48aDHMuYHQyeaV20XLd67bZeJOJa6p5wGoZxIckehrBu+I\nRXin1yS31blUDb/GxmTinK6XZIq7FC80EFZ6pUhxMOIFRiNihyLfq+QcEMx9\nrjz1It9QKm8rXrg/GEYM96sdhvExFx40RB5E8/7/ChwZo7lRiNnovc+sOQd/\n5JhI\r\n=bFQh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"639eddd5922eb447589f5fc862117e66203ddec6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-9ef441a-1587949973107_1587950036184_0.35985951774131086","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-b231473-1588012900301":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-b231473-1588012900301","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-b231473-1588012900301","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4e9d053ab3e5af171c5f99bdd263cd87e90fc1df","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-b231473-1588012900301.tgz","fileCount":8,"integrity":"sha512-bKE5cfB4+Uqpy5zVpSKCAsFvYjb5tQaqJFQ7tiPn8z5XyduQYffVpCdtx0uRu4Ai2tmC3FkEDzPqbJgOVPyHsw==","signatures":[{"sig":"MEYCIQDcVzUab+U4CYHdJd5l3ueb/0RUm4qQ5L3d0pxgJWydzQIhALENN/vZ3NqKHXq8tA/q2Krf0Vw5vgwUizKU3P9lTq9+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJepyelCRA9TVsSAnZWagAASp0P/jWRXZOF8Q/RN7lVv0k1\nY4/DRxD4huTKRV4ClKGfnoxEmF31Xt3n7+s5164+Puo2+IdFzsbgFBhWqMhf\nSaXOZXPf0JXbtX+X8kh9ASfqMkVd5i3dNuBeZVVR2TmKwOyAGzNNHwFQf9ut\npoWnUvty0KRiaBsbG+Tgl1TIMvRdYQFTtehPTsCt1wThe90fu76tY99YqVuU\nFx5LITDtv1teBbOEZqkdRTycVaYLPtwDKW9QVHdaDARL3XnwwucuPfpcjxiX\nV2utAnieoqch4yj0WNd0om9QAhsPnbc8jEgFK0JCKyfgHdwQDGBhG+weHuW4\npc8DDCC2t7FonS4QWGijqahJtXhEsn//LoYWH0m/FBV188RccSb7DO+YtSoc\nh0Rcp+ec+102Phov1ATzUtd0bL7mHpK43Mp7rt/TgAD5Xqp44vA3Tic1tNHg\nkoBWJUjl1Gi+Mq6NtWd1b3ywhAmFSiBYfqdjyujScYsBWIDKMpnE3PERxFQj\nW6elZCZk1XO+Kg6uRILBMUyDV5Z7QVifTmadOtNF1oircOU14ZwM5f8+YnwN\n4aCSr8JFbCqg7NMAT7ZZ3dl/uXHUr/qy1uBhxxJbozHdnbjYMZ44PQs4qFTa\nyvr0G29MyLa8HX20XvzU7Unap3QWTFkjVdkNdfX4R9zr5TnHUX0bEJHUsNKw\n4mnm\r\n=n0Y5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2c7eb23fcee0e3af23ed666e8f7d1cc860601696","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-b231473-1588012900301_1588012964444_0.3451369052601436","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-2c17e3b-1588103412645":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-2c17e3b-1588103412645","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-2c17e3b-1588103412645","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3191a1f2e6b86eebdc1f5d8701ddd9301ca7e7e9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-2c17e3b-1588103412645.tgz","fileCount":8,"integrity":"sha512-7g1GOIckIx1Pw3hiyRdx2zPHH/coViGGC1r6AUwMvMqv6MpLcD4JkG5ietEx4iutZAitQdRJrX9C6ZMn8f+IzQ==","signatures":[{"sig":"MEUCIQDN1Bw604ZluEWIr91ocDWhJjMjuDX2sZACUWR/+4kbTQIgB0sdFOG7j02th68lFwXKGzoRK6fIuJR5YPdC0SMYgtY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqIksCRA9TVsSAnZWagAAlY4QAIYsHXGgjorxuqjFsJ6o\nmKVVrqZufH16jM1OCp5grHu4n3aKwo+gDmB7oeBnjjN6rBPwqv60V/ssaxRN\nar5bh5G9PLjyrBYIj5JFTSRi9lRnROaYAy6D+nwR5hwYIiakL6Be4Ch5kQyp\n2js1WqY7UrDJyU4Fd9FNJwevlqR9DgrZdkMcCHhdfTkfweMWyA8jHm/kIWdm\nojUZ1gzNJ9dgYm31q0U29i8ZMp4LkPpkOcrgLN8LHSnz58jGawWKTShkn5AS\nSzS2PiHNOFScEbRO4jDnYFIGESz90kuOJPekQdZosA/Hc62QXGfSdr9Vm0ug\nGQGBTanFE+GX1GjVgQhqQV+Qs8NtDNzN4VWXXDL/hADptzwiWciAh3hJeB/b\nq49/F6kNX9XpwzqIztlFZB1Ap8x63XgZyAFkk1BSxJ6ZQMPF6GIXrHcmkK9X\ndfiJWTCKBO4362vq6DbWFEb9FB3Th2xpOFhgu2QHXge5Z4KEhmdnQQywYNt5\n8deAOXwINwRDrVLmjtEFOxg7bLeC5RUwm6rgj7nrwlX0bvuzqvtuPmD1Ywjt\nR16NfU0Z3lwfikC/DacOOvmsDfQpPUf95It5M6Xy7pL8jiyL0cBEjLl5Sc+F\n2hSXxN4zFzvhUlVlqGeMMubxznv3PDEhS2PKwEhG9Vy93doIjIc6Rqu4Sy+1\ntUp4\r\n=sVVc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9d69cba72991a61802617ecf5dd906ccbcbe6c4f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-2c17e3b-1588103412645_1588103467379_0.8569274716354396","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-0f84c9d-1588103466646":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-0f84c9d-1588103466646","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-0f84c9d-1588103466646","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c13ec32f1541fe14b6e06fd6926d7ae855466a4e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-0f84c9d-1588103466646.tgz","fileCount":8,"integrity":"sha512-S+cJTOusB3CHcazfPOJX1yuwVOipcbq4UeKuH0XxmQio17noYQfYgwlXINngi0r9+dFNJ4+c4eYAxQ2sdniEXg==","signatures":[{"sig":"MEYCIQCr8H9GtFXz4UNgWDD+FuqImAGbSuPj8HLrNTYlEGMl0QIhAOgjZZ4ZuVzWZA20IVJEtXPSDXBI05AfeJ74xPYBNisT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqIlsCRA9TVsSAnZWagAAHoUP/0UAAVKGOUGY+3RXtaLr\nbAD02CXDPDnoVbYgEtOno6pVuQaY6dDqzeBLrKWrIJIqfJzHw7eaG2qDLf3U\nSZFhImcWm0/d9J8nwJoLrn2Ep6t4SMM0r1EqGyO//vfhqjd45FD4xxQ9Jyng\nbRrTfaQcSnS2itqGQLMcyp3+tNqtyhq4ptKi1KHzuLLEeLOvDJ7P6n3yDSPb\nNS3RM49xW/xmUF8CeLxNHif/j+qNriUu0m5mKzjOMTZJbypSoafsLzD0thc+\n0aZ2W7bV48+XuZECqwpWR2wzCnpryT4cf6NgWy/r/fWSZ9uDerQEngKUjUyS\ndw2hs3eB756klpCa64YkDmtm1AME2Wx8rxpC0rfT1snvqcFLPrrfT1qX0EtS\n3uWlBNNCXeKZZvGjTAay4z17JY5QGwYLqMFQnrZDdWa7uqzbZTyaa+T5QGRn\nkMG77+AUPzSBwu5pMl9+fqriYOeFv6iH9UvWFn/NI8Z+8GfQbsqAa/unPt2V\nCq9/BLbPCOUNvZar0GEblpd9QjxfkXEFZ4jmmQjoQ0/yYZg7V7rX/5D+Y9rK\nIrLqGpqA5ZeJHEVZ0IAQnVTs8YsGvCE8qRro3NrnDF+40WXsyPRYWio0kAgK\nxZHpsMdj0REw+Ix5eWo7HHiNTz1DeZOcS2Tik0OYqBgWJXiYVwxChs/u4SyM\nI/+F\r\n=Ou0x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"58425b50c095f9e01dd9b69c19014cf0caa58b70","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-0f84c9d-1588103466646_1588103532462_0.7824381261520252","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-2c1627e-1588157983350":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-2c1627e-1588157983350","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-2c1627e-1588157983350","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"49689ad4e1418dde00abd03627beb09ef44f815f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-2c1627e-1588157983350.tgz","fileCount":8,"integrity":"sha512-vx0tZkfjfAFdBv95J+qzbupUWGx/36Jp3Dn8kXM5cRkrN4vMrYdK/ijLh4OWwB+09LZFweq8R8fDqHiauYv7PA==","signatures":[{"sig":"MEYCIQC3yTbpzVcBzb+6yMSZmdQ+3PBa2Ikgc8w91yd+IO8QywIhAKwC/3xh5gJ8Rrk9sPl5zOiKm4f9LMZTzNVgiwhbYURV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqV5bCRA9TVsSAnZWagAAdEkQAJ9LX7sAAAtSXDzXrDny\nWH5l0s1UccS2EC060bUSkeh+xYAkl4T99vjL/Hq+hag/uLIiWu3R5xp5fTiN\nYgv2tFbl1MRwC2t1NAZnj/SRS2Oor3VgA4nRQkRq7/2oq6LmLTUunC6476CS\n0CjWoupQlBhiAsbyUtT4NJCfebrp+W5GoFCLQFElmYExfW6k/f1v4CQEKA7l\nzBIDxEQ3DyiL7sHlzIWWXm31B2zR6XnMgX3/4/iYg8QMdnXSACDZhFznuR0M\n+PNyA12fbvOzVSGiH5WsTSgqBVDyJLZYGUGjYvzDQzBa5y1YwgcKEGwJRmNY\nmBO+iwTKvfsR/YZBeeFeDe/LNPbfapoaFQqQkz3WkBBtTsjnkwo85emkY4oT\nZfeS5kWxAi80kgqO9Bglq9tbHRhzhDrV61HbuYbGzPctggj+jgQYq78aH2Hn\nweDrwmNiSBVUuk0bF524p84c8Nu8vYRX0K0CiXecuOl5rQMGYOLpZ59XTHPR\nPTKi7K7IrVjcsNXd9WQNwIpGFtFosy3DIeza63u6c8ZvEiWrRF2eE3n8nuQ7\n8xOHK54W+iEbFadmIztuP2S3YvbptahprOxEa09l+K/cyLjKqQ5bgbTKE/TX\n15AE4E0xMKBcfrc6YhikEFljQ3CFm/XvpRFm95BQOi6YZyigTg4zdbZ2vWn3\nw0do\r\n=YtUA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fa27e4293da0e63ee1a1e89d49e92988d3990dbf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-2c1627e-1588157983350_1588158042852_0.1972007146650061","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-c424596-1588158013144":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-c424596-1588158013144","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-c424596-1588158013144","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4387a8e14db966731d64981a84ae08fa5a8e6f93","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-c424596-1588158013144.tgz","fileCount":8,"integrity":"sha512-rbqy7E68Wn4M9W17pQVng8Zye054Q4V8SUF97DAHOY5IIFdDMzVLfXCDdWIgmkexufgH76wkecwenqPZi+LR0A==","signatures":[{"sig":"MEUCIQDNqxcFCSyWfJZt7GIWWZgBEUDwCvaRJo32rFkVvmWudwIgXPVE+JCUamrx9kKQLnPME8roZnGcKSxQhfCeD4g8B5Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqV6NCRA9TVsSAnZWagAAFiQP/Rle2t6ewV6g++Lntdc1\nZTx0/UU9q5QGNFT1ajjaJYxq7YYAmiXgpItg03VI4T4X2kotyZ+FHS+cZ9Ws\nhD+YBOh703yYLx2pAl57ebtMsOuzaM2+YKtH2tYwK0a0W3TdRxb6Rue7SwGW\ng0kGqhMS0NRzOe8Wk9vthwZO7oBd7enkxAFwYIegrduUgIOZQd4eBeVhYhFo\nZmNUToYDPXBIJ5KyDfm7eyboVHJyOLbC/oV/isvWpNQCeraUW3hZESSsitR1\nbGW9OKWFLy5OAvaBmc67c65Y6kIYwUqWP7YC5+lsz+DPHWiBdUiz5fv4AdmU\nOvTtWyE4ldn8iaU104arT2kM90CMirCN6xu2OyEi+8HdKDWKzKvXTajhj7TA\nKHCYHYa5Dko38yvMTiGbBWwYs4VkLfwGsMmSluhmxC8W551sTlm40ojIkyr0\n5aoitTmF7sz/bm1hioCBczz3RRCGnfT+R5x3qUG3r8NJurt1+iecdNbuyvZO\nfz5FWBacAEhP2dhUh37Vbhrh1GSW15afj5qdbNoVaigdKQ0s2NF2ap1f0o83\nCEWtfM+MUJzDruOYSvGQW9YhX0uy6sVakApo1PwxJVADrnFt0Hk74EbRdOzl\nxfD/c+XAC1UeWJiSlcq1bpfDVVeAUJi2fuGWX/otVDirJWG4nArgPzKRqb4h\nbRQg\r\n=XQFa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1b49bec44acfbfe83ef82d444727b6105361ef3c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-c424596-1588158013144_1588158093475_0.9918134129540208","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-79bfa68-1588185892953":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-79bfa68-1588185892953","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-79bfa68-1588185892953","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a22731501032a6b6d089a4e1f4530b4ebe58da04","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-79bfa68-1588185892953.tgz","fileCount":8,"integrity":"sha512-SV5ny6TO2j21Xe7+3eBWcngXReMIBvZdnW/2T4w4+m87tpFVirDCn++Sc2rcHsLIsXx+WAqLuhrE9jtMFgz4Ag==","signatures":[{"sig":"MEUCIBtxG+KLNsZ7gfRR1MUj1OxtRxQuSdXxLfBHrCZaz80/AiEA3vRzhHjo8WaaDNeighK37SRNIxZjmKpaSP4CeKSiSN8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqctaCRA9TVsSAnZWagAAb8IP/A3SdFAhv4Of8ihKDQFQ\n0d6il9xf+7G5soolUsYsfxQaUJV5N2FOsT5OiBsZ8bjWfoyqURPsZMi+azWp\n7TvNcSWojwgYaVb6opkigwUG8hZJ6xXTFZ2S5EM4bymS9NHlXkzqyA9rZFfu\nm9JVHfZxoQbkAJfxB/Mapcbm89naMss+M2W5sS/eL+SF8IWurKiMdwPJoqVA\npaKGLdGl4VM2jmIvjiRSgZ4a3941TUCS+pGc3IS8braiJfbZZfL5xeKDvn0H\nD4XCzrS/DgYJBmgh8f84fmkSS/xgkYOypQ09pX/xNCQqbW+7sOtiXZrHTu1s\n+2fOKWJUjYp+osspV6ZpWjISNaaSN/dwKVfDtGper/goF1GfkUfIPz5olGtR\nJBMRpjhSqqa6cwX6TdYzIelidICGS+c7JQVwuuO8Yr2A2RcwEX72dM2aA13K\nA21saQt/wfjywCdVuaAep03+cBf4UVqpLZ8qCRMykPvV0UmLHc8Schbp/3lv\nOqGM4O3U3flywwOTuKZn8NALWF+P44BRm8ns4F++aXTlpVJ0HsITTQxllz8F\nEaCj/lYHEQcjwEmYPNN1/B3pjmr+PTKRjIrqcMKEnRdr34VLK3+oHnwf0G1H\ncFkbUarI4UGSzclh8IxdLR3QGa+EUZcy2YH4O9zL0X7UnQtQvQWgHiQjJeyZ\n/KSq\r\n=/qrB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b5a61fe21348cc8b2a8802b61ccaa6cec851c943","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-79bfa68-1588185892953_1588185946239_0.11420203528618855","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-15e7976-1588186715813":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-15e7976-1588186715813","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-15e7976-1588186715813","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8ec5dc6b20854d920dd587bf9527580c6bd0309b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-15e7976-1588186715813.tgz","fileCount":8,"integrity":"sha512-Z5pfBiN9eRjeNi00dwsEt5HqS1/Qkq2E59QVWAEi/r1lQ3dwptC3lNCruaLeFz+6h4WW+7QZaFYcKxd7R507fg==","signatures":[{"sig":"MEUCIQDdIuEy7xOIFAt7Rw8v2rBbATMgNIvIwNEEKfrWVdGMUAIgIlfJQoQS9YXHwDr70yk30hitTsxpAWxCvSVnzC2DwRk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqc6dCRA9TVsSAnZWagAAoagP/35idXxSNGpWhbr659Tq\nOTnWX+/QtNbCUqiWTntWyl7X7KyDIiizSqfqBmtRiDtCMm+fLimP4J2n1p1j\nWW8M++3RzQuwM2fIqDkYxeqDvkRGWQdf1gId2B55ui4+g/KFrRv5cdZNYKai\ntRNaaahP7zCNvcYVCFgWFh+KZOi6Z2P15RJ7wmLnOvA40Mv0kEzYGZWVdEiZ\nGd3NJqx9WzsiNkUJJvJXgObp48rvviLMgRzzG8+YALUjZohKLA8POljvoa3C\naQjGS1R0hl3CtXoVXJ9Gq6A6o5UWmnfZl6bG7PrEfyu2VlbcnxQJrRo0xnH6\nwd8/UZPSVvPFXCzBes+ltyKvyO6vvwA9w2IrwmXI9PsEMyF67jSwrKA/SEe3\n9gUIvdHo4+2nihm2KqX+y0UibosEjMJNoSSBAXZk//zU/99nFgXBXkNo5iHk\nqEeSUSCNEdRCvC+oEPd/kV+1axWm2aj/JWRDYojlm99Uw41BV+3NwbF/uwOu\nrvhzmqc96M5sEk+v3Rzz1Wl99iNgO1fdOY8XYEa9et25IFAzOlB875+Lese+\ncZlAr1yhvCThTw1yxlAf1rAOjo6giGwLMgMxCMukmdlzPd1BUY5k3PLI1DSK\nbsEZaljCVHzEWF9sRKQKUROBnvoFruAX+wsNmlwKAe0l+PT2I1BFI0sF7kA3\ny6LF\r\n=A9KA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"60579ba1540f29d09384e14e009ccc4f3dee3f78","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.0","@types/jest":"^25.2.1","@babel/preset-env":"^7.9.6","rollup-plugin-terser":"^5.3.0","rollup-plugin-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-15e7976-1588186715813_1588186780864_0.41007453129281957","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-8179d1d-1588187147368":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-8179d1d-1588187147368","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-8179d1d-1588187147368","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"19e628615063cbdad0ed96c05432fb9dc485c670","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-8179d1d-1588187147368.tgz","fileCount":8,"integrity":"sha512-2e9du8yLR9TKu5zZSBd7D3Z0uXo926vuDoYpEbJeDPXvkn8CBxYf/NOpwCDY7nn5Ck0MyebfuITOJmU//V5ASQ==","signatures":[{"sig":"MEUCIDfJJVPiJscVBDErn6l2Dcb1ZTLCtpiETl3pkXLv+5LuAiEAz41ub5rBIxNMUvLH6QJcuLWOIDwatMS+qpfnHWMHAC8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqdBVCRA9TVsSAnZWagAAPKUP/3O/u6pfkemA8U+9XS/Q\n4sdncCINNi+zoZM3uj9lk8Mt/IFFmxKptLq1pkJJ1pYWHVFROKN99FpJZDSk\n8RHOgPIuHzhf/26cPym9ZYtCRuUBfrUeYuQ7KAvQl30SuPdZl8NxxlC73BhG\nMV5Bv/elk+Yp5OkAU1iV272nAuRdfzIICl1HkTlg0/8I2NanJEt89jJ+sSP5\no2xpjV65hO1DV86LReX/u4YiiJcxhJrdz7j4BSKqBbEhEhn6BcteqLaSbeg6\nplG9PIyLpiXBSs3aiyyZ4Xo63tLZ5VOaBWq+1+p8epQiwFXSu+yFwWnYbmwi\nusYopNlVdB2YNiruoie1zOaxfFwVDFQnVCDhrrJnJwKwM+l3dhLS+dUA9Nur\nXob32aC9N1UtrKxEUeg8RGO4IVU4YGFynlQS9iEgKHH5lklZc5y1gP9uiNbI\nKaX6DgSxe7nze5hjEsYhbumNjwjJmq74Y7uD0Jmvldxs1Ksq5TFm84Dxno7A\nUg0Kzi3RGLbetvFD1W7F79VMCjdp9THGuRJOGw9J4kkA8kcjhuqmxXAXjwpM\nXffvuNGgtoea+nwKS+1z+qdO8+v2VXpV32JPuXb3d38zYVlWaBQrfYaqxQax\nWZUgfLQzFqix8upJDP40Y7etCrf3yTDvvZc0DXNQbAuBSKnTe10Rl2DWQs6G\n86/A\r\n=UZC8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fc8e83ab52ff1c6f5ca89b78c9e9bfac2303a6b9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-8179d1d-1588187147368_1588187221391_0.7170215563397073","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-efe0053-1588190101851":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-efe0053-1588190101851","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-efe0053-1588190101851","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a44e42510e74e46c09a727b57b8665d3869d988d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-efe0053-1588190101851.tgz","fileCount":8,"integrity":"sha512-TR2vEsWQLoTD6Bn/3pADjo1mxjoZzdqeAVqBsEqdoIQCFgU9D//NifRFcSPC45h8GCB6+v6sHnIGYAYBxwRj/w==","signatures":[{"sig":"MEQCIDJhmAXIk8phLJQF5K+xzypShN2KqV3naUUsMQlvE9d6AiAKVzn5jlKVJWY/g7hNfBZEcDV5DFriRjRJhpzpBVZ4IQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqdvbCRA9TVsSAnZWagAAvTUP/iKn3Ylj778dOZmn2tXm\nlmLbSrfIE7UkNJN05EZlZePFJVBa+NhWdzo+Yhn1htK5jgGyUcTZ7X5+NxLx\neb1shpaa/+4nDT/+b8+TH7eEBZv80ejrRD5/ngezPi8uj3ScxzCh0TZxjOrb\nYGKgcD8B5PODEGN5BTW9BllORZCcMeGQSHWScfu5eh6J8EGP9WdZoFG8yK2g\nc6Ow5ohQsxmhZ/CVnhl1cw7cMaL1SswuNaynJVsca1UMB65KWoyXDxUVFFLm\nygbv+EE7mODEQgyqPxpuIzQVFF4Q7Nh4zlciP09rSF3POWFGY3iGNWQ53Hrs\ns6diWGmQa6HndCiVrTBJkZXRHIQAEs2VTu+b9M/NA/DD3VNgZEwBNW3mVgOz\nUwF7u1QBBvPECvR/aTksdv8rMUdfiz1cxPfIRYrznRrHvhg1ha+64CPfdFJO\nXoKcJt1IyXR+/ySyazV8bpmR1KHYP9ajMtOR4DPQTmcj+BjOp5LXENJWlaLi\nZR6a1a0gZYyOX5KxFJarQjpB01EuFkInwXsd8VaA+isxhFKXEyBsr9LhcuCF\nBU2Mxnl3JurZ4mAS9W6cZQ6UCCbnqGdDI2BgZsvNBcB3aUgyR1XCUJhZP6DQ\n6rmkUAfNRhGmD+5jg1fFT4Q5rKcaJ6dPW2B6PvB9uRv+w5cQtVNFxdnuOMKu\nyD+3\r\n=rI4u\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"52b8fb424ea81bb0b13d0360c9e8a710d77deb76","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-efe0053-1588190101851_1588190170623_0.302730397954007","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-992f400-1588197333350":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-992f400-1588197333350","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-992f400-1588197333350","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fe35523ae205641c352779e24fb6ea4915187fc1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-992f400-1588197333350.tgz","fileCount":8,"integrity":"sha512-j8hIDbxxcxgiwIKBkA3+YCQ+zlBwber6VJt9CPkJACShjv1Q/9wus3g+iAvDcnEvrL15kbjtRP2w1EFwkOeWYg==","signatures":[{"sig":"MEYCIQDoyIfBH5h5xXh/40e8xI6CVeBbPdMxsLxRzkJ9TnMJJAIhAL34YQFmF6Q0vlUw2RQCjvXYXD351ubUZe7KiF3FBH77","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqfgWCRA9TVsSAnZWagAADxcP/ROU9GMQlugzGuUhlDk3\n5iy1Wui9Avqbyy1LbGCgrwlnLmn1hDVd6zKaiCEnow+IaFUCJt0d1EspFKsz\nD51gBEwifH6ndRBSBpSj1Xn4kodzd6nOy22CYsBJ9X0GFYhDfXIqG7y1MI/1\n/IoFlL14MQ3Nu++a7AaNPjQBaarm9mJUk3YbyiXbg/HyxJ0f3m7TqSX6CbRx\nRgOx0sPUSrYvPhYByTNqHHZWeif6em6jK6GLBNvcOUqR0eZW864Fm5iASyYT\naV2tUwJzfw/hlt16PbzNiNPsHrI2VHPjhwy+XFF86W+MTpziyW2QF9IO4u9n\nNVl+ZBty0MPJKi01GnPD9UWB2vr3DPDWnhFxnhB4UAg9X7QF3VfGxzEtBkLl\nJ0Q5/GKUVK4kKNNuZGJoVi6lZnyPJp4pXb1+8Vqudy0T4nJfbXf6M3DDjHCf\n1969z0FTkZuVX+3VLTbX7wZwUze+4KxPOlYH7u5TLfed20yHTwzalhAQVyxO\nkfuTypChI5WEpvferAVfbpwCL6w+/TG/FnKOI3P2KFNvfBNmiUt5kO8OJfJb\nM80py0PC87XKD7dwfGPPdUhsc1x2+2k8IKIuHr6GNEq/gURMDUyE4J/ymSfb\nkVJzgx/Xtdc9U1XHdgCVonaXWjmlyt+y6B0xU7NySu0jkdLFNKLE10RhY7W3\nS9He\r\n=YoWE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"35e2dde787e915f0c8aa7d6c03e0f247892dfa6c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-992f400-1588197333350_1588197397979_0.6958444071025751","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-1f9fb09-1588273271465":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-1f9fb09-1588273271465","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-1f9fb09-1588273271465","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"49c641baa91a69b41986af987493b4cc3626631b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-1f9fb09-1588273271465.tgz","fileCount":8,"integrity":"sha512-7k0TmdyzOfj6ff1TyIu3cqB9ZqmHPoI8QftZOMKZ9LPvSljiHMCzPbpXY7dWRXWXHZMPg6wfboAEaY/5eD8HuQ==","signatures":[{"sig":"MEQCIHzGEM1Nr9fjyz8I+6V1g5O0vB0nV5N97ZkFwVqFiyI0AiAdBc8WVXWYmdApnAkb+zpkVTC8NsDo0t8zvGCHWgCTXQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqyC3CRA9TVsSAnZWagAA2XwP/0cTSrJMyczCkIoDCJPN\nHdqNaSHJApFqoaqGT3byG33Pr1VQfOAjOBdxLl+aN4viCOLduqittNG2OR5d\nTdLDDq+m064QRvSCdY7tvdN+PHJwWZWmGK2z3Vfli8wyJFCrhvrKc0oHmSwd\n3onjvrpxwjBOqR92f5JDDHfpI7Yh9iuEzRq8lQTSOHp9Zp5hesNKPxxJrcWc\nrtKvqRtpBcLmBmvJ+oVnmhxIMvpYZwYCg4TWsABS0e8j1/BLiyBkbhyzZtSP\nqs6X8Kibx6dETAS+nMm8s0A0sN4MVeH6Nwu453b8yk9Ty8AZnqmW64uYXd+r\nXPb4RzK8v7o1aWIw20XUCUMO9fQB7I73fMvDnpvXSDyiKQupIaZphQ+6yyLP\nVRkXIll6i11Bkt8mZP0cqOIsKQruALQSbSMeV8LrtRE3ymM4uow6wGEsDvpC\n0+TvmZ2tI8PW/9fnz4BDz8sIsC/5JgPA4IElyLwE7U5VYtJ224uFY6fl6qRA\nQgrEZfi1tg0y6sxYTIlxAB6afH/VKXjINjvEjS+EVE6XVH8yjX13qHuNhMiH\ntQgl++QNH8IYa1Mf6GiF+KFN/+jye0UQt+vaXwMivRbZhhbSue8zs8KL6+cQ\nfqzZjCYYq9B6Yog0HHe6PVJ5I1lt+jpxbub41E3pgIF60x052kMtq6++ILRW\nVnpS\r\n=EtSj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9d4134aa9851f964aa26f7bd2fd4e40b2294158a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-1f9fb09-1588273271465_1588273333881_0.4228754271123414","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a5513b9-1588285015103":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a5513b9-1588285015103","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a5513b9-1588285015103","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"436e8cc6d2cb58498a493af976e9c85d34651528","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a5513b9-1588285015103.tgz","fileCount":8,"integrity":"sha512-FoC/YAYNQarcXhCxPDWqQZfJmnwmpGlR5uH1JZpzN3RwDASzhECYBeGRV2fwatCEsSR2B+rqNN46x9z/pu7aAg==","signatures":[{"sig":"MEQCIGQvf+KZdcFFbNO6mxhYKKIfoWkn927nJNbcKTpWBFyqAiBn1OGhfn4l0o/+9ofEWoEmWnrDfBwTL6d4IfA+MPh9Xg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeq06ZCRA9TVsSAnZWagAAktwP/iNtX7JcP8umOkusZu8f\nMsGvhtY+VLso8YjXeWVABaAhEnwPfHGVQXGTqdo4gpxlXS57q5KjF1HqVsyN\nUsuEJmPCOTb6UwuSmd4CRUjVRNEPLC0YsFa6OY0FbWCuYKbhiEj/m43Ah/4i\nELc0vjVzD+aQba9WdDkpvyV33tBRrsFtzVE5QsltMnKMv2MF30qKBSEYZKXI\nwYjrscNlfkFENcisKh6H1zzFphjq1u+UeLyMjJSLyjqgIWTTrZkXYviax5ip\n/cxVgWJEtbM9yp7s3DGs4ymxRhC04MfVbsxBJpVR7xa18avUH4wAUf2SOiDL\n1KZzpewnRD+IUMXKsRHZtkxGK5V6a3GPU3NYk50XiHhWcTH1DmClwIaJFcFN\nGXOruJhJbbKrDh0GE8DD/dw0gtSmn/5cDPaiuI6HHb4944LAAOPX9BcfwIVE\n6ZYlAG4NEe2EuZjFBL3M0NWCqyjZcIUM6UO2GQFcUgzVU+gFLLkWqOH5R9IV\nNRaxl8N7VjnxbNK/wSQlTWIXNS82kX3XKl3M1D6Da19CpuY0x2+pZx2ppDNm\nwdTWCPGnC4Q8+8HLWIobNkdzCgFNoueJZLXLF0CgKe8uFXbU97DjtEKTCXy1\ndZ9A7j1UJDZ079q9nxnHbWcXItx72ugrEXOcGMITRpgVho976vhdQ5DkwoEh\nGa8V\r\n=JGTJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e98289b96734ceacd8c3f3e8ea679278d72486ef","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a5513b9-1588285015103_1588285081089_0.9968284349600687","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-889992d-1588407679745":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-889992d-1588407679745","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-889992d-1588407679745","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3f4f9c3484ebf866e79339326fc54af94feb9245","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-889992d-1588407679745.tgz","fileCount":8,"integrity":"sha512-X1Y9wmOY3O9OhrlmxgzFwZJjGBGQ5oYuNNkOZc1cQreZaR8/2hOOlC7yR7aulhN1BaMGwGL1vwaGY6cvLUN4Yg==","signatures":[{"sig":"MEQCIATnFc7wbdyf4m61zMI9Zh7aSTP/WJ9T/uneYh1Cygr/AiAsDpdbnD9XwNY7KJ8YV6vtSkV/C8pUVufDB921O9nZyQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJerS5gCRA9TVsSAnZWagAAa6sP/0sZDLuvCnu3tFBFMvdk\n5PwHPmaZRtsjC0FYpdMBHuio51TjyD0r9iTaEUp1Q+6Bam4kVDxy41glGBsk\nsXOLXEEqY0Y0hpXgblItSqVxEouqKNQT8hLpiLtmNCcgg0POE8rz7gLXGLpT\nZVmU6FnhhR/J3LlklEzx+t4NLZ7nSrGNdeHCYngsjTrEZBr+jXju4VXhNmNy\n7MJAwAJezTfnIxmx4nqs2lU16XRBld0O1dh9RlTogagAqpQIO9nM9RzHcGjT\nYcWTRA4qqYLgSZ9qAGppB9+N2lEr5ev94D3IZ3Ez65O3HqlLBJSLuaAmwH5+\nyKabGK+9Cw0pCrWR6wI0nwgFLuxYGME93rmmrkZd2atHx1rwBY8ZG4mXtV5b\nWs2l8jtsRnEYFiE/c8+dAN9D4NPbG+UHp7KnsSPI5Hp8jR9vCCVFqvX+7Ky/\nE/4PM5d072fuH0GJumyVQL0vBO1x9SDV9CtWeW/NJzIahWf3uZmdQRoIoi/Q\n+ReEx6jvosFSQ+vWWJow0xwM91hLsgwU/sslpvy7zIJa1sM4jNXMOCTsGVyv\nMymtRVF0Tz1DLN+eTHJAO51XtjFH4D5C9pIojOdXpmx66dKWFexqu8Xvm/P9\n9kqBxYKMtaEazu8BzRPbe6sZBuS37RSIsH7zlL76BvAmgGa3YkU2xw6yJ4/i\ncWLD\r\n=L2Q0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"286bd2f4039dcf43f64af654c53cbde4d5ba7420","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-889992d-1588407679745_1588407904089_0.31223712974214424","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-ecbddb2-1588615076695":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-ecbddb2-1588615076695","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-ecbddb2-1588615076695","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4d72a4b21c892d4ed34d689bcd51d5d8459e603c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-ecbddb2-1588615076695.tgz","fileCount":8,"integrity":"sha512-m+J3UIqM8Eu9SzQwz8Ql/ci2PrIM9SFRW6wKSkqdpwYPiUMuy0NU2A9jf+S+VfrVHmJfkp3U5SXX8U/OSyOvAg==","signatures":[{"sig":"MEYCIQDK+4n328q8pYZ7zrPg0h1VZVni+yLz0dSEmnejJHIRsgIhALb5v/mmXpsFM3rYlT7erxHC4f/gIcit3+x9eYne4X5G","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesFfcCRA9TVsSAnZWagAAMvsP/1PZBeWJj/CYWUBuwD/X\nFW/hwGia0yo03GWKw/tes9ZrkYYaqSeIQcJ4YQ1cDWn9uPYCkQnuNmoOBaYM\nHd+Iitu3lGdAsiRlpONzFPkcIB6ivco+YK0rhUB79ar68ZpVLgPbkrt2nfbV\nuU2L+eBEZrbH489hh8e/OYnUF7RBaVH2FAIZZnm6ymUvPz3vWp8868DVw7bp\nXOha7XhVbB7jMhsX+KnOtN32+Wksbdlr5wD6WICZOjyJ9kLygCDCxlT5+4PV\n/9RLZQkIescwH5mlQ4IXlXP/Ya4go7bYeUDKxFGJ/jWPUNUt5IfdH8VFWhpP\nH2RonxTYxyB79fJKb79Z2bjaPZPMGUNLkmHh6+umGblh92RKEyQmVcjElkha\noy3mTaWFaOVyu1sBk+c3Bk/Og70PKEXwQ9irATM2DAoXqe4ieU5peT1YkXqK\nq4wFq91vxXqPkBMH+oeD7qhhTjTmKHZ4xaIYZKWWZKMWSW8YUt1okfS+6y8k\nD32MtaX9BrTzOCPqeXU5ugPhG8CBez+tBnjDYDymwcWGL3Yv+mWzzG9ytofA\ny8mK+4cuvPzrrdwH3nbv1wNXOgg/Lykb10tDeWWMeBYwhb2rAfndBtlLIXd7\n1549wK7ZP6mvV/RzdOZi7Ll+Y2EW5sKzyBrL2OnS6V5cO+VbrDcmEUssxvLo\nyBeW\r\n=VGr6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c63e1fc47caebe8499dfc3e29a37a158c6c228cb","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-ecbddb2-1588615076695_1588615132000_0.9296008218837832","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-19cce0a-1588675647653":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-19cce0a-1588675647653","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-19cce0a-1588675647653","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"007cf4cfe54a3bb27d6cbd33af47ada860c9bac8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-19cce0a-1588675647653.tgz","fileCount":8,"integrity":"sha512-r2mYpyxur8K15ByC8rgHWvQ2WB57WhxucekYcKCdQU0OWWo4rMJrvJd6HAPaApeQ1SEZPtQypiHHeqPAz0RdHg==","signatures":[{"sig":"MEUCIDPMancHizjq+M256JF5asD7AbBjT2ZYIi+szuKm+K4yAiEAu83+wIvWtEOTpys4+SolWV04tfOptFI6qrHlYHf62SU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesUSFCRA9TVsSAnZWagAAZ+0P/R6ko7oTDF5OixAswo3q\nS5grysbARLNIm4oYna9UeP4RMvYxVdDDIMTyZJ3wKNweHjfwMnuIbldcBru0\nYDlvUrHpRN3dh/2S1I9CX8JbZ3G0Zi5YnwA03r6xLNgBRVhRFtiS3hUPJMVE\nEaAIa37IpiuDKQr7HNCDgsJyII2bOLPSWN5kaQ1ARDMHUu10I/9f56tMolW2\nviEfQAO1hrf5ec9lbgaJkLLC7BH92grlCXkhMavFGs7K+HtUczxjlazMFGlY\npqOM8d4hzs1bmABkmJmF7KFaedhHMkD9oUPGfBF4GQSMjDA/xpPy2WhQZrjF\nTroNNS0Ql3uYOF74/nPd2/fna9FSfAl/i3SJa52ageOACX+XRC2s5hVZAFvM\nmFHM5IczKbtLrLvUHda1gvKSWTJCUAzq+3yOaYVKwAUeG6XNMmf0vNFXnlsn\n7MEIWBifWHLut+aVbL+AuOT2jpVoDHEUxu6LKz2aqoiN4b/ZfdW3fiHtibLB\ns2tuHi4w8oxun0GNy3jrI8BWEudwNiM3FWnMZ6mZ95SEBjvEQEf5ZnMRD2df\nfxlSIfp5elOmgHvplQ9q+SVdUMZnLAjaVPkcb59cf6VwAD2y1wkWvLyjrWuf\naW76RPH494oV4yOB6NBQeAJtUO/CbwyoSvqyr5VN05BMO/GS7hMXq4RFudJq\n7Sbk\r\n=jMmZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"745fdab24e9959747928fed1a7f0157d6337e873","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-19cce0a-1588675647653_1588675717303_0.839263431892296","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-52169e8-1588721273741":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-52169e8-1588721273741","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-52169e8-1588721273741","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4a6f574209a226a3e7ddfda4bc6d546f4355f0b2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-52169e8-1588721273741.tgz","fileCount":8,"integrity":"sha512-dfV7yRxlrKc4WPlyU8OrMrNMb5HJemFsxkL6Y+M/tsBtWVG62Jf8xW+sEYvmCoyLvJJi9HvbnnOKqQxuBLbgjg==","signatures":[{"sig":"MEUCICzMLLlFJFRSCbyZI/lQ4FFr7VoLVpJRyliZMlKebzkCAiEAm5wEfwQJeWNXm1a/6B6WfqGYb8i/9W5gpryWArsuvNQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesfa1CRA9TVsSAnZWagAA8AgQAJSBokWco3DVfUQTX+8h\nLQPCOkoW1jEC5L+uW70UbCOMOBf4cPUmfGWXkSN03/OEab9ABsLm4pqBzRN7\nFB4M+AChIFK3AmxQf1DfGiMWIIr3vTNcHf/F04muWeHc/Fv5gFR+6nQgtdLp\nx9CD0W9fkn1jzHULleSaUuSgknY04WUvS0i/ElOfTA6isHWQfVHxhd8YRKAd\nem+ZcFiQbPSf6a9TrxWTOP3RAnfe3SFIUw84gVAYAL9rdwOzZmOkJuVDPK66\nlENEcbETMqWHMrPWR35DUUsno0j24YRCnLQLDEqIeZ030zSrXKn8r8fRALCm\nGN7Q0+JY0s3r1Y7XkHvfkwppowWKHJXOUX3DHAzOz6guc2WIJxcpDoU1zRxJ\nUx5igg/a5Z7EFphEqoJkK8NH9kn+P+BxGNBeiRLM31nexVAuSCyU9vgh62vQ\n65Zm/i+7vRHOP1+M1ceILhFxjcuApaKb+ig6V7ynoETOtTiXTIyh4N23SWoa\nt0Mss9pRPvvCbulBvYBkjlUEnwoJPNj1m4Je9r1//tWByY4YG7U3UfOTA5qv\nBO7G4k8FM0OYr8V45pi4RLLVAe9kpgchgKhayB5IcV7foI9LDTBKUwqTp5jX\nU7vQu2qLtS+xYxU5QlS0bQO+JPDd72cJDYTDgz0cjpv8lbGapooiv/8w9dvc\nP/iM\r\n=GwXe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8888d15f3e192e6e1d3522e0afbc03cf3fe18c94","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-52169e8-1588721273741_1588721332854_0.18633623252209386","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-0055846-1588748538997":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-0055846-1588748538997","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-0055846-1588748538997","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"10e3dbc3db0c7360335ea7768b16295e0fd95d8b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-0055846-1588748538997.tgz","fileCount":8,"integrity":"sha512-QvCug8h5d4yFCu2EEcmciHi78VtYz1gnyvx1dKS2hCs1ZqxLJ5F+5ARgom+nWADO6Pd9UajAcMRmHYDjCnJHRQ==","signatures":[{"sig":"MEUCICEUlcyc8CUjWXKE3kCUGqPo5PuuyhV5hhs+T6VQaXxRAiEAjpR52g71qNQs0+BTUiw3zBB3VB0XC+6qmcUEZ2MEs2k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesmE6CRA9TVsSAnZWagAA0UUP/R4F01vq8miqD532le29\nPsb3BZGP052zmc6CiHw4dzRBVPX2gdmEMRralAwadP9mRFEdfxLQEGKLWQsq\nVhWmFPKyYqPQ4ID5Gej8bjSb8Zz81ytjvKSyk93oezp+pfqIQfbik1Ig8v/B\nYDFHuXyONtV9ax7u8j4YjZthWcihyEn3W4s/qoB/qeUyrwp8Y5129vw0Gw4k\nsgYx83uzjOpyRyRCAK6xX8mfUm7YNIu6+LH9qHCsZfGYwFUDli44DweZsYFb\nGM78IpbXxOLjKr9nuV1Gdf1yA4tmOTaYhNU2hR2j+UbV328VRAO6ihWXFRtw\nlRu7SFzbeuE945Qdwfh+RgnUJIYt5aToxjwomOn9Vo87h/Z6hAF/1TlugxwT\nCXHkE/YrLmxuE9S4DB2rHTpV8HfsNZjlhhGhqZOVG3PpaBKTsI4Rxu2n2CxK\n18g2ZbaeBWNyOqi0JEmSGap2aydCigtZUNFwVsR1Iktnh5J4bNmIi4PU5HYA\nAhU7vIWeTlyJeJNhb7jbx3hulYB057DDAV7XWw2ZwbmCuKAS0ycGYCtZa6eE\nsmIGkfVr2JSxBhVY1QJjTCU7h32F9IxVxkLXdKfiJBmcHFh4iVt+iEmelKUh\npDAI7tTyYO5voxeo2nn7AAv8b1y8oHRNNV2ePo+6spbuc58pYDLl0XHcTLcL\nCJIR\r\n=rK1w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"30d7e97adcd97d71d0f59582977b7e20f7bb66bf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-0055846-1588748538997_1588748602015_0.8385214797338907","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-244d597-1588755806680":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-244d597-1588755806680","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-244d597-1588755806680","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f7c1f1d09754a188689a9ee695be58b73988fa38","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-244d597-1588755806680.tgz","fileCount":8,"integrity":"sha512-SjZ+o5th3m1Ju7fky+5zD5VQTn40xB+nRoPo6Q71Pugb5h2Mk2CFo5JsAxXEHAcGlqBvkI+lhzHGr7OunvkgIQ==","signatures":[{"sig":"MEUCIDoqkJbtLpjWRU+X0ixw+4tPJxlE4jG+45cST00PstEyAiEA/H7W3eF2lb0/TsoG1HZ/BMj56PNGyLA5Ob1gjDZHER0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesn2mCRA9TVsSAnZWagAAaaQQAINEs68v1qPHBJ/LtdFN\nuCxM9NPrqI5y9kvxcvqMwQTlDUq5/NdUyUeOUtzkQZoQU7dIk89JVbyVOJ9O\nqQHe2o8JwUND6+Ca4HYJHtKNjxgzae8hZuZ6fIuOHJ4UF9i5u6EQj/cA0cyU\nVOakR2Q77ml7PF24SNiyA9HKvc9NLdEebb1JNBRA9oWvN/gRHkLZh0KeAGSf\nHziEhM1IytIeNneSuBEEy+vm6RmSePvM7dHJmXMeBX0HBKq6IH+zTaq9X2pj\nhjWEIyuTMz6n+IAx7jJl6GnCfovMq6x9SEFW6Xn9cQKI6txjV3X7WPQg0lJM\nHHCscZatixAXfHe0tidTa/ZgNN5UwZMgAa8rn8mOaMFyU9LeBCCzqB6tiB3U\nO6yeOiUXTDCoPxlj9I3/03EZcaDr8VfBpcCue7/3ZMd5Lx9+RWa69SOaAWxd\nEyg0ULAACjUO/hRwCtwwmKwtCuEeKtTZp35zLz4P2LSsprHQ9hKuxXc1mQVC\nrw2Y+Lg/rig+aY6vNydG8dIQ0mS4xZ/YImta8AHOiKXl+cVx4kaJ+PkRbw3c\nYlJGiddoTufTXQrlWF011vOsWYSIu50tNp+dhhP/XgGWJHH0z5gDX/BJmwBr\nxb9jHEOgNRH+1YJemvL9wSWITfcjyk/vUSzotl5I99XrAdIH74d9h/zhGU0R\n0bZl\r\n=0xuk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"33a21a05f301acc2e5cad1621ab9bb2a6d3c416b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-244d597-1588755806680_1588755877548_0.1690246938559714","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-37986c1-1588828986179":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-37986c1-1588828986179","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-37986c1-1588828986179","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b66e2a5b4a0754c34eb244db178273ed4bc7425b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-37986c1-1588828986179.tgz","fileCount":8,"integrity":"sha512-PEzU8TBUrhZfi6HUOYM8OVufXl3p6PL5ohkXYP8cR3GCOBIyhDEbT5Rq0j6Va1Jw9DEo+VTtXm+uEi6Hoo2pcQ==","signatures":[{"sig":"MEQCID2638V5BZ3sVes1bZtVg3v9dFbrn5goFD9ir+9Ziry9AiBrnQrSqcyk41RjPkHKE1oCu3xy5w9YZquaSpfu6GAghw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJes5t2CRA9TVsSAnZWagAA7U4QAI/n+mPeXFsr84mjkA35\nNIPhEzV9ONf6re0w56A6eBMNZSzsfri/3Przi11d2KnFmZVJnwViVQXR9z3g\nWOb/vvkiVCsSrRuxQJ7sTDGqWd0gpnkhdEW3zI+Vvf0usAwulBcehbMtTIyt\nfp2E/wVMN5pQX9DauHCXmhiG2WX5YxDVDzsrJwXwuzxfEpvGQmA2o7gMmcl/\n9v1qT5X245/bAjKLXd7wKmisblSM81U5LAQKkKZF8I5C9nqrH1qmYVyLlQME\nF2IOEJ4nb4r1e46KVkZWULpP5IOzfr1Iso75i3S8FAHho56S8nc/KFCwVUd+\nwhfX5MrxQHOWlNXLI4yeP0SfxXpYLkrY9X59RyX6Coe2VEKrpAXJ2CD/BKRS\nWW7+GoElsKNtYXaWvANMOQfLxc0oEkRZp036ep40Dephe3wZJ+oL9Eej3x3G\n3Vr5jYeTDNZikdkkKShtE39cPI6k5lZPK63Hoq25a9xi8daZyVjAL7TynZWl\nolyCzZMDO/GUxVZBxA8V8QuMK+NEAaKwcDgZ866m+E7hamP3YD+kedOF3VRO\nPPoGRTIOYUrBGNWoK/LMhfaEHFnw3E8a6ycQiZeqVLK5V94KJsyfIGRHNsdC\na34bD10z3FmWh+AqdtfKUN13+tthjsMu/KMSl6a0UB0+/bNexrDix6lBSAis\nHT2z\r\n=Fmex\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"25a6a65026af8c1c12ebf3eff96830bbce3a8e55","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-37986c1-1588828986179_1588829045860_0.9188776932207618","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-0f6ff6f-1588841434488":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-0f6ff6f-1588841434488","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-0f6ff6f-1588841434488","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8656116b9f8187a166e1cb2c305b485da47af461","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-0f6ff6f-1588841434488.tgz","fileCount":8,"integrity":"sha512-W+agifO40d719NUWOHBUQ3bso8XIwDqOgYXFWlRGFANS7q7bgEGILVE8bWSVm9NVRICIFcSj6sVpT/ZjOs3DQA==","signatures":[{"sig":"MEUCIEMp9iYLbyFMkS65UEFrn3cvF1tLoMpwV1e027o1Li7QAiEAibdQaB2cqmTEfCAMUlPghZxvllL/n3+GtKwZ7EYvL2M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJes8wRCRA9TVsSAnZWagAAs68P/AqA4yAo/lVfjPuT2YNk\nL2CkQ+M1RztEsmfvTD1IC1eSJeBTE3tQQW6e9lwuhDDus5eUyo+9gKH1KA3s\nhWt+Slp57EPYFYd1B36D+Twk4DH8hDY+xHAqMOjVF+1+Eq8rTPnrFR6pLO78\nJePIyoteWrvofWiVxVjCKOrDdYwrmUP0E6KhLyv2EvJXl+v6sp7e1ndzCU38\nEmz//iP5wJs4Q0vn+bMVnljn/TUOU5O5vihQja541hpQZH8Ru+OZ+SIwyF6G\nunaDTy+DJUVJBGxEfxA/ibnGfqRpjxcYYxu5UYuJd3F59YHa2KlhL/jMEV9h\nBTGHrromOtrfLd7Lwje660+ZtqlNHc1hX+sFZDYzlZ88svUGDCLhyVpmgUuy\n/OLGqsw1tJwDUcKKGdBBSJOKjmpVkWeLA2KLOO31LPDMxrtL5LbyGViRamPM\nBEz266yr4hJ49N4GXMEcTlLOyFBH8pxQ9bOAH5ofXnMTroxjfaNKMFfMhpcF\nGi1GTPGX3vC9RSAjXieyqS3T4NEoJ7wyzYCoCrprDR6x0GiJeRTMq3LnNaxX\n7+n0rDzXQg48fF1U3OB/jhxIDBv59vvV8gbtOfjP4IpcGXocz3da8nDU5SW4\n2uX0XElhmJ+1PWLZOpHIgLXqsbIIdUMOFwEX57jHVTcAHW+OjB317xuekc8w\nU0rA\r\n=NLQv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"61ae0254f00bdf3f3c52cc265765ab65a5632dbf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-0f6ff6f-1588841434488_1588841488814_0.6907280368914002","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-b7cc680-1589014630167":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-b7cc680-1589014630167","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-b7cc680-1589014630167","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0edc5cdbc6c299ba212b37fd383222f040b29adf","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-b7cc680-1589014630167.tgz","fileCount":8,"integrity":"sha512-UxCqXxvZmmXF+g7s5Vl2TMzWC7NoVwsRBJys5OX0nPxXjcoHA/BzKtAlJna85hY1YUj+2WWZMjMSFJgpD8IvRw==","signatures":[{"sig":"MEUCIF2JRm//O3FdCauSvwjNM5s7+IVHulym9ip63k413a8ZAiEA3B5Psz02n8czaT2PRifZLDPgQj/BhNcpgUkJJlzUiAk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetnCoCRA9TVsSAnZWagAA7CsQAJby3T+zXn87tXnM+P0Q\nkKL4U5vG6QTM6kruZ7uK3rkl+5Rsw90vbNHiEYZpdY0dd4v5l4YWsF/7uCPA\nnK/wT8aG8x1xKjJD0SxqeKTMNntNyUtAaEyEo10Wrc7E4CNxl6mwCZuqKm+q\nKE5fSHQZvXFAdt/pHTb2+HhCVnopEUSxg8JA1ZzdpEqkQb7LPd5YdrHSR1JM\n3p4xr1Ja2ZCPox/LCxNyNLFlgze8VFmIls6lF9GIzI3xS6so8SS1/ZOMkvBe\nALWO1Wqa94vFijx50COndM++EJCDKVqaXhjJSThfAB9z17aWl266DMOhexh5\njWBBxWSayzunuVYa//N0v8nQUymCON/DHkHLTQZK2IrZKdZFyyxqPc85cwoX\nT10VriS4xuErTPVzLvAWcqblXUUTBQsq7VFcmOBJ8Z+pQhFKm0qhhxZ/5CTX\nEle1LsXlhzmW8GY9s2+RTVgIJJsiakTZn8ELC4fFZYtU5xhOmG32kHIGeuSl\nAYZ8gOWp+H41VJMtEQ1hy/RKO6Y7u06+QhOWEvT4zmtbz3pTmTRkvJgAVQr+\nyixPMbfejqMUYQeNI0QT7SLuwjCvBvlfTqjq+vfT4i7bqPmQLkctHoABYZSa\nLBHuDoENm5Ls+a+riSCS9mXBsQyDjab5Ny5bW6nQL0ScAHSEOI+cwa629LfZ\nRpBo\r\n=Lw6x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"62cdd65938c2187a4afe754253d9cc0f8e6e116b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-b7cc680-1589014630167_1589014696144_0.6340570022451792","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-1478730-1589108142075":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-1478730-1589108142075","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-1478730-1589108142075","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4df3489be6c773c602233fdd09d6a6e8d7ff2f4d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-1478730-1589108142075.tgz","fileCount":8,"integrity":"sha512-Z+Qwc5oAYHk4WSg/06SyQdzoieocY/nrE/K/555FkbdkLphopkom35QAqoIN8oNBMhOGsheQ1KoAru1iHQQwIQ==","signatures":[{"sig":"MEUCIQDYzSmGpyVWne/8INdCwK+PTDZzJqvvrJUWYsxFmQIPEgIgYtGmywH49EuU38wKf2TW2vywX8bc7oLFouzL7TR02NA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJet93oCRA9TVsSAnZWagAAF2sP/R0jrAC30L5b75SUUc4l\naXVsVWeYDusCPI/vv5Hg6E4T4K0hh4RsqvdUL37yM1uJrVl9gKMERfpAMBlw\n8b+IyKTTA7p0dpqjdcdrwMlWisvWxX4lFqaZsk9KB/SyFgJoqSfBR6fa6JEA\n18GujEYZRWmRUWpyR5CMRT1aEEotWjuUYR9TtHXdIYLSQflssOHBWi6tBTIa\n7eMV0kynXpB1ShsMkMFl3m33cF3tGPlexle8LOodbRsB8a4hRB1dPyxeN/4U\n7fBnZSUKy77U8W8myANLmY9g7SSkX72bdIHFqG5Nl8iz/MSuJC7fr+PGFiOZ\n7k4GLr4OHznFE2hAmedR2djeOFqk86u1OmQxqPU4mgbmQhotmyF3nIcgmiti\nGZzsVlsChCVgR89SozfLOY9L6qYwzLTKo7W09gBg9A8ee66Q3jG7D3r2jWNF\nRWSabAn1ogitzxzqxJNm+hkfskRYlyL5xXqiXzewgY94OMEqLq/8MS2MxEcf\nxal5aXA4x7+cQtR1ROnlfSnaczjyMFjFAJ+fr/snXTPztv4tgdcBpjkgedru\nuUP349pZtsbtlzHi1iPJd4dcW2PMLzpHWjPJdYbTYqkXFIL6yeW+KD4FLr3a\n43vNKSjws9XVYy3rdQaYr1/UQpJ5a+RmJamQaX+wQ4d5XpFn1Tt/pumbP61F\nJP/t\r\n=uMoa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a3c941b6ad5c50f5c1190bd42c233f8edfa8ee42","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-1478730-1589108142075_1589108200231_0.895600433657781","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-6f53112-1589190833506":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-6f53112-1589190833506","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-6f53112-1589190833506","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dede969c9cc8e0958dced36c4dc3a9cc5e57031a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-6f53112-1589190833506.tgz","fileCount":8,"integrity":"sha512-baysCaWGQ/RYCVsC3CSgs7KNTEm3bEjz+h+3jJhWbTZFPbhAuvi8TGqDSbkvTG94HxP26cQnz7pbrieeITxaFA==","signatures":[{"sig":"MEQCIEDfAwvYH6ZqL3U35vSecDHyJqguBeaGOvhHWakucSaoAiBj3uIS2dMqgLrRA3LuLWYpgZbdQVuclUIUcrQzV84dLg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuSDqCRA9TVsSAnZWagAAUOoP/jfxSSewkcBWLeWENUT8\nAlsgcArtS6PSuxiH3nLiEg3xEUpxmBlHf6U+vTDmePhcTn6HYx8h2qUWt4Bh\ntgikFlVm5aKipjwjMg8fZMZjQ0O5aicglhWh6RyC9rWhW59nJl0DrVrmjaby\nRYtlwYl/GAOS+5EZxZ3NMm3HTc4H7HZ6coilOGOM/3QYLKvJeBf7HeMsBziB\nfSvW0jLItMedCZ68PHrrzzN07Ghe4Gylz0fSyhYZhLdEdEwHN41gf5L1aGpV\ni35rzLx1IVudDECEbuMqHV2iG2o9IATLkZQ3vKQzp45Rl+T1/IDgimDEVDf3\nRAmXgA1Zh7ne0I46FSgVev9PKe4hc+y/Bw0lGvnsLEq2Wxf2ObIBZLcdFa6G\nepwTf1JKW2TFb0RDx+4TIbEY3Fsx1vM8EB7jaKPu1lZeChonFKVGnr0RC20V\ncVqJJJnYRsbIkkKQ+jSa514eI1WP3SCDiz8f7/GB5FOdF5l5pRqTYg7vcMeh\njnuyM224qOiVyLWCA/+cQ4sISYI34OykynYJPzlXxjYozRX6y/5Af/wA3vb7\ns4qdXdVqnrq/7D0MVXxuz5nhEJqqLnF5d9bbf7aKrDzYDj26JoYd6aMXYalK\njmft/mphALbQHx+Eq2WV2RsnGcWJKL2qkmQXVr2rcskPSMWGEdoRRxhoiag5\nTFaW\r\n=WXGg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a170cb1573b5881a07e177c337e09f4a53a51e0a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-6f53112-1589190833506_1589190890082_0.5880411901659897","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-56d1eba-1589307147434":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-56d1eba-1589307147434","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-56d1eba-1589307147434","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ea65e5793bde6656e68e8adc8c39e0628c4de3e7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-56d1eba-1589307147434.tgz","fileCount":8,"integrity":"sha512-yPhprAAKAatYSi3EEndNvKpqP4LzrkAJELnTeU6l7CpHneeG4PCE7Afvx8KpshcQXM6ofn0eBlm8JNKNkOOHeA==","signatures":[{"sig":"MEYCIQCadVQziVvMkMHee6aQnPELQqmMSnnv8aSMh24bnu3z8gIhAJy+khrsFZB9rhTIKPR6rlLQJ+fcI4wN3f87kaY1SRIg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuudGCRA9TVsSAnZWagAAy3QQAIpkRgapH9fcJoPk7z6Z\nsFqteXuoalBwEet3j3u/CumZscPVDJ38U18WRS1rTQOcTS1p34HY6RqeY8p7\n5io5csjcvlXg+KJzZxGksWrUHM0zq62f9vECoISJm2IzxgS183o22NOPuo6y\nZSgWGPk0wwtYNTB5DFnls6LO4hkEfSBSennHdiMM5JD4z6pCRF6Kc2YWa05V\nBEOh7VpUjnyv04jOdrv9D4deTDwxOoGEylbefxAQ6/+mAnt0YAUaLHRR5y3y\nZD/BE1MZvOocO2VVDS6dIz6i4r+ryjhXxvEtfsDz38xqkYhjuSHrv9RE/Icm\nPRzJj7OHtYr7r07V/8FtuGJvgFXi29sf19qawB88ItYmdiIssOTSp99200es\nqxpBJyfgeZBQaYH7j+sKvBfq3H0g55gigY/WSTnn23hOsK7JYQ5K5j8EvmWM\nCbLTFIWYbavcm/uCZIP6ytVMJ/z4jZ47a1C5U8r9oBIzpxmH9Ztni0m66QLP\nvy8or0rU8Ab9kNjnKt9msdWExvjwn5LkmnjClul9CNqPuYMwhTl/l4kGgu/n\n8r3lPKFrtjMouQZNq/vLhWzgwXuXqUBFgbZBb2ZvdF3OQPiL97tzykZE9kna\nnXS0rfz2mOZ4flM1CJ3psjYkWoq68lK6MD1Z+P8bCWlUwPMQolzyE6iAYJx9\nVkgp\r\n=XIFI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a438b6211008b5ba8efbbd87fdfb09e93bacbfc9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.0","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-56d1eba-1589307147434_1589307205686_0.03959193083110746","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-1bd0d03-1589312259435":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-1bd0d03-1589312259435","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-1bd0d03-1589312259435","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"23189339471e8ef910c7a20105bfca82ab96391e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-1bd0d03-1589312259435.tgz","fileCount":8,"integrity":"sha512-B0ii+0PuJ2HBiYfZviLSoZyhOf73LAkC+Vh8HVtTbph8ROAuu9SxhBHYJNARKgFQrQ9wWvwvWcEzN99Zyx7xsg==","signatures":[{"sig":"MEUCIQDoUkIpiB+juTHy6346dApiGduE3pOiqaBaQOsquOCU2wIgIbMf0VgW7We4ARxhkAZHGsQ5+phHRv9FcqP6yKs2nfU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuvtMCRA9TVsSAnZWagAA3g0QAJDeyhb26lY5vX9Ls++C\n1tOx9EqY7T5pEABPaCGQQzm+sOGxgRZk0NU3HhG/FD5Rsz/1q13oCmOdI7eN\nGI7kFXg70rkoAZOJ4JnhCtPWj5bv5sM4ryY5iF2IHJUZxPpjGI2QGTJ9MNhK\nc+/RK/ntvvbisz3uhp67DnT+wNKuxL7kxvYTNiN2d1kL956i5pICN/+URjNp\nmRVwkqoIfeozsl7tg51zHNhw4zrm5NUE/eyhITH189h2rRYxfTbwWSqnQ67H\nY5vAvgSWb9PDmVPLIla3NEweY1+mL+NO4CpB0w/Osidva0mHxyuQZfKFjWe7\nUaQ25Tob94M00m1QTzqfs5VtLhf4NNgPju3Km6ngkWMDHQ63DpPp0j50n6If\nL5JeoHOzmOCYsk0ygEfBMKDfSvNBxzuRBaZAmdbTnRl9cr+2lFst85jcuZId\nvI/FUl5aB/9MYByROszZxn5f+w0pqVeIhsew3hN6RAP8OkkG6Uj0m9wNSfla\nZ1rb/dmj4dgmiHwZXyc74nCBlMBnqpe7UkpEmhelmowRjI7WkpcrbGaMTJwj\ndCdap3WIVxAxtPJ5ouw14DyWGdHF7QLCgINDUVjwfAmfj0tIaPwMqrN/KfF8\nmkiKIwSqAl7/nQbhUEhizWbyYN43KDdA5qvfo9ghU7sBM80+1/TnKSnHEsTr\n8Dzg\r\n=4tDA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"081ea88cda1df29d54d1fff4a79bfd0b093a4018","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-1bd0d03-1589312259435_1589312332031_0.3665068423517277","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-344fe6b-1589318878356":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-344fe6b-1589318878356","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-344fe6b-1589318878356","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c0acdf1e02cbea7d863092690bb708acf1f546d2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-344fe6b-1589318878356.tgz","fileCount":8,"integrity":"sha512-si2oTR25DJ4n9Ln6aYEtUsEYeL+Gc5PYPxaEKDMenAeRiV7ntOi04l6Q2XeJjVNpOLSTza6rF7tcxfySV82jWg==","signatures":[{"sig":"MEUCIQDRJigMzZtsP6jOUqe/hh61g4B78JwW23Q6Ov0X05o92wIgNIoPS7S+vGvv3dWQHBpeKzEavz0DFj0Fao/qeh2xZjI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeuxUaCRA9TVsSAnZWagAA2Q4P/A+ub6/O0e09xGByiNPf\nvrOaqkQlc+pu3EPy6Or+VVMEKislyPa11sJWO3ICAL2hSi3VNs24p7MVJExI\n5kCwwqdasT7MUgWbm8aLd4HGpdNpjDZPnAcaOtWrwn5nHJZqWH8baMP/Fx1y\nJfMFxEp6lACGcg7idBuknhin3rJ6OvS2xQlJhEF+65r5R+eTnT+4rA3pH/OU\ncR1FOm49aRvv7iWHwkdkk5Gps4wYsXtq35/Ini4/qtuD5Zj9q9qe2gulXAdV\nyZEqTpZGWLcKiNh7fYBmo2Qe2mHTCxcQFlQhxQ9ea4qDgeOg0CKNFtyGiE8I\nJAIFR7at+ztoea0gZURqrsmwdDrxDFJakQK2Ph1X10Apf5UVzJyoUn8AvETY\n0g5+VXk0xk9+s8ohDBdMgWJE7QytksNEEp2TpBEWH6pMI+Q8FlXqDYbUFjG6\nuOJmcARrQfIuGHX+ktSxYYL3kKwfogdZBk4nbYnE27a+WGLXvnpkUlbq4Xda\nMHtd92v2IPSeiVPXhoQ5Z0Q1PlsSBRR8eXXYFKMtJ5N8En9vNw4NO4Ypk+JS\nDi4GeaeKuanexzzLWblvIjv2Q6slZ+RiRWXqV48Yk8m4Vxz6yQhjLq/fxeQI\nUQlb8QqonQrCpl73oWaSycuTVr16LkdwohHnP/YhQ1VGxMaSS55uy/T107wF\n3SW3\r\n=ZSlF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"23342bdd22df0b0b967337a97c363c2d7b2929a5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-344fe6b-1589318878356_1589318937742_0.27235322067316226","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-8020112-1589347820274":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-8020112-1589347820274","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-8020112-1589347820274","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4354b31a2c52dadecdba572bbccb5c2d59fd9f85","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-8020112-1589347820274.tgz","fileCount":8,"integrity":"sha512-4UKZ66crMZGPEZXTKz2WYRIpwa7X97By81MiVOlxCpgAj8HnWg8bPcIEqRIQp6WRAukSNaiHd0jGKO6qx7GDug==","signatures":[{"sig":"MEUCIQCs8GNaCnRrnIZ+R7IAwucEwqK6AEIlhDN0UynBRzogZQIgPJEItgExOZQYcAPIgA4qV90+Io60Ro93lKqvlpzXYPg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu4YuCRA9TVsSAnZWagAAuqUP/3KV7QdtQh38pk9Cx+NW\nU/Be/Gop/lbEpjy+tG5nh+pcIjNN+1YUjpqH3qkkXYgKHzmlTjIE8f93oUEw\nv8YFoFXNDw8ZcXsgcXe0PiYelhTlE3ZOEvSrvrJyAcWQns4XsObMF7T+uDMq\nKdPU5RfVWsDM6udynwEPbmje9iikZGSwSYCd9T+e1pXJZjUXQzfmvRRx1941\nl/BMJSL65OHjEj9N+crS94IVd9jco9IqFnLYlFnkJZVsUWraPrYgKlNt0uKX\nepem9fRjcsZ3YpAQ/Qgrcfr7JSACdaMM4U8BQflWrqY9rrh/9alY3IPgAuc1\nnXrCWwBqaplA20LZ/SuXjoCxq7sza/LZPeKYtpXd1nWf/33cIyFJqySA6mDX\nKCfKpd4Ol3XwnDj7v5JJGFdD3bhGDed3sqMNKnn5Eon3SMaFUm4too5Eia2G\naRQFQRsqse+R0qATLS3wYUfe/l8kF/vyOunHtVYChf78anh0k7dfENMxkwwQ\nN+W3/3tW8oBYM6I85R1l/j9qhpPnYPXrOKMpU1oGhvAcEXgQLM2LhRvb9cxZ\nip3+MKJjdpwKvgSvcqcbHq5Wxb0pl4pI/UQsw+C3quSDv4dnTDzLEM2Timsk\nNiZZDeMaUbdR25xMmAB+wyXBbq0UiFQro08urRD0K/fJrSLt3kNM8tt0TuD2\nX0fE\r\n=ng+p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d6baa54fe455796641cbc9b8777b048248c1fe27","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-8020112-1589347820274_1589347885279_0.3831750903507347","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-ee56d70-1589352647665":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-ee56d70-1589352647665","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-ee56d70-1589352647665","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"07d06f609f11b4cdf59132bb927295f5201fa525","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-ee56d70-1589352647665.tgz","fileCount":8,"integrity":"sha512-KoOeRIUMEwmy5iTBdxXDTnBON/wl+xXjqY5wUc5T55g5e80QI1vEQOruxt9pHF/R2+u1pjP0FKhApYddO/fS1w==","signatures":[{"sig":"MEYCIQCFxDBZjGKMp19/KhmFXKSSisT00HlcbL1cnVWyDR1wtAIhAIJOlFMo04i/9nXN4TbDain5Ms0yzB76uORyPsIIR0/b","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu5kCCRA9TVsSAnZWagAAsicP/itt1w8LHFNXph8VjUN7\nCa0XHK/JrGFHYSM2+LcUTNhBLCAN5IfX53uBSn+kWFmzZwiYkzFrHwCNpgA9\nn8ibBCTD1bvqY9NOWYDAtl/osgDuRDjpsbCORdvXkk9Fm1N3VoAh+la7sTWA\nvHY0fk+mfAn6wHBFC8uSW4ylfbb81SpuARNF0K2hhZDrEv00SHbB6DIpTAi+\nNAiaSnqLitekWi6FOohntQRoR4tGCelja9izM3twxErI4voqDG700kQOn572\nwcU+zUWl9FMxkUioHE5h2xDZjrBzsXveB+QKP2Hj8jPduhSwJR+hLSEAUjx8\n0XAwhYUOyuREGjAERaCG6yBDD7WafG89d9FCCIclkpOhJUQ+376GfEzpCcda\n6mqKEpdKYiFZPx4l6PYmVHGdvm67pBDk3dz2C9SvhtSUQOLvMPoG1dnwWyE8\nn4DXWQRckJDQlDiyX4Ef4qZl1CvfNuihFmYGajx4Uji9MJywr1fgOgmU48OO\nCGPHea+MHPcFMnFESvyXVJWTTWZwsRfY0HRE3t5KLew5/QOmslTFRIvNPoPU\nIPrkOW+Loe1YYCB2EoIFpXvvZ/u/3SnLcNPD5yntYjZKiWfcDJxBV7Qfv/PU\nCdpRhpKxb+Ahjrx/Tdb5V7TyMhpN8R8Pt9N6gsU3G5PTVxJnxkLeRugY2vLx\nRWdz\r\n=O3oN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"896f1d3088b8a63ebeae9471175992a310cc10af","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-ee56d70-1589352647665_1589352705905_0.7135306399668906","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a5f43c8-1589353590846":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a5f43c8-1589353590846","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a5f43c8-1589353590846","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c94070402e83f98d1aa7c86a80f930febcefef0f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a5f43c8-1589353590846.tgz","fileCount":8,"integrity":"sha512-xGGAl+e7BTUcKwBaBrPVMQ6tKy8RWj97PhyNEsWg5Q+zX7QDYV+k25J4Dl9h8DKr/3gtz559Ray6m9gybBYs0A==","signatures":[{"sig":"MEUCIDcBF+Rp6t0BJQ3HaJHUgrMtHqRO9LhRgeVb6/XbbJJpAiEAj/5ADtHimMHKcSnxh7cVtaYAXDzg/v619LZ6IVsJ4/0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeu5y4CRA9TVsSAnZWagAAwPQQAIOg8N60dcCT8OmwDlK1\no4ImmKVIouE8jVP4WhxfU24oeO1r2pnTXHvMNU+9gKnYiuCZvSKzJww+nHz/\nTSvAlaPSjL5H8HqP37wrBSSM3DOt/FhdyB5cvLtKeQB09OHaX1p0rmZPfC9c\nUl+/VYgKPgD6q2xNag5orX4K9G47MYGzGkFuMaZJ5xrNvUAm4zyMTdCh0jbr\nNufRoGpahzeCefuMJqBKLxKW9xuc0SbiS+77eMuJMI+iZhxRwHqbrH1RJ8u6\ncmYLDjBvNIL1xfI8bZQLValAJSGK+ZoGUYmkQCUp77tj4gsykwIIrb1ug8ka\n/43GKCNYZ7uB9xcuqIH3sX6AtKDbfvaY1StTDF3tfafXROiAbPQp+d6BRK0z\nosyjjfkSfH0TWl7TNDqtBXN4fWy+rhD1ffMeFOrog41m6pK+X0+GQ6v0uhWL\nVxqmg+ECHMwBsuyugH4tMA7yzLfqQqBhFAHrzqW5Kyi1qCWOJWGWV4WGo9jp\n4uHDr+iinU5fNCpX4bYmAssa63boxbKjLVSVarryc8ZIV43Z3ED0NEHy/Ynb\nu6OkfpGbwEwdVSUq6BfqK2qEHsuot5ccSicnZ3jV8m5gxyV4pB2dXn9JKPCp\nZ4FMLCzJDj7YZZ4vK4WlT0aCDVwtYiXb2AXROJtiSR5qqbFtYQEHbq+v9xCp\ndwMl\r\n=YMfz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"56f455254189136e6c3a5acb0af80aa11918f626","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a5f43c8-1589353590846_1589353656188_0.2808372843357445","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-4993fa1-1589395986518":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-4993fa1-1589395986518","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-4993fa1-1589395986518","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5b28811502078c8487012d2176acb727a4dd1825","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-4993fa1-1589395986518.tgz","fileCount":8,"integrity":"sha512-IfpLa2dBu91Rv0HvbPcqUKyuAYTFQNiI5s+nDoMcUzLd1HOnJEu+V9IYqdpiRkopMmjvEiytg9oCgssLXVc+kQ==","signatures":[{"sig":"MEQCIHY+3/AYvekY/8zc6Bt9OLCguhrF1W8PcooD0peGaegfAiAG40s8Uqc7vt2NP/JmrHs5/Iww48EhS9jtLDw9y6hAsg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13950,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevEJyCRA9TVsSAnZWagAAqYYQAIuwLVwDs3dmvWmNaHs1\noYep5Dq6CeHvdoYUL0KcS3aJ9k1k7xOCL3JF9HQ++atNc1yFkBGjXasZRU5G\nDfpzodLmdXp/cr+oQ3FX9A3lwbsM438E9ZZdEVsEn1G8fEvwkWCJnycfJT2q\n0xGYaznRPcnaknJVCuwFyZqFu+RZaTvH80u88inNHVJ8/+3oHbsdRA9u92qa\nbiOGrC3XEQRF8E52NSh9IZF4qcYEUmuzqHv54JAHVcyBEYXUJbJSKibTz9g9\nMnEshMJLn2H1bbuK9DumgJ40oliHPkHYm/7RQNRmAQwMm8gw79UBwNhDj8L6\nOX/IpoDc4KJG+clFqX0Lm8n/n+gCHssLXGfZdYGy/WX7trg0ET2EonYfU7GG\nO7hHsIr7Dw8OQzqOPS5vi7X5jVvA2rgKDxI5NBewfXJ7qG6joUJO1URiDxY0\nQqnPiXd8D9F+72Oc2qkfmkDz6n9z60WZ/1Du7lTyEJDYRsHxsBxpyOfSfTiq\neDBqUBYaANCot+SsN06W6lPmTVYVNQoup263c2xEQo4syTZ4R7fGO2MUj+6M\nuS5KVrCUipKrvPiRxr2ZbAWSa1dvt6gAITQB46RdiLZyjjVXbpQBnHbL5rQL\nrBYjtUc0GcPgqsyLs3wPSPczvrdUWDzV9S+Tg02dMcAcuOGGJSI/ndtyCc0r\nl0g7\r\n=Z+TF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ddda4c7d88843abdbd4c09f5e6186261a0da9188","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-4993fa1-1589395986518_1589396081331_0.6968276228944015","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-615f6d2-1589411502969":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-615f6d2-1589411502969","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-615f6d2-1589411502969","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8974ecc59966737949e92e3f16cc84d838cdcdc4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-615f6d2-1589411502969.tgz","fileCount":8,"integrity":"sha512-GCHD1HNT4krgxIu7wAnNKMoENZyXU/YscZp4iBBs0j7j4ODZW7mFI5REgxzw/97kuUopJ/dhHpYGJCIz0P8e3A==","signatures":[{"sig":"MEYCIQCbqY93MTGWuMj79SqttumtxApjx/RfhowN6aGEKMoeTQIhALimNHxgznzu24LKNe2FVJFM+pxEK7/lmpSxqCuxszCN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevH7oCRA9TVsSAnZWagAAxHkP/RlMzvJ6l9GwYQs4Fmnc\nzWdjAVppSiY6Gl0vRVo7XDNCtNINI/1LhGQ5IygLH0cJrFJldVUkMmwleioh\nyGQRlku8sSvF7PF+Uxhys4GnAkdMbEbBWqXvuopWttXG7a9mnPeL3F4Feutg\n+YUHiraNfduak0hvPnTjRGdrse+6YQgm6iPEa97e+cdhYorwjO3X0Xufq7A3\nFD7OHVyZj1XGmQ+Qdyr+zDbqV/jSFhCNlcdRcJH2XaxGaZ0i+b4f/RYehFp/\nXndcEK9vEnoAvUy+z9Sn922/FVq3uk+CUuKk+BT9+AEnGUT89NRHoXMkT+cY\nYGJp1mAfxuzQFokPs+7KkjzEYhVZLwIqU6yVWe5HxihLwmsDIphlJgBQfaQR\nR5jaiH3zobQz4pAnHAP0AODmxJcPphaBHjcnhZ68cOikJQMV9688nwwPRCIB\nGSUdUdaRU2i/sk0rN4XUPQY4PbGMl+A9W7WjRXbnE0H/fX9cd4HQmbTUQ9uT\nCyBGzeDnh60yGEN9jOHPTToGbmDrLwm705oBIktYC2I93PSG8EOmEtNfX1s0\n8gKTSJpr2G240oAJEZwyIpY8iefamq0JrLTXspSWp8MCljEGuBzJHsgM21pQ\n+j71MM37bNvsU/wUHwJinNPmRFlh5kWTFf7Rf7YcpperOT2+vH+MnWwR8vdr\nb8+c\r\n=0Tda\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ac48a4c4b9d5b0ba55c950d34c9df5e826ee13dd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-615f6d2-1589411502969_1589411560110_0.2524744965736776","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-adf58ed-1589523511339":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-adf58ed-1589523511339","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-adf58ed-1589523511339","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b58d6833df0997f4c9484d6b950ed65ee97b7f80","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-adf58ed-1589523511339.tgz","fileCount":8,"integrity":"sha512-E97XjhoiK3t1XHwuGz6Vn6vZvwH1TpBVemucI/kQLnOqU9ZcfDdIS5a0m5amKwIrRSPo922ahqrryE7K95RT6Q==","signatures":[{"sig":"MEYCIQDdDfS4/557LUFE622XnlUDhJn15qYAtTBAf/aBVvMezgIhAP7L9v6easq9xjiQy1lhXoX3bTWfLvfxF1LpkR5BM3mV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevjSECRA9TVsSAnZWagAAYioP/2IHr9GDtRDPwUWysMMV\nlBtLDhWxsLVnVhBhvef9af7Rw0JqQ4vUkXbpP3cjIfh0R3wm+7FUUNRhBEEk\n975LLG6W21punCbUG9MsHq4GmAjDVF0/XyYr7qvF2v1F0iW54BQoN4dgDVXb\nhgPru2Oucb7D5+YMAs0AqVR4a277uEFbjLIbsHTVMDxquuHiu1ifC9FZZvO8\nt08MgcjOIIc/vMhhoBkQD0iov0HzsaHemaABA6ANwX+tgXvGR9QA89XnXHBd\neLfOKHOGFCRdtDV4vKvl2ug8nfFhQ0+ViKkUj99iYATELq5Af/JM5bbNul+r\nxn6B6Vu12221t8V+Ym5Es1Py9jv2eKkIZwo9F/uLbfXTc4LBfi93FcuWe01N\n7RcY7qAYE6Hs5NzUQYwe7zlO8ARPnVwkuf4GQq9WjNTrsyCrOKsTeoNpokSD\nilbflrJfEnIDemTNe0yP7kYUxYhcXAF/S+23Lq6QqXQaqXQu/r4iUpIvbJVs\nn8nosVnGEvNKg94yv8qFIGoF59d5cPdgpbqh0EaUPv/gHHC/xkKXsNxzlW0F\ntzG1rpjkkAH+jcBqmlqepkVzTLhgTdxfLesuGe62T+pT3y3a8MZcZ/blMP2X\nNM9Pf55WdzrGnSBp3sJYMO1ETRS/vnt8fnGbGyabW1he/ypdngkyNnIp9CqO\nH/uO\r\n=pZsZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b00172e993c9121faf6272797dd7f6c39be6c372","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-adf58ed-1589523511339_1589523587647_0.9261998761608936","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-80d3baa-1589687934188":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-80d3baa-1589687934188","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-80d3baa-1589687934188","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0fb35d9dc2733a6e82feed51e4a5580c3cb4bde7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-80d3baa-1589687934188.tgz","fileCount":8,"integrity":"sha512-nhkm5VsZ3wySDzDeoZGC9U+y5W6bSnYHLqYtwDUE0sLI2KKbGSnnKyu8AzsrWoUcsUzdT/ayydCf7laUsLZdjA==","signatures":[{"sig":"MEUCIFjUdr1bREf0lMJ0k/cZJTZcZqrRu+4aIoogFHzbeMeUAiEA6mCVTt05ZBUBM3gj2qOuIJhVJo4nSHqTaGUJBYEouIU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewLbUCRA9TVsSAnZWagAAztIP/0uJlYgecU4z/5FixdpU\nfYzz2Y98H3ARzE9+RnfdMkbCSxM1JDEaT4+tq8mGWjupK8CnHr7pzvClAJYa\nM7kkOggLNP6IzZ19BGNcrdBK5u4fpsGFI25C1pHuLPcnYzCEj4GdvCMFtcbe\nQIrplrq7PJJEUtG3/ZTsQCjiD4BCFt2/QBxJR4mfuk+VWFv6bdTg4uWdLn+z\nmvGpas1vjZoWd+DzzNqWmU9Fk9HJ/0klC5Pe8fKckmyD//4mBcdtDwqdX7sF\nNqnHYGTrMSFuyPmwvgedNT5SEa/QCOiA/nNHs7lq1Tv1nAOTon2bCcRX8c8z\nX1P9izFg49Jgc+/5bUea9NteYqHOMainkaVdlvbMUvYl2db+WiWE2ISeYeQt\neGmFCriNsyfdapaUKC6yYCkIHOYtk3ZZ68aGzud3Z+OD34r95q2L9Bju3xNV\nelgs0n7Xal7Ns1X/uqUTtJjKlIU5Xxk5TbBCPjUyWMMuLL01ojBwLzE4Wsal\n9hEcvitXBTUNY4MsXOfQI4MMrGgMbD8M2KlAl1wOI3zR9AB7rpbwD9oBcgJe\n73Hr4PK/iDa+rLbCpELf8MNsubqVU2ph1jTi7Jh6vHOlzVaI8NIxO3lgEfC2\nct/iOuB7OLGv5OMm2GZWXAoOX02izFjrGqFIpQRDxiF/d05sD+m1HVbKOl3O\nSMLD\r\n=3KTa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"40e3649e3f2826bd4ba604fac820a06af03fd066","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-80d3baa-1589687934188_1589688020039_0.7686296625079552","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-6f46f4a-1589842476806":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-6f46f4a-1589842476806","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-6f46f4a-1589842476806","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fc1459594f3b0636c50f9c87da8630de24540bc6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-6f46f4a-1589842476806.tgz","fileCount":8,"integrity":"sha512-pvEP7pW9IAm1w6vZR6X4yKdMyNjkXP1BFK9wZduUgKNZkeFyF2NlMZdAH0HSTSMVd0LGo1r5ER12d+0LL5OShw==","signatures":[{"sig":"MEUCIHjV7mR+nWTN8cEafePPWJjMAoblIzIkBWftIN1KQIlQAiEAmyl+vbu1n3mb1IIazcmBio6v9eBS53qlQu7q7SDBv8Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewxJgCRA9TVsSAnZWagAAiFIP/0y470DfDPpKnJicHYyX\nKPteZGoFnlCMhpedbwsUAHGdW5LLK/ECVU5YlbRvMDMXfoPPrFERgOp2/eIM\nwVEEwi/ZCKUJTl9cqlUzUUtJy/lNaAfJMfFhA+RgorzJ1uAG9L1tH3GYkrJ3\nAzQFDoF2D2w/ysIkWrKUjruAB4YDZn8hNtmh3qUgVNT3W3iB1HH4ATDyV35j\nwZP+WN9VvS87RTmcY18JxByk0qkkc2qBvr3h0kqlZuRH0XtjqKQaYhyZd21I\nzKx5+TAolzOgZCFVO6UyEMxwL7MFg0HFFEf28BaFQzmEW1OmT1OXTuPak63x\nYiOE2JmM3QPM4fPOGH9h5CX48S1AjwkKzvddreGtC4uHdynJSBRjX2Nz7t4t\nGAWHs1np8WkrPJFmhyUS64gUGwZe+gDjaro+p1hMIw/rNrE6R8RWuHyHYl/V\nizRggO+YYDITWq31kIXHiHsF8/3Y9qs2RopLU7UEq979ZzUmIGjBwHTP++/Y\n51W9iO4Za5es97W27C9b1OI900zcaLCaiMbfadxvImfeTQddN1DMg7XzoIk5\niXhNI5j6YiW9voWN+jZmlqz0WIj+euKLBJTjM+9dHQgnGuQ99wg8fw7fesq6\nfcqaChmiMZ4hm5TY3MUWA95IKGeu2UB8dfgH4YF5mbOO2ijbuWj4djvEdwXw\nsBrJ\r\n=LEyI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"97b29852aedca1f5404724f3ff4ee8440e86dfce","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-6f46f4a-1589842476806_1589842527813_0.3224214637773637","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-3b59d34-1589843950138":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-3b59d34-1589843950138","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-3b59d34-1589843950138","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b4a7c4b00323d31deab6548eb92797cb11c72a70","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-3b59d34-1589843950138.tgz","fileCount":8,"integrity":"sha512-Vf/aAcgzqCbvhzDE9G0bGIQVHtOMmjNZBS64BjAX0YPod2X4KHuvKLSIlezfNYlcmuG/exKd7qa4PU4XT0lobw==","signatures":[{"sig":"MEYCIQDTAKI5CySTc00puHY9O2wA++x8dYZLDl0Vi5xGRSQKMAIhAL4AzoQ9Sp9NdsMlnIlXN40OgiagCw2b9cGI+sjXytXq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJewxggCRA9TVsSAnZWagAAlW4P/2NsiNuVJaJjcDwMvHjQ\n0PrLKZLJkVn5+1AAiSotxYkiW7c+S+ErI8XyHmxtluvADFYaNZeNhQ3nZmK9\n29GBlmVbUQtrXPst8x0mpYzh5WtNHJgJVxz0QwUrT42FWPOHiJEa/7mEi/Ln\n6NOWIcPsMgzPYHIX/kmmPWvX/oykQjMrHLE5WiQB/ZuSzLHp1LgPRvY8oaaD\noz6keSOgOZYSAOL0c4wQ7uG7osnStMb+llGXRorNccEkbx+S0uj4Wmxod3uL\nv+/41qNXUy+Yo5hWwrsEL6zuKn1w9f9V31RJ2nF8tLc4ktAg2HexhKrp26qj\nYh9+84AMqZqrhD0hmnxNQv1j5umrXxVaqYVg3AEvNs8eptHywtzNLMmUEq33\nWyCV2tlyeeR8YqsUa0xTgwVFhf7dyo5ytrqwvWTXDz/h+3mNCXgQV4XEjb+E\nZkIWo/2eeSKmnF+vIhAOhLcEjwf6jhhTodKGmCBCB3gflwSfdTwiLjiYofTg\n+0Br1IkmYzKyiu6Co0mHn9NtYAylqYNh0X+3SyfBgzOFienqqVFV52vYq00t\nGVuUboTLcycwghQAn5kgcEgKQizsUf343ZK+doD6F9/H4fb+3in/pF3kNiIw\nY9ERb54gZ9/ZtBfFuTqk8JaKgmnXKm9Mv2JJPYF3UUwoyl0zYAgCrJCkVAAi\n1VJo\r\n=lpdB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"491d93fc76f73657c7a6ed2ccb338a84c58e5c06","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-3b59d34-1589843950138_1589843999566_0.26696642891171685","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-4cb1b65-1589870044852":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-4cb1b65-1589870044852","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-4cb1b65-1589870044852","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8f42a8758b895c5131dcd1992eaa73ed28c437af","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-4cb1b65-1589870044852.tgz","fileCount":8,"integrity":"sha512-06xZGoa6dSyNE6BtVs5LiIp5UoUleRD3tDvtDirXpmhS5FuAn19P4tkQ+KgP8EGFw+72174o4s8LjH29uDp6tg==","signatures":[{"sig":"MEQCIBCYLRZ8vdY62NzTqKYazcSdRVxEXHwvA/Hg+yOb4wQNAiBjxYkBmXCDjI3Fmrt4bQbbXiUOfMcC7II/Vnyc958M+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJew34WCRA9TVsSAnZWagAAjg0QAICM42iabFcDkTy/GJV/\n30tItDWHSwgjqgHcBOyLw0IY7BH/CyvzH5ijJfaia4FAS2XjIXRmvaZqlgEO\nUAy6iW9zbCrofMj8wHaNqF6BmEBraE7c3gY8ZcptI8Oz2NHj94A0z2wI4ljS\ngiVGb6QAiSMti6mJuyOZACh7DcJ+pO2FN2U5MV+j1tJBm8fBJGLr8NjeDhPb\npIBl+HpeR5UbMiJTXovlTitdY8aE4IjousSqICTmKx+n2u45FH61ekQrg5hd\nKVHI/VFJpp5r2Ev6KxJwwoLeq1GuJHxBkkK7dE0ReGa3FN7kIgKHsUnAeUe/\n7jlxjJZPM3289VM1u+nlRxhNdvfBbZdhsGUt82I5TzHdq8t/lZQT1lNomjyR\nebSWiB78JTdpURNOEDutUYJvOpfyp3HfRXfBXrwbJfGHm7VD/Je7dwqt66OJ\n4RGQ3bxSYNB+Rwef3jk22PtMtd1cOD88zpBynN9mo6TtwN3ksnpz8b9rr3tU\n21LlRGRt0XKsuGQq0Kbygio5NFnKOpATRx3FAvKrk9SdWdc27lDkqn2Fk4Qn\n0ajCoXVdY8v+XpsiwnLF23FerRL3fUB6LlLLSaIQOAAkrPbFpALDJLmHBlhW\nvNp99XAMxRVuvBz8+Wawk/wRaWRSPkEgMak15k4yJhLJaPaPAO6QLlGCFgmj\nBywI\r\n=85rn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a0efe8a56a8c0cb9a5fad326fa96b477c163e78b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-4cb1b65-1589870044852_1589870101412_0.05166372647704187","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-e72c8bc-1589922341260":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-e72c8bc-1589922341260","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-e72c8bc-1589922341260","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2050f20be6aef32cdfcff770a5e92290beb3214a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-e72c8bc-1589922341260.tgz","fileCount":8,"integrity":"sha512-j8hbTL+kVsKREZMkNeKgxDHJVWpuDQ6DAVi7/2lse5oWDxD4yQsphXSDIK4k4Owx637XhqgKWcBpoW+BVv8LVg==","signatures":[{"sig":"MEUCIQDfxKv2jWa2zG8LCfN59g8BTejltriqKCn+545qpxXULgIgVklZPTLEP0Th8vWdZGedaqq9EroMDpIST/xc9XB06OU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexEpjCRA9TVsSAnZWagAAft4P/1D0JCyqB4nHNQPmtaFU\ntH8iFF5/hFefvUphVMDl9ohitH6ZFOm/6fj9RBP7grYugNt8zQnUDdgDkLLK\nbus6OCVAGky+66ET8Mn4xb87IMMEigiiTgvhk94CLS8lJ0/fOYcfcQeElM8a\nGw9R8wyfaQ76o9k6RYY0BM87/XBCWWGKpPDwavIwHYOF4lEmyjar4/b+kRkC\n8gV95UDwJ2JXBftlnuUX5ZpFwhwKJW+lkvnIk1Jddsu1MOtQdYqcbkUv91u3\nSMym8LzYDu9myMKO5lJ3bSiSSI75Au7oHIMCItl4Mmw9ZbFkPIlLgqLjSCxu\nSJ4zU7+ypycRPDS+Ha8YLTKaAcasm9mMPp7SBPpSzN4DKjmcW2o+WY20i3UY\nxE9ii7mhg40PVdozaQFhkAW8sQMnmvv+CxhETqctKgHDNaOSZL9Kbb06z5ne\nzOMJD58Lf+xoo1LgbpY3uvTHrriqXksf7Y9QvBCA6XUsLlffC6lMnBKdF/U3\nWxphWQ+O7W+PVoVzqXAaOs1zCJ3PHsaQtHVRm4lRcPIE/im7HvPh40B+bBlE\nssNwx68wcJsbw9TX5UddqBt1n2EEPQ95hVOQ5JtbBvdK/WI6yV2XzJnesyDq\nS2y1GJo4KbVdNJmKesqTasvw4OZYi9VO7BjDZec3O8jOJJQwgxkadFYcmIA5\nU1kf\r\n=z1bi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c65c8282876d4916d24ff84cfcbd50a12d158522","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-e72c8bc-1589922341260_1589922403078_0.3466822710867632","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-8590bed-1589956040845":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-8590bed-1589956040845","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-8590bed-1589956040845","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b5d0ba86df964fb622ebbd25722d736b327bede6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-8590bed-1589956040845.tgz","fileCount":8,"integrity":"sha512-bo6zTkZqID7933Vc/hGA50aFRrEBKtnvkrDJX8WYDkvorvOhzkcB59IAA/vP6H2VGWKRfSyG32fH5kA4NHgcqQ==","signatures":[{"sig":"MEQCIENu42l/LjX8pVgH801jldowb7Wg78uJTP3WH/7Si0McAiAD+ZmXTQLZbDlj2NY3YLj54oGWH13EpYeZB3oG2HjPbA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexM4HCRA9TVsSAnZWagAAiN0P/1IoGWdS+bNCtpNCzjb6\nabEkHpXlkT6//z9f5rcVl8gUjdQ0Pc7RKAfpRQy8snzc2FfNc7cO80VbuZpZ\niqd3aPFlDFjb9B0T7H3GiIjP7aYFp23spOEWO7sDisBmdd/WcOXoOHBxa3T2\nPqvIs8uKF6iieuQCrDbpB8rk1w72GUMnlO+R0ufopPT3iDrAloyPzTWC6G9M\n868Ldn3UxuaAv9Wz5+uQqQa/CX7if2dqmCdwofLBnX5v3k7AyLibEpTzGpAN\nx5Ud2kUBJQno4tr/HRnxYxhH8amv0L8Nf5r1ATtyaMU/3HM2nQFvrjUYfxoX\nZzUR/MD9tsLMLl+rvSW+92iwvCjGLflO2B9+CXOzjtAEYjHD/XoAwLhH6oz5\n/XddeVb7SGLlTyEcCTSCuXpL2eggBc9cqLb0Qf8oB39nYSKtWx+3ufM62YJf\nQOKU2iv/5P9YUQyeL74SZH5TLXfHMEaBhH3KAlcG62F+fSCwUrGy8zHe2xYh\ncSB7qHOwPufe2BXHjGJdqp9lMb5+k9bCyCKdHokDu2DaWbHy37dSfgxHGkUj\nculc7GYMyJzZfoxAw1moUaWCFRB3ANniig5byZtnKhSw2svcPY3vktRVX/Gq\nptdBNpNoD9bgg1+eVV0oHhCcqc5fTSFlIPwDxqHIGOE8zxwL96PejRDVh2qI\n4sGW\r\n=Kmh2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"20215001b47f253c615ec8c9c0b63c09dd482b73","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-8590bed-1589956040845_1589956102255_0.08433942141825157","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-0f5d3ef-1589958814757":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-0f5d3ef-1589958814757","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-0f5d3ef-1589958814757","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3f8aed8dfc56b4e40b80168f211c7e29eaf18653","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-0f5d3ef-1589958814757.tgz","fileCount":8,"integrity":"sha512-ajNBnoByLnFaC5H/NfMiOBuUQeP+CPx1dUskuE3bov8HhckSaq8YEvdn0js3C9IekliyZ6MWJ5ZJCPdFLYLU3Q==","signatures":[{"sig":"MEUCIDx7M+ckcXpp1zs71lcMjchwOKQ9bjfLS2erWavPz24TAiEA2B0xjigmdbmtRDmMA4GTG4fiukX2Dh8mErcoAVsuBGQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexNjUCRA9TVsSAnZWagAATdAQAJUXvEqMV+g4a1dDfLg9\nWhuTlIUFPY9mOzos2yU+qTrNy0j8Fj2CjUSnrhoSB2CY/0SG7Y0enaLZbL8L\nTnjn+JSVWAXaXuP8KPUXo4yQ+Ig7gvS+eN1f6K2v9GaWExHNE2ouAGiMUADQ\nBfsdDO1QhUVNjLwng3Ula6f7n9pWWK03MoEFQ/P/HO+K/fXvJiDpVvtiLPU2\nKi6cij8erf1HH5ZPkNHRpgSfnNfwzaltfgq52dBJRuP+mjj/3SevDl4afzI/\ncuc6nFUu4AOcZRZNBQwNMX2iATRReZXHu6jzco4P84DyGqT3HcuSGxHsguuk\nvArGC5riMS069UXebTTaMZ+n/DvHDlYmiLg81h9uxNLZC1mIncFxdma5zrEQ\n7awG/l/DJNHszXhwY/ekRggdTkusVku/uYHoln+pmkFrpBj21rPQFy0OA6am\nt6xWxyLPf8zE1L1AxU4NiUcXgGviKCE8XyI/CLWtvsN9sV1vEaShGcYIdqpf\n8YrRlohGu3+lOzmWv1R8rzOT3dJRH7cyUzzdnbMhREldcvW1LgiocVThzfh2\nKrAd5L5b2gvBTZ0f5eYJPzdB0NENz7+u6/7Ys4/ZVNaazGskgXH4QJEMaVcI\nvEUcmVJL5sOzCrdFeVwF8lVKikFFcqEwuTTdxYiftT4Lm9bGo/imSV/oVZ25\nSGtR\r\n=M0k7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bd422eb98a5c4282bd8b94bed91e2f958832f9e7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-0f5d3ef-1589958814757_1589958868356_0.4163171890956503","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-6bf94e0-1590127697800":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-6bf94e0-1590127697800","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-6bf94e0-1590127697800","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f11a513194f30db7b0cde620cd83df1bad766237","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-6bf94e0-1590127697800.tgz","fileCount":8,"integrity":"sha512-vKeBRtMP3msul8tqX6hcZQOZnUZRiabHfilNZpV7AZiEBuDlmOfX38m9qAN5P0rz/46gAfFrbZCZW/rubu249g==","signatures":[{"sig":"MEUCIQDn1bWuXpxpXEfvYhOTX+GQJgtfHYMNdtbNnMPVtffbZQIgeYpp9cZeLm/NXRh+gHNkBJBWMZazz4YgadC7xjN2M68=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJex2yMCRA9TVsSAnZWagAAO+sP/0OY5rvkc3N6ZNluM6IC\nvd6Mc5OAlLJnTIkl9eYIFA+UHDnBAZq2mZOFNxVBxujtE0NErywTLu3tfzU5\nIRhRwnC8Vy/1ta4ptgEoBJQcWAAl4UiJNcV9gjUZhkeuHPi9lO0qChp3Jg5I\nASZOsiqPCzV8XCN1UG9BwXDZPVUIGi95Zg2Z3ana4pgs/EsUmNT4UwLSvSgt\n4oa8faCLhsT0+Io1ZtwMbJCSpWSu5nQmMxEslWo9uB+oNJvID/lKAb0+mC8H\nr2gzZ+hdcesdfT5PjDjIrQet3vAAyUe/KbSbboKu2LYUdxSHGOmWi7/gsvZp\nxFN8Gm5o2hLqPKIO2tM1w56ckxuUsv7Rpn74HhGLGI5fOpNQrNE42LEaYpGK\nO1TuhCVHwPvk/pPGLV+RbE2CrJd/xs1Ewb0LESephOg6lNttrC4xyNInQcG7\nx7srOUzw8TPaXMSeXixnr8PyeDQOV+MImgRdRl2BltptU8GNo6337h+KCKSI\nfPGbJwbMcLp2LrVejrZHUWZDJ8/AWnj1IGFQXIRYal+0q4VoiXmsGyP0RLdu\nB6YSfFopfIMvgSnG1dH4TkyVAuzRS6nd1WX43xLCzLBEX4UhCIKpiaB7KIF/\n5Zkb+bECgbxp1eBKAcOU54JdPLrNC0QQX/OTN8h5ECnAC0Fuli+I1Bqr9gBZ\ngqwE\r\n=Oj9q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e2a661d9958e8cab34597a2c38d0d5e70ef5eeb4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-6bf94e0-1590127697800_1590127756239_0.08838516846868161","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-eee8d3b-1590213645497":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-eee8d3b-1590213645497","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-eee8d3b-1590213645497","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f97789bf115fedc966fe382225603b4b2a24d517","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-eee8d3b-1590213645497.tgz","fileCount":8,"integrity":"sha512-tsHDKA1nXlPyeWZ1SF1fsMk3WYAlxKqRhRdKBt12UoyiNhe2CB0y0bl5rfWoioCXidGtSl4cHVkK9N6pauhbmA==","signatures":[{"sig":"MEUCIQCYtfszfdgByRrr27anQ7McIqFG+p66Ee5jnC4h6QQqYQIgJEnh4Xt1NwXcS/JCXB0va2GIGs/AzDqjK7ZYU27arb8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyLxOCRA9TVsSAnZWagAATCUP/1LVe9+HjIiYriHSpHD5\nyat/eCEgzMOWaAqlPxfOgRsAPCi0FaZGxIOqrxzanixIsFSREyku2eq2BiPh\njuTpBvnLUWW3G5MLs+vx9zBnZXZgfSyLp8uLYScNscxZ8N19Jz5zITU/00y7\nMOb/5YMT27F1+ydEIdjt62XyCNckq/YCd8JJulOUOO6T9aCGJR7ZRbkbWfkj\ne5WSBEoDDiV7M/5hcDv/q0wBxoDaLeRMSGAfIKpKzMVCN+fEkE1ILW8eW1Ri\nBN63a24sLMxtc76kptSJBIMUz2X5X4dDQl0tuunPgmNqvKi9RPdv5um5VeG0\nLmAX9GL/BUWbSVAvWBn+7/UdMMAFx198dkoSZR3998Iy5GY4/DQwUGg+FkGW\np5IrrH4WbY+n7bJgThIgmTtabN9c8kUms+DgpKoBuUoCvs2IEipUC4B0WNqb\nOWpjLu3KX6Lpt2pCuuKGOzHqBTaW2G9xwjP6x7S6S6RsT9ZxOdWE7y9Ly4XL\n/LU8IMrIyiZvSDWIYM8yhF1ERgCVjtRxB2A/GCPQ6L5fEsZVqdNX6mRPB5ck\nzWgeklfbsSGDD+H2fTVgnbDaJlu4c1oMdVoR8/DBDff6tEgSp0BUsRx5wmil\nqWRMH+gyKow5m6gROZaJQCxCdUa5kVFieQBw6+NrXF52nS2t2cPy6tbDVsYM\nBnXL\r\n=Z65z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"731fb950de92ff3036d79b726c3dddf6ff3e6947","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-eee8d3b-1590213645497_1590213709604_0.06918277035093401","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-a8f684e-1590228899568":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-a8f684e-1590228899568","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-a8f684e-1590228899568","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a8612af31a2bc94f35b78e811781d7dfb807b7af","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-a8f684e-1590228899568.tgz","fileCount":8,"integrity":"sha512-FTOcRnMOX28wLKpDbyqsDlbwNP0oO6tKnnHcRmCwV8nY6zVTagE/EcYIKdw9g8Y0++meKbGupjS01P7ZayMKgA==","signatures":[{"sig":"MEUCIDif1d9nyiOavurS9CC6+yzykdfawPbx89FX6b78rCJaAiEA34aJw8wzXJXB/loJV/gmxYCGIovqcqpm+yA02gM2t50=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyPfiCRA9TVsSAnZWagAAi6gP/Rh0yRxp/nQNyUBy3o2K\nwV267CkWpnx52iLiN3G9Dbz9OCkZN++LqATBVm+ERRyLiO3X9XxuaM3U6ugx\nN6/Efiblygs+1xha13k6TCjQvyfKetFGpjcK7wPxZarwI8WgzAWO4o3IHYXl\nXzN0d204c+ry/Uc3h8dxWRJ1cS8ykBZXKO7FzA+c/yb3xuPkCehjk3f36GeE\nHPwCLTxxrFocgBdFduZpaiYopPlyKECgR345h/ErJurcYjQF6OAp/4lM4Exh\n1BGpqxqHlaiGyhMHPhmweYkZn74JUmEP+MF487w2J9A6i3RbB2kUzR34vSTZ\n/cPjrZcA3OrUcWreBfly9jJHGT3c/wsSzBGZZ1fiT3g7cPINlQKNnRzAC6p3\n8urhI3Lv60DeQ9aQo/JRU0EiS7Uu5rS4bchuoEio9/WM7+sy7u8ltJbtlSHw\n20Ixs9GXz4kQudRpG9+FWtEX3Q7St7FXW/ATKzb95QSjlfYLvyKcKB1VWuBo\nid4c254KMh8kWy5Zhie8AW8uQ8XeJj1DyNwufv/5bhjjv31ycPgRFR5oF/I1\nQHACHwCUZims9YAme3xYrGPMBVOc9cjSBnEq/oPs6yIP+xIGLjQjB8JlXUcG\n5CHoqiYZWiAoWGCrugYPpXMo1TlKDIqapQdctEMrzQ7egxVN42jBW/3UchP9\nUH8B\r\n=rAKw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"85673e1441e676f3234cef304e8da2fcc7dbe826","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-a8f684e-1590228899568_1590228961698_0.7123577027865415","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-d887954-1590232693016":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-d887954-1590232693016","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-d887954-1590232693016","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"86151692b5fcff35a6071e8f13717a3021fb7595","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-d887954-1590232693016.tgz","fileCount":8,"integrity":"sha512-/GDBOPpR3UNpJfq4ATKT1YprLIM1sAtcjSYayQVN6KQQop/fhE3Z5vhuQetwQiQUgYseSKjhETDzC1wQPenKJQ==","signatures":[{"sig":"MEUCID8rjJMEaqu/DSS2azY/z3lubzsDQ7tnv0aAeB76c50VAiEA6y82Kal80QGQNQuFoMk9j7lnXsOJUCYwjkMC2ZWsPPA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyQa8CRA9TVsSAnZWagAAHpQP/i8P2MOrceOBbJVMnzpb\nbYPTZ1vgJ22NG0P4jfxa/7IAd/+grB7yl9WMvhM3jsSSiV4vXGeh1MwuFgLP\nJcW2dc27h8PZknIaH1Aa1frzvF1sZtbgYFk3Top9nusXjXmNn6rxJDiugIh4\ng3v3MhoLFQztBqJzAlJ/2obq5LLrWXsGtqJb2Jn2bID7CNywuOtD6NKHT2W2\nAMAguAho+ukCf4IEVtprYDrZxJpVTYHMaRcxDns1s+CbZRBr+H5eLgeKvjQd\nwZEfAZqZsiBFscddoG8mkqdTM4S2ayJEJc9+c9M6hvcctnAvi+aITsux5IJv\nIB8hQgn3P7iwDyREG/Esa3kULg7SXUaL/zDL+/ZiXWnuyFiB6IyHviahRYj6\nomMB6PNZTURsDUo/rSgmN6KBHHzTD41XRQk6sj/gvDN6vWtZt01aZK6j5703\ndpcDicgD3CM+6B1SXe+Vpl08GcXAVzsylRYJsTTPuBGUYF27DaPxeJzNpuka\nYI/BTRcH5yPMzp7MyCuVjYqumRmRHBxky1BS1OzcAuDJXq/JCd0oU6/jDo1g\n9WI2UoKb1/Xl0HOi8DtdeFDnV+DTlOLmMUM2hcNWK+YLQrYMLokZ+CjTB4ec\nOvuaf4Irxih/xIUGusepUaJNZIDhB/jPU4LqKVOCGl79Iu8jiruWXkGulMMj\nQPtQ\r\n=TOOQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8f7f0fa1066b31ea57586fad2e9a802a6f19908b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-d887954-1590232693016_1590232764113_0.9889307807621694","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-3de3e1c-1590302819712":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-3de3e1c-1590302819712","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-3de3e1c-1590302819712","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"443ec8ea7c030441426f27bcbb65d2223fa03271","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-3de3e1c-1590302819712.tgz","fileCount":8,"integrity":"sha512-xtPrmEmu9XnQUvno3YJiKv3QJCcr2HOt91MDuZFhQ2HO7odxuZcQDdPHcnsNtJNKQNpmMLf5pcwQsXBHspHdkA==","signatures":[{"sig":"MEUCIEALXGHWwmsIksU7tVCTUWL0cyE2G0YkvRW6xPsFEB4PAiEAvAg8cdj0qT3x32nNWX7m3aCsJ/VC20Qi5CW2Qlkhi80=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyhiiCRA9TVsSAnZWagAAk4AQAJJvtj//fYvhqGFgQsY9\nXVj3nsOvDNSwZ2LpVZiSkFYfpHMMlHxV/xZKdLjxm+RKritZnt2xllfX5Oia\nUAw5yTEyspN0lzoLk975TfBwFKbv+tsE2UqBZmSFK2uucyqSxplPQe01o4ZG\nnEGTMwUPhuKcRBr6YZW7pUcUf506NKxuo1i02fp5AK2ZYf9eRbuqY0NbLSEs\nlh8FH4lTTrN7bGfZJaOM4EO84ZcE4IEFE+nXbNZEiQIaQg2G6MQUgQOHtull\nIzKbu3/WRzU1kaCQUARGEvXkRv+TpflGuKGqmDF5Shl0UcpMR/1qrXLkNx/q\niv147Wvz64+bTye3dqdXUw8DwPeHWdS3pqMz6oNMfwWuTkXcjMRz9ZKfVNK3\nBlUuWoK7WMq1QTYXnq3h4hHCD+i3Hsvq35Ov9L0sjiQNOxWb1tHIdL5RzzVa\nDg1z6sepmctecG49Acb9LYAR9Z25wSuUeXjO/cid/G83/1x7c4+9l+rSIiwk\nP7+J3vP+s2t3ZwgNEWoBFiRel1ZV2hA31+qr4JGejM4UWmrOOc2HfEJIMcbK\n/Ckb/WxHSx3/R3lilK618DsDGF2FoUPh+lDoCArYWaLFA5q0pHyTzvJeCIVa\nRFsTe58K7W9LzGLriPdxHzR59CILpIXxaVftGu0blmd9bwsrdrbsjBuWhE7S\nP11W\r\n=/Hzx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d0b44521446da2c0e79b104376bd641f16efde99","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-3de3e1c-1590302819712_1590302881728_0.8677264259196993","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-6866f6f-1590358852675":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-6866f6f-1590358852675","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-6866f6f-1590358852675","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"42d40bc2b693c4e891983e7794cd0e302982e285","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-6866f6f-1590358852675.tgz","fileCount":8,"integrity":"sha512-ElJhG3uf0GeWSz+8ZFnLtpixc93h0JKTZUwTahsuAms6RtGz8y3DLBEUXP/CjoQx9F/Xz2C79BU0HDRgqIbaLw==","signatures":[{"sig":"MEQCICbrSlMRJXlrUXDj3+VdiryuGMwn4fJ5bXCPSuCrbX0xAiBWvbN8lUVB1cp80aPmwNIRxs0XCGcwlL5YwlW5sTfuXA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13949,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeyvOKCRA9TVsSAnZWagAA49AP/3W8AkxxpPd2ZHJcsSSV\nGXgAHLNSHsJ/7HlkZ4qyQ81o/tcNbYnRqlHZFXIoMx+eGkWbCdGx6TQemGg3\nuAz+4Q7hRMNaZ9MiEjGjTbw5Mo7z21YBz9roL9Aqf1GsZNe5q6hvFhbWebxP\nkmuJYUCSTD8Hf3BWvJRgCeZBNu72MjympvmxyiPUzkQ/pLJyWifXp7K9j/Y5\nV7gWD6WzJQe6sn2d6KTX0quZ8seuQaqK8ovN7Drz3u6MfqNVZ8lrB8QGRK98\nzfqRhJoEcVZFpOGlULBmJ/obhMSlJWGu9fbc0MCxFal28pqHXBLPXchtFlSc\n55hsLQNe9DgGrz42G1QgTpWcu0sQvYKpr2QzSAjf50GogRYsqyOd54At0V6a\n8rBbN4llVae8VsSgBUWatpaG/4lsXBULCJJZz70J8z9fjavdI1WB4h8u1CpQ\np7hOb2UZtcOA8CEtHHYqZcBYOpK1t6EvpvtE/4ZfPSw57EnDgcctYO6JgSoi\nURt8bIrXBe+UIkjaSDTh4//JcrwbaBJMwZIJCZYTft8hSDE9m8h6xfvkCdCO\nvXc1sAMl1LMfEsxK0Ujjf6M+J+GV4MzHHioTV8BuUu6rbFX3wkGDmkShrqzW\nbDKdYYoHhm0r8PxRJVLW1Z3HglhGmMA9AAPYt8VzB2ouxCdTKnH2OC/chO5e\n+zR0\r\n=rfmH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"092b8bfb5dc1cb3bbdbfaabc0d73e5a0a67f7346","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-6866f6f-1590358852675_1590358921854_0.04438749231930372","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-dddd665-1590388038222":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-dddd665-1590388038222","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-dddd665-1590388038222","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"152361c78a4bea1b879138fd162a7531d8903cf9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-dddd665-1590388038222.tgz","fileCount":8,"integrity":"sha512-u8RdL5FfuqQUzkUifTVOgVlm5yz4Z1XJqHue0uXO6KW6QwDPKpgAjeiCoWIpNCuXHVspVn5eGhCEnco25+wNpg==","signatures":[{"sig":"MEQCIF6eVL6QpH/bxbQ0eQn4MOc8LH0d/fT1sjY0NobdEQm4AiAyBRhc4b2tyuuK+0todg4/WYf+3HeiAV0OLceuC+3QVw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14157,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJey2V7CRA9TVsSAnZWagAA1dkQAJGfKdTmh8HbmxrnBz6x\n8o+szarRwZCnOjpXx6ByWcOQeIm9Yq02mooGrRHWfl2mkAbXxbQ7PqehZ8gN\nX8pVj4uPUz6YSJI8gMWKULWcakLJE+fH0/FdNlySLWIkEVb/s7xHS0aLXr3a\nz+MGrkCsSrT+lYsO36WyyVSX7GkV6jVe7+AEfUPKbYE+ZtCnOlEt8K7HJ/q2\n0qBFSpRao8uhmsCBhj8Jf8AVMnDDuPdRy6qxws4ShI/o4z9I/rMyOMIDa++r\nnL6U4c+jjD/qglDwywyemBVwtpoA2EAKGl8rkuM3+qQzIC9N+nGCFq0EkPmJ\ntGD/RVF0nA4j+HhdlCEtPJ+GVhlUHS7CTym7at12HvWwKODTPr3QrwNArx96\nxKnvEXs/aa1uFNPRYH6eKOLkFnAzZQ+W72OH+/BRqJ1GdWGvQ6DvZ3JPMDbw\nLl48nKh63ENX22T0qV0W3UvumEo5tT7ZdznqPdISqUcsMGPWqjMxrtaCCqMt\nW9gWA2FHg5xlelOHihN0W77qLcLp0aLK+xFZ+/faR46btiwPnmCcqB/syb/9\nLpLKt5mo6mf4eBsQkiaIMmAxNGKn7IgASKgq8vtqkwN76zaQIqkrbiIoDiSO\nXnogc4auPBIRl5KTRYNxmTsEBWAm2aRTxJrynmQUWalSTe/2DkzW/5gPwm0v\nf0GA\r\n=mYTV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4fae686d67acb6a36a814fedb576d39a40d7e7f8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-dddd665-1590388038222_1590388091407_0.21256475312358347","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-932ef46-1590388249417":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-932ef46-1590388249417","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-932ef46-1590388249417","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fdcf9fb1b3219e6d3fc106ab56b7abcffda9782b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-932ef46-1590388249417.tgz","fileCount":8,"integrity":"sha512-CKmCkkBuUpq+FlxNFo0pmI7UCccEdy7oNy5V9B7yugKD9YnakTryOUsdBJkQ3H9h0fFMwmLFgQyQVRHacqZ6yQ==","signatures":[{"sig":"MEUCIQDQaXVVxblb1+CL5WQ7ZLyT09YV/+Kcx3So/Naw3Ir17QIgGvdYOLJ11Gqpa5EEEpsATWHwfXtUaYdeLLpdV1r6LBU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14147,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJey2adCRA9TVsSAnZWagAAJFoP/jdH1jV5uQD8RrJOb5VC\nJTTVzb0QUtligGn38DKUQLlmy+Gf83iFxVlrcHPHlwDURCuKc3F+N5Edk4pt\nrRLWZU1ptADsdP0cTo87n8U4wng2uak0lSz4IPZytQX9W2dizVaNpPn6ZJ10\nsyHXEWwyBCulxS9bJS7GX1Jc75FZ6Xc8PuxnYXLpp2J8v2T1n+9V1l0tNSDY\nggGLTYmvagHecBH146VLEUJsDn66knlXoF6BdvmtrJLSDNd7bKNn1Lfj2esq\nO/rrFOD5NqUKCrPWom34+I84Qx1jxebnG77H8NyOvVpoZ12UfSNSePbs3ruP\ngZmlA16Z3Ku2GTfQIx02crWx4kRsMoL85bYxz3dW3GWM9i+4nUYTTYWMg7Qi\nspBGZFrocxDkRWXhsXTqT3yjcmWzFMqfRAG/QoshktxFCGDrshfE+DF+LGRM\nXC066mvVf151vfS+I9Hc1j43bicpwm9QYi3Cd4AIkyKH2jJhDTDVXQp1YvKj\nUQDjckjiQMO0pW12LNPlKhbFMsFY14p+CH3xpD1mdk8bWJ1Rf/loaS7PbXGl\n9A6hnLIFcsA5Hmwv+gARlEQsxOBf6Jf2KGdQfXnG27XY7CnSD2+JS91E8pxw\nRF3epoX7Mhmcu9j6Arjll1eWgG8YDqlShmdSf4jgxjzgAIRuMISRsfiuSYx2\n4roR\r\n=D3Da\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2b2bfc814dd268e963d6e07de304b02e82bf8c81","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-932ef46-1590388249417_1590388380437_0.47074394874839465","host":"s3://npm-registry-packages"}},"1.0.2-beta.5-canary-280615b-1590477704162":{"name":"@iadvize-oss/opaque-type","version":"1.0.2-beta.5-canary-280615b-1590477704162","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.0.2-beta.5-canary-280615b-1590477704162","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7e622fe54cfb256d69d40e8daebfc965691e15c9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.0.2-beta.5-canary-280615b-1590477704162.tgz","fileCount":8,"integrity":"sha512-Ilamv32OXMOly3R4D5EGQOxMMn+BDwinVT1vhmAZLcXP3A2gTItXKyht0bhqs3YYFNor6EzliqF4H0oNp8Lp7w==","signatures":[{"sig":"MEUCIGU+uuXBHmrB/gf/Hl/V4gXeaSO0uJdCy12NRcf7XTq7AiEAnnU0+q+57YP2ygbJuay66D3gnQok8ncRQYTx90UW6TY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14046,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezMO+CRA9TVsSAnZWagAACNYP/AnHzotJIIjmlKQ2S+z6\nUXr70UzrWNfhF+dKTCiWqqtbzymMz7zRFNdH5LbKnE/mSbNgt5ilKD6hUQh1\n8fDSbT+shpP54NM5/D9tVHvHXku4ln+F8YhHvOb1lWFgZ8vIYqNuKzBtIkpZ\nK1Da8tzvcRXDb8bhuXgvWECdGu+ljhXqvyBrl2IxDGgN+PGjspf3aWjX/Obn\nvaxMO0GreiFDO15yOUMeu2Ibwp1xpz8syiP03MPff7xE+Nhpla4f/u4MtMn7\nxz+FKUoidxi9ezV8NaU7xp9ADNR0GYkgPRZBOoD77oWoyNSLmo2gv/9VMYRk\nF2tsezX7R4bOcVDTJ5pqNxEx8AF+jyrTf0g+F3soOZfZJRo/ZxpdnKwkxa7a\neLIOokmFVaooXl0T0zU5morQEvVrtWATrvH5mSBxp6qNcUAcXP+A+wjmCXlR\nYlvgIf1aG2SeJT3uBpc/EjkDUvJcsqdcu4eHqPDXJsX4DDvfzMMVMAGz8aqo\nZvi8gmsOwGEP4dItEWNFQefE5M/OWAsxlEUoJ9SU4IYqtl2CMMnFmkZwquUF\nCW6kMjktuSrWmlOh6kmVUFTkMjTQlFVuEJl1+ue3stDT9QzLP2yzPGBFml9T\nr4Uok50HMeXS423vXSJ33rMN2TMN63gVe2fRii2SLan4aA+/UZisWXmku+LM\n9R9u\r\n=krn6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"09ab8c56313b9a54fc4330e52abe865529625d1e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.0.2-beta.5-canary-280615b-1590477704162_1590477757855_0.48174835134116534","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@iadvize-oss/opaque-type","version":"1.1.0","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9c1a2f9a9c6681c075a26b8e7a23a33c4445d0fc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0.tgz","fileCount":8,"integrity":"sha512-kOacjeaRuzt0sSme/EhrWt5asf/u8dLQvbVTtg8N0yBslQ+Og2TEVlRHwzhGxvq6GkAdPFf3lYR4YWMgfYLcAg==","signatures":[{"sig":"MEUCIQDs7rHwhB9DJPnnOghJwFLXEeuCWDPs/6/d3HrYVpuKlwIgHF+HSFbNMLjsQtWbsz8mmmUNO8rt5EGdFRapJodoiNY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14109,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezMRaCRA9TVsSAnZWagAAi2AP/A0I+4SW86cVqj/erTiv\nm8iby43LbzG0azQF4zYIb3BnV03gBM1etR4RvoxFXecZMe/c9mNVZvk/svbl\nlr5MXjhTZJ0CPyVPKYGppqt0B4qYidhpbDYdFEaHb89ZyBZC72j+xzcUYd5g\nApQobXWAFjb+37Wz9Co/aIWLNX2+eFS5R29/C0gHTKeg9gz5/i6zh8e3OWuY\nqfwgR/19d6Or+vJgE32H2ebpyCQX26lIZrItiwBAIIQ2x3L6uyEUuO5EzdMC\n7cQLBlkCYvq5JgoeSUdqcpWLNPxCXjPKeoFOeySSb4vioRs/0+g2Ip3QWyLR\nctXhhhF3EV8gV8DWpPn7dg6Uca304jRK3yNfJs2rIuftAxY6jRIq3Sb1In+i\nJMhfqfWmIfz9MyB60/4WhiLS6xYFvWquZtp7NEk1g3HQhMeSlLimZFyKe+zX\nzA5W42hnfvqUyKB8q+MQ/F3jq1GDZ97QDMn0lr4RKIExr/vnL4lAv3K5R8qm\nscJFVj+yTitlKLaDC6T664lgQeKft/6InNIlAzGbY6y2aqPK2PZ1MW1jcr1N\nUNMa3DNBefWvPmH+32ojTrrPl21K4enOE4BQXbmF/BaXy1bIq2IEu/7T5pIg\nVIWPLeNYMv3ZbHZFaZejL6uk9P8KFDr4C8KLIIJ7eR6geXhlf6QMeQrmA6Wv\n1b2+\r\n=Y1LG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"840b101d605e8f46972a8e198b06c569781b4628","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0_1590477914485_0.349005736702227","host":"s3://npm-registry-packages"}},"1.1.0-canary-be49305-1590530930008":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-be49305-1590530930008","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-be49305-1590530930008","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b760ed23fe936d0cf4ddf787110dab5a90580beb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-be49305-1590530930008.tgz","fileCount":8,"integrity":"sha512-arzt6K50tZ4poETVE9A6Nl/iasdxgxKp22PpZz/310z2z6PM6DVXc9qIyom8gdxV3jFocXwRRksKfR90k5+X9A==","signatures":[{"sig":"MEUCIB7OzEWpz4GoKvjAXJze3tFs9GX1AucecZpbg9fgDUTOAiEAub2hJl97Z1lBnhKhsETo7A38/fEJ+57Fn+8U3YtDXqA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14139,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezZOnCRA9TVsSAnZWagAAZtUQAJDqPtcTmdYXvnWzxTxV\npMBOMyyoxXWNI90LO3jhXLRiUbRtCKIxEJ+Ia4hGuYEmNcf5Q5KkGa9GlkpL\n7MABJ1DTJMDc+SljWBPicTwsf86UgHEUg/qN32HUe8+ri+nmB3cXNM5LPusL\nCJu1rZmGmYUmzzoQovN8ddxQCZYq+UO49DjbMBZiphKQPnSjZ+VOh2EY8Kaz\n8hjso+zPr8ydGhhSnkzfEn4DaYNHBw0evnqNNoN9heuPtuoTtimYbf0bUmKz\nI4uRs8wBGNVd1mP8ahg+IqfNaObOtXDdHHT+HjlGlXSpBjhRghxsEw3+H4zF\nPR3Ybjd3/xqW5c96UPbUAijRe6BesvjZ8sXRo7gQZn014yfcXLUvxYLNYeoI\n11jyvIqkle2UpntKpeQfdiwF4IM5YsbfB+S8LUJcIGsivbbZW6fZzadM1who\nhKN2l8g+PdM+jmIFarXGMuCVX5qtaKMsfzgDAIf3VLgaGflGmhHw5JJswn8B\nvgYgUvyEQlv6n+sUJR8GGo5Emi6cYyRIjvnvxWvQUp9CXDC/mNO0iNsVdP74\nwlaYo/XRBbN4KCM2lGtxBUcr4XE/H+kJo3qDdadsIXjoeYkdf5MVUA52VFFt\nNSGg+X0hciZeROvZCLMOHDkYTDN+rqEKQmz/IyHbD6xeXfbZqwe5W/bil/tN\n5xZE\r\n=j1wb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2344ad0d6981817ebe605e2f4e0cf38a9477c921","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-be49305-1590530930008_1590530983031_0.7009024363608423","host":"s3://npm-registry-packages"}},"1.1.0-canary-e894cb9-1590531655438":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-e894cb9-1590531655438","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-e894cb9-1590531655438","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"89fb82e87148b9354246bb5a7e31fe29989a5a04","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-e894cb9-1590531655438.tgz","fileCount":8,"integrity":"sha512-zcWfZlugBFdYAgZ6mBhmtdQGhIA3FTO1eoZEASIH4A0+wEt9v06vyyUTX+AimLYsgOWfO8MqP/X4Q+TGvqTzNQ==","signatures":[{"sig":"MEQCIGAsk8uROqZvnMaPldlzq2szloNFLHU9T5WyD+Cgi611AiBchK8SVtDeb7fYM3k/4nOE8xJVDhnRm8TwSnd2M0fwOg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezZZ9CRA9TVsSAnZWagAAoSsQAJb/87sC3lFpm1d9YRgG\ntiRIqvL49+InbHq2jGF2GgGvFuTD9HTfWXdSfPnp/CBaQZBhrcn40VQogF+Z\nTrIGY6gavWUjqBHaIE3jqcA0U2l8eLxiNA6+63L5Qqb8S61WvjcAWkjVFNnd\nxHbgVSKRMXBSn4j4vxJFPKS3uzJaDvlsNz6OphnUpY8Tq+MyxnYm16lbGAKc\nB/1Xy1sVwYQqymj+N3hnzHxVwfj5b12u7MiQ/VTENercsEnbhsRalsCLM14z\n+Z00+QFMDzNziMVVkKoWLjehpi31NiRk5Pj7pVTZBZSKlhnBSv58ATEFXVy+\nq3lu7AKq3j8U+Q7G5QDQsuzFzYtanWkiKaaBdZYI9Zibaf9+iPjSnfGtHS6J\nUi/Q/9/YgWyP8ST/Zghuwa4rzy1ukX1Y4fSvje0B4GmK4wVq7s/dZ8nawmn7\nQrdY8ewnZ/6lf3hpKzvasA/5cDDkN9DWeHhlPn6eL3E0ZBHU2EAeOgAA99Zj\nqditBA36Tzo1ZdHqkwOjL8EDTgNWzAC56OP0IUu503TlTbrpADSotRCp0A4F\nxGDy8VHx6HUBfsD9Q5kBcvp0gXZCplYI1ZHxjAY5vGustj+WjoHdUacX9HYC\nUx+xCzmujEjm+hIcZRyJGsTAbSQzVi/WVlKPpr6e3n0ObQcs+VZGuU0GSRCY\napIM\r\n=iUMA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d05b86790ea0f88f5b8a99f8a52a8ad94fee5ab2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-e894cb9-1590531655438_1590531709346_0.45634455199947","host":"s3://npm-registry-packages"}},"1.1.0-canary-843a022-1590610125425":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-843a022-1590610125425","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-843a022-1590610125425","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ce4cc4fcbdf8e5da81f80bbc06f0347c605ba315","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-843a022-1590610125425.tgz","fileCount":8,"integrity":"sha512-RA6qOMFT9s/9pR8WPVraiLK90USATj7wVFo8ytI0su31dkjQVg+lUDCKb9NT+bSw+dsmcInsgirmWFf/U79RkQ==","signatures":[{"sig":"MEYCIQCmcCVfBO6Q4MktG9+8d641/ZP32AXBe13aB+5hwA6g1wIhANMGVd52PFB9yX/mm8hvIoUXuiQKbt2T6uoi4kcGJxmt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezskFCRA9TVsSAnZWagAAMnAP/ivSj6M5Bqnbxs9JcZUz\nK4MImV73vhpMmUCvzW2g/P/OFazXq7LQayDfxJehGKAdwkWtOJOd88yBQsQd\nuyS/bZ27WH45Q+xqoAG3Wa/4/wAtPTv4GArPeZ8zjXgJNu/yYyNRLFauQK/8\nm6gkA5PyL4dVFxZ+QQ8vCVg2K+h7iEMuIKQ7pFakQHFTWsR6AILVdL1BRA1D\nCewlk0C+hfSZT2QeKyHeFIk8Ue0EndtSBl2QmFV5HiTYUrvkb6WqU/JZgczD\nnNYIl/woTTmK/4h9stSAx2LU/o0ZpQ+lElPQr/uIJ+M+1UxcOx9m4gl/xtZg\nhwp16ewkrlk2h0i7IqNUqpygUgPIgopPnjRxtqFJ+ufvcsJasRbRTYuN8z+9\nh+qXhgvOZtjPChFyht6sH5KJm/L4RT2ypEBFwrbxUW6qtmJ7z5WCBb8Ez11u\nPtDuTweZLIxzXtH7FSJ7gj1VXjvg57QAf3fFwmUilbjqUB+bv9h86NKAFVct\ndeBEXFe7XhcZmPYdAIWcevhQ4Mqj3m2dfuUcEGwn7HRX9C5+0RqknEvKsK1e\nFBg9pEadZvgZaBiklWafyeU8DUXRu5m67jaMWcdK7d5mFRrAD4mMQmiBXUfY\nRek7KymZsiPmCv2QwwnlIZ81pPLXTXBfnzRfhj0W7rzeedsjaOQYS8/N3FXl\nREBD\r\n=bW3r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5e78fc98e9a24c0fa5537c3113b24bb12dc7af34","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-843a022-1590610125425_1590610181393_0.7356694688460963","host":"s3://npm-registry-packages"}},"1.1.0-canary-f7e9ea3-1590622926924":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-f7e9ea3-1590622926924","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-f7e9ea3-1590622926924","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0e7d03d66e3cac04fded899e1522cce3643a4feb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-f7e9ea3-1590622926924.tgz","fileCount":8,"integrity":"sha512-zOsojpapd62xXSJ43p0TEZLyAUkCUsIXhEY2+hOWKCG9CtqvbxSkOeTRLHfR7K4RN8CVksYcRsgSA2o6e0QNlA==","signatures":[{"sig":"MEUCIQDZN+B/ta3gbCPrAg0GXntSkqDeU42pA01jg1nS/SOUcQIgFW3PnkiQV4du/3R8ezwjSCZf3uBAamAvEflMskyruIU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezvsDCRA9TVsSAnZWagAAc5gQAIe6Qo355nS+wEsMk5HG\nYI+OdlqXa/HMjfuGwBgH0Dwo8Eeg+bk0CRZrUpZsjtBGwTZ2VZBJvFHqTBAS\n3F223g9c4sP+0dpbvJC8snQVqI7PDXf5+MHxNHDfc3j77iPPKCf3tFJcpQf3\nVwzw6eYAiPuNxwOxH6yRYrRNPRaOtX6IMH5O0LsQOarBfA7qRWAUnBMN8DDX\npGGP9PSy7cZt5h51HD6iDQSvBUkDm281SLG26seHnyT2leaViy6PMguA8Ae+\nQsDcXHJ3HCu+EJHMN2ui+ghC+HZonk15YwcoT5gkcYAqZnvWneL9WokH+hsT\nT2ba3O841h9KSw1/r8PhsfRUlvwsVl2OXhrj3r4nCx3oknZEAbaAGuEnXHiB\ndVltRQoSxlkmIOaaSr30EEVIP2JOfhBWo+gpPczO07Wnx1iY9J21KYxI4b2/\npFDtN8n0awTk3Noi0pgRr5Q6wcJqOcsOLFtuO5pG8p3YBkqL2F+uJ2BCZ9UH\nrvWxs79/QTX4tKv2m96Ujh3j1d6cbnDvisC/4/4c1QO0qRjuNRSwQdkvHL7O\nfcW67W3tiv6asmLVkrG0lkou8OrJ11cmpAiDH+qldnHnab2HZ7rpCqkce8RE\nroLdCQleKocrt/mPLTxVpgTccsD6KAx3H7tAi+MmnRwnjFO/eY1FcNhgah+D\nLZkE\r\n=kiUX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"da9431dc6510d28a29eaadae34519a15a34538cd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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.0","rollup-plugin-terser":"^6.1.0","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-f7e9ea3-1590622926924_1590622978609_0.7838616989013463","host":"s3://npm-registry-packages"}},"1.1.0-canary-6153d68-1590623623619":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-6153d68-1590623623619","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-6153d68-1590623623619","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4dddae60997cf5f758f6006edd6b8c6dd4dea6a7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-6153d68-1590623623619.tgz","fileCount":8,"integrity":"sha512-mtUJTIB8PfnFzCZ60Cc+3pbhWUn3pSRFz8v9BIXWvREEij/19mlm+F6+1xOg7tMQZeE0BnaXjs9Xe0p2DWPXdQ==","signatures":[{"sig":"MEYCIQDoTYOMMg+n2zprG6afZc/DH1c32hAfjCe9MgCzoJ6glQIhALiyZtgmGz01LZXEMPJ+x61kgxMhP4xHtziynWUmZZMg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJezv3ECRA9TVsSAnZWagAAxokP/1gpCvdOIq1ALGG+B6VF\n26Fy4vJod7VYyFtsGZJP4rNQX+05ErXkDOJmp5PxFPYTnNJfBs8oTIrran5h\noJvpR7XUUDdguaeNBIj3t10sQdZr7eedsEgBG1/g9En53LFVjhVT5lOX67VT\nqP/0uecExq54cpxudxMsRSBbQPHJg1iBdv4zx4QExINnecI8P0bZNIHg31O2\nXhJ0Di0VYu6WkuRKv11mFGff/7ATOalxCkVQUhfyziBOkfB68WplWckVRx4l\nRLiOvBic0jMDk3pGSElIb3VluLF4tStDj6/bPGRKOD7JFdAiEwixkSCIWzJX\nI4eHzoWua58Xell0CbgA0HDxhPkUq9vkk+v2CzLGVT1R5dj2CgR5Z3ffPF4o\n9xkeTJAa38hgFGRCK6mLbzUM+2RI/25Rz1S6nBBv8TOp3v+agERihnYQJDWT\nzkvVYKdxH6NwN5A74EdB0kMMHS8IE6c6/pLZVXXqI1vmD/ehnU9kiHrJ3YDt\nZKfU8O2fNMCLkUSzhO+ILoj4Z/b+bJ1XcLN/Au/DGuUhT0WqfTjO/uhrqv+p\nMX69vELNx6IWL0RgQ9ERF5NuMtqOhcwrvgM3n1pf1i2zWugviFDItfGTxZ8n\n5v4q840c0xxK22oPaj0C01mhQ9bWJC3v7UWlvmbzqdpiOyATKEEh9gSDjAMf\na5rc\r\n=Hzml\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"93e4d1cc4b9fa05cc2e18de46d7cf4f136e4be60","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-6153d68-1590623623619_1590623684453_0.4941302547413764","host":"s3://npm-registry-packages"}},"1.1.0-canary-bb524af-1590646959609":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-bb524af-1590646959609","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-bb524af-1590646959609","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c2105af0b0b3c30aaf94d39b743801fb5792bd0f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-bb524af-1590646959609.tgz","fileCount":8,"integrity":"sha512-H2aCfwyfjo77jA2lGBLd6C8/dVfx84kGE4L5hZCMt6Zadl2LmTI0U13PClTpV0xbMsW8Uz8aWiU/j3Sn6j5Kjw==","signatures":[{"sig":"MEYCIQDWkfSjGB0O3kfemkrKpbfKyAWUhUCZn03CFlV109z7pgIhALffKmUsxNbhTsdjyIUHQFxB1SQc9MxsWSLGq95UbN6H","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJez1juCRA9TVsSAnZWagAA9SkQAJUmnEGG01sDz7dwqjYA\na4w4NDjhSzpDFN9SDV5Py6VxNH86Ry2DqMJKqA5S0LQAumgmzIAh1HcFhABZ\ns1iZl4oGkNktSLBuZQM2tVJJwdaYhd47aq8RnJ0YPhiLvt3hJgBtx0Mcr1xI\n3lMKx8lk9De3XUgMQTZC26hMWV8+3Msz1OZxJeQUagfXj4tBrnutyuaXfa5H\nt00d7Ut/m6iG98pPSMcFDEzgQqmLAwn+MARJNzJTFuiqrlPGXzuc6+AaEgvS\nm+VRQf/Gn0A2p7FzFaaA4VqRv8PcXLf94l91tp9mqvqX3jz9f0h2qq+Nsatx\nDtnzPYUCwx+YDc2DLHE99zjj2u+lxKGAjji1MHrcmUUV6KPWVd2XomlgJdDn\nPtkBVybUrKysGe98QEORM5dhoIUHAU0g4OvTR13q5ikOx9L0x3zNbTq8+eSB\nj0lIxndK3KVweEKUNOUIYRqRX3iDIeHcCgZPLHkn84oe3GSU2RgdzELlD1lc\n2yEgUUiTQ1PeDM+pYmlkXFSHCkWreWdrJGy6Gf9Z4I9z9klh5ROJUqiBBZuv\ni7WWH8FFXzwzw0/DCzsX7ACPBA7/4QOkptVYMH9YOMnaAiPa2eSjQJ1xaKhm\np3GQEK8VFFbnu2WZ+uaMxvmujQSgnK/fBmsucBuFMZxkEIoatjHdJwozdSrx\nKNgw\r\n=WddN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bd9342e0924e066f774bd255df797d7cff44e716","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-bb524af-1590646959609_1590647021581_0.17302963224252355","host":"s3://npm-registry-packages"}},"1.1.0-canary-dbbeba6-1590870373720":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-dbbeba6-1590870373720","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-dbbeba6-1590870373720","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8c81b25f86208891d65e847faeae638693b522c8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-dbbeba6-1590870373720.tgz","fileCount":8,"integrity":"sha512-f7fmCvsmYvGr/qjgnrRjr+o+m76h1VVglryBLNu9zw6/+Kb8hBSMJ4SKqEoP+QbfUbru3m0sbGC9FX0etErwgA==","signatures":[{"sig":"MEUCIC5jvVtz2i2iitZagEtj/ezvwdHtoaEohaXCbNhhfR5HAiEA/YeDkNR+p7904B1AsCUjbg56emP98GLxK08LvomLndo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0sGlCRA9TVsSAnZWagAALkkQAIZeMKHPWvSw2UYrvLMW\nfEZfEh5pHXQcdveO1GJeURBxBHJaSrovp8AKRrx5CIt1ZzS/+3oN8Z3xw6PP\nSonVUOoWQW6jBXR0mHgyV7vTEsNYRI/g4ACM5CQnnMDPCUD2UGlB2KI71VCz\nqvjiDvTPNJW0u1lKEW6ACOFT/BUGr4sD4YBV4Q9ZcDho/8tb/SAYw32aaFao\n7gkxKZprocnZHu+q7TxrvuqoJjAAyR8gwfVGDJsTejGQKc9CDpJU/94IaFCc\nfWk3FF14mjrX5AXZa7vWeqmsu0Lnay+3CbJjitTe5u8TnbkGpUcDH15S1zyj\nfmpT+DaNgJR5YuQmVzWt+lOTdXxuomxbq/ECxdLWp/CFoIsMen+koREiPP46\nQ70wH9zqRdH0SKXowWRVRfE7nhNUyCw5ywn+tnvMZBKn/3fvLP3qsU1I36sA\nQaJ75scXwJ3rcTQDwZ/ZHPBrDJxo/luhlyvPUr42zvcZBxQhBYXbN7y0JxAs\nmE7f7HNECjt5uQcNTojJaIA0iv3hF9kkzlSyuFrKZqQ4nlXhMucPGVOPevDx\nuOCpXtCwqUm6Ab2V2CVZpUXOCT6VvTT1140LkNbdqCz4A0u+JywShO/VJ3/Z\n2z8zEMcCvvi2MKi5mI1zLkmhxmjmeb0gBT6m/Ig1PDMtiqUn8qq+XdpRhCmd\ny7R3\r\n=9Lhy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dd047feeb0d89f6c3e2a203ade922cdcfaba6ade","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-dbbeba6-1590870373720_1590870436243_0.5079457027393854","host":"s3://npm-registry-packages"}},"1.1.0-canary-8bcc443-1590871135457":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-8bcc443-1590871135457","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-8bcc443-1590871135457","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1bd24474064f3a4421c08d1e8be6c3ce93bffec6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-8bcc443-1590871135457.tgz","fileCount":8,"integrity":"sha512-RDVA3XOc9kkmNuCJsX11+zwwjDD6t6Ydf8AdHWIiG4PQ1PTACusvoMZwoBbs1ozmhXxx+/dVUZwk/GnGTQiyxQ==","signatures":[{"sig":"MEQCIFqwKVaVfSkMEZeIkqbWS2+aX+QubqCcNdIC+j2yksKqAiAN+4w2ftcJnzHv+LyqiJoIWcRvJTb9j7LQ1mclhd029A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0sTHCRA9TVsSAnZWagAAbncP+wW4OSf097Bl8vbw8LAL\nHTa5CCkgufRao36CF6DKBGH5HWQtpQZZAm5TOsiBwIzmbTveEs2S//6awBeX\n6TS8Jgdtgb6f4PCm/7izx/GyiYMz7kJXeZlWL5uUjz+AkbKtc0iVhgZBIfL7\nFDNpSPCarAvGMd+u28HdfEWKqeXX7f8+uyAOzYLd22E05N6HOP+hig5CXkNz\n01By5sx7tbjMzDjXI4a+MBo5CkLH9NtEqNFn1iDrDf5D649Ic8D5rosNiyXb\nyIiiFvucEN0JYQPeb0pCpOkblvfY6D/OY5qM0tiG0e2VH/gLmqlXo6oNP8+1\nNgZticOHSShueq2DKl4kJGMkm3oB8KEiA95xnOBvO3cff9lCci1rKWN5i9TM\n57yUHLIKNlcljqvsJ5UZwazweAC+uto2YdMcZ1X/l6/foaAQ3A9bBAJRXDEP\n3VdWvZOaouThaXQVQqncdKaYHwL5ReC7D7qX0/8i2FakGdip7hcJRlwyaEdX\nKpVJuJYZN6NA3Ywctq1gFDwnbcqcBP6zN2bTPOKpFqOik1qarj5dm1mm5v7D\nZ83wPoOGQ2ASKhWiQlEQs0AyKlejYyKi14xKU7eS8AQEJ8HgvZEAz1UjoRlt\n57oMnNyo9ASFGlvP8fLun+y6xiHG4hLlToxjYUj1knM0iPOlUDowla0PnwCI\nbMVo\r\n=8arS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6d307befe718651838372e33247dd74e48c52854","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-8bcc443-1590871135457_1590871238575_0.8956733472994465","host":"s3://npm-registry-packages"}},"1.1.0-canary-cfcb72b-1590900349309":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-cfcb72b-1590900349309","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-cfcb72b-1590900349309","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0094e5b3a5cfc5a750bedf532771e6777687d1d3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-cfcb72b-1590900349309.tgz","fileCount":8,"integrity":"sha512-sjM4cb77l5xICdBKw6ZeseVezuGEtPH9LnRtT/3aBh2UnXNw2IcDJdFHjapkEoLBuyXqvoLDH8j8bCG7miRJfg==","signatures":[{"sig":"MEUCIGAA0MNFvVESQ97K1HaZHzQu+kN7SwM9Z1uqA+bQ0bh7AiEAojsRRNyUM9g9FAQOeX/dxaEQQ8WReJMM0u1mvcgng6c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0za5CRA9TVsSAnZWagAA0psP/3uzBdoApwMiL5oMXJfY\nuhkif9vbJiA3iyoiXpegLYZkP/ghr8xA2+RnFQS0y+ZybYcNzHgP8Z9faqIH\nBvPklkFawkQAM9SMbjNGxgqhEfAzpmhSzYNl0Epm/dcFjHaLLz8vNigHOQoR\n158u3MVBjHTsEcdnuAy7a5+IgYj78T0useDm9TPhapfcq2M84w4we3Kk6P3q\nNm44DdWyfgf82GCystOwBbcWWVlly64fHFLGraEykJ7kOtBsPn0ZdxLw1x9V\nArQEHYaCilDM7jLfErwFQm6u+oqnwpYmy6lWnWpiOuh/GOVYC1FnnqNpExDF\nsm408nPWIGs2Mhio8EzKbL/iAMtr8LKhdd/3hmVN8DoWqAMkCENUggX+0L7/\nBOTd31y51szSMj/Sz/OwUx82CddEpkE3O6fTQuIz9uQNMvJGgbkehNH+mefP\nnPm54IFTOn+OJLieOwXurGfmLWx/4DINWZPhXYS1FPM64EZIxtEVlouQubmV\n0Emiyt4DG7OEkdLiAtFl2HXoqC+/TsU6APna0Xql00vv78r+VRPTcJV5hKPi\nBcphjxuMqBLnO5qI7xwDdJBtM/YMYX0jx3PYy1do9p7UGHwQOnClmdOW6eyU\nZDN8yB9FSx5QAAMul+ZtBVst+09lvLSnpsEoYI29994ivYYfwkO7xUliZJfa\nlobm\r\n=3Jo4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"89542bf95be222719418550fbc918de947554660","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-cfcb72b-1590900349309_1590900408930_0.6135792028490601","host":"s3://npm-registry-packages"}},"1.1.0-canary-af2c380-1591132026664":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-af2c380-1591132026664","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-af2c380-1591132026664","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3d9072ae6bc298374a445335761174550805b73c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-af2c380-1591132026664.tgz","fileCount":8,"integrity":"sha512-lmPvyPP7w51999DiIlG3DUHQeC6cXpya8DWCj9lsq57Wp1lIpi+Vdbx615syRUyEGAaav/iFHlaPwadR9On8JA==","signatures":[{"sig":"MEUCIQDRY8daQRxEkgimODi7QY8KfdBZH1VIpk+4aah5A0iBDQIgVNrcIALnVtqa/XD5Xwur0WTbxjZV6vFhNK723f51NMs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe1r+0CRA9TVsSAnZWagAAL+wP/jFjmgoDeqTSHtYDlG5K\nke7fdV7dKAZpr2fTxXD9SpiRUteJtKsyDriLm98hmMxEcRNfFciV4PpnXQQv\neHZTVhoTkKHFMnK1DHgXrCM71PtcMJOHe8g97d7wOuv7MJR9f4gdHOauP3g4\nkDivMTncuQXANBPi067iSi9b11iRYL6xw6KHsgpuGZghhCaY5oJYxnIMjhoE\nNsyokAgwd2dqdkFwFwhENHjrU2d86+CfyK4j9t+eiQXg1RCpp3mBSScsf9Yb\ncYemba8EXGqq2rWpTqCcc0ezltauvbRS+f2oqDfEXVFq1muBWmirwlbAOFlJ\nH84NjtogVoiwso0Q9jpsGUu+gCqs28NT/vxleWNL3ZkXJp+mMCSD7NQUX0tY\nCtHofX2iOnIo82mF/q84heIZeRxZ7d0jf4O9wCeGFiFdrAtBPdenQuTcu1W9\nwWgXRDt0ol4eRHWiiVJGGesBTGfk2W5517kCfNnuJ7td5vAeOQgLYqXkwCVk\nX1croNgrydQv0RnBoxa49UHerazJDj6/Xxy/zIa221Kz8fDxdBrAIolB718I\nORmFM1WjN8SBIMqqQclnCrKSe5074bd8I3YTkKUciyOfn4dvgznDNmzbHlA+\nV4mdXtJ5r4kUIGe50ptaP3kqVvLsFVgIeMzOrI/w74COoET5Hnrg/yGgtGNr\ni0Dk\r\n=UYiT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"aba1e616ecd6810934981719f0924766969881aa","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-af2c380-1591132026664_1591132084227_0.3423747840471223","host":"s3://npm-registry-packages"}},"1.1.0-canary-d27fdb3-1591216500836":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-d27fdb3-1591216500836","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-d27fdb3-1591216500836","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1c66bb8f93ff52db69b70f41635d8333fb19eb12","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-d27fdb3-1591216500836.tgz","fileCount":8,"integrity":"sha512-ApLyx9Gyo5LgkJbr+cBI+UPw98uj2aryTNokwdjnn2Gk++y5sUViSLyF1851mXAJPKlIKviRHJt88erN8XAFcQ==","signatures":[{"sig":"MEQCIH/hHz/OFi4qPu003mF+AoD0ihd0A/C6Zek970VdNo0pAiB1wdqdZXWgZGfFVYs+EtkD3RwKTlXlcw8mLNXo344UXA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2Am2CRA9TVsSAnZWagAAk+IQAJsERykMvqjah+DykACU\nLs+G5GuMVl32x4i+sKYfmOdk8YmnLb+xWug50yZXkyX/XoEW7AO6kY7QAFPG\nQha03tLZJc6drakavkS32jk9cZgROXwc3Wb3py14Y1J+bfm7yNR6f/9XW/ay\n9wWTM7ii9GtxOI3yZgmHbEAhU+mbyUmjkBiXyZhSStV0lQQzT6fFlcGxlNfC\nxDoSZ8MvPSbKwiPygckyIF6sjUS43vbQwNQ3+EvpJU6xzHGFBlzZb7Yi88tF\nxiHge0iZT11dn2jNqfbRQcChPLSpDFOCpYeQznQvTkp8c0WLbV0nWSsjSuqr\nN99//dVaHz/6AxzYEFkBK/SBnfEnGQlyh0jqbm5dPd1r502Q4JbbrfxFCev+\nPpwj2uWtS7lrCyfLsfJPzgum9h1OEgrdwzq0nXyBgSuBd+C5Z+QXKYM8HuLd\n4Q05Rk9UA/+tY3rXIMxhV8FeI1gVWc5/aK5rwVpD30d07AeksDefVUbo7BSZ\nw1DCaTZUWXXyPDvBszRunkJ1dcxaClJPJkXNa9c6PUCWa93I7ZzpBJcwB0Wx\ncIIiUv3qNwR5cQWfUz3fYF3cMS4hrP/pYi0waZrA8UoQKRQ56tBdq66hmtRu\n7I6kL35ysQK7p4zyeBcQ3lfhe8S0lRY0uzLm/V+RvxSz72LK16xxnDh5sNHF\nvYdP\r\n=bAk9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5bae797ee74b2bf5f4fe2bac8ab9d898b49247ac","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-d27fdb3-1591216500836_1591216565398_0.04528173967967608","host":"s3://npm-registry-packages"}},"1.1.0-canary-c0e2c2d-1591250949476":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-c0e2c2d-1591250949476","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-c0e2c2d-1591250949476","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"32a73bbb22cfcba24c32c6cc46fee47c5eed8675","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-c0e2c2d-1591250949476.tgz","fileCount":8,"integrity":"sha512-486xYaP1hhRwoXIZlCPQ+OtdlaUI9totwbfKvsaZT5K7+XXyeS+OAsh7u8d5EFG85CBJqD75HHWRrwHGQYAx4w==","signatures":[{"sig":"MEUCIDwo1y9yughV1u5eIYGXbYaMFhyHn0vsSuMHGwfpLFhOAiEAvCwAP7nR9wV66i9Eh5Ke9rCMIXaDmbxBAHunnMoVLmQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2JBGCRA9TVsSAnZWagAAul0QAJrXAt3NVdP1JRQUaioC\nqLC4gXW9HLapgMvgiSZIoorTorhNqDtkSR9AhkwMVgSgd7zb258gImGWOF+O\n3G85s471dgFaJ3iRir2xXocUb5/pPoIwNvG9eOwe1sBic8dRjaMKP65OucPC\n/M/AIcg0lyR9RbhuyPrPUg6HCEZin3rF4PcTGasC2DeadUhqbCPuPbVP5eLX\nSkbV9G/wqBlqwKMf5fGqWbzsDHA2DZgOQeIRaPp1loO5SzZ/N6RK7EDdya5q\n1OQtwAowPo6guIrdR26D4KJ/NOQ02CS7odVCB6RvaZ/tBIMkyZx+bzPVzunw\ngzAoKdpvL+uT50TVYUuthPHxoYnnTXMsASr+ssFo22JZkq8pC3tNtOAwAVzJ\nRHnYoN8nTJkUVTGbotsDVVYoizQa6rFo4tsNYm4FGVW3DwCdmLwJaBm9TzSu\ne8TLhZD0+s3+LATBgXv82PNgdA2NKXQUSMZpd2ioqKxi2CcHFIq63wlolEMa\njkW9kNTOemAARwwg/ZgudeLCQzrkARDSspwQ6AYrZvVvLZg4fu/rLpR0JX3p\nTWP1dweSd5NNI+OQzfj/1pGsOGH/LG68f+2kRu24e8Moe+lSOLG+gROerQNy\n07dt4YkZmPm+ZsSJcZKEGw0XMIsWSADvIp/IxQCpZ5hFE1lIkXCKDat5Lr/x\nvUve\r\n=tcOD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"70d18dbb4f7d66919711933b45db834d8a3e8989","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-c0e2c2d-1591250949476_1591251013945_0.7361138943626275","host":"s3://npm-registry-packages"}},"1.1.0-canary-4f0596f-1591305030945":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-4f0596f-1591305030945","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-4f0596f-1591305030945","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7a357da76f15932eb48c57622f8f2259679383a3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-4f0596f-1591305030945.tgz","fileCount":8,"integrity":"sha512-yBD4j0hUsnvGkkCU2Y8YNLePssBWdUpCYOy0DfaBJawWeeq5Bmsox7u6gc9zhsPKc8EMRfG9N3QmHrdeOIe6pA==","signatures":[{"sig":"MEQCIEJXiJslpY0LaH66v42nDPnzcXcFk9/7nmQhDi5HrSumAiBJCxwOdV4O9EQQIJ3OblUiXycpI3wDooBlnHP+MU+HgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe2WONCRA9TVsSAnZWagAAsugP/1ofhXHhLnG1smDD8yXN\nVbzdKI9fwksjyb+kRorRtsrCNSc0y4dKXYG3QacbHNH8ISuPwqJ1a+cVA2ze\nvWymLvQY9qQUaV76GwJo4+gbP5efxFj32hQKaTxdsd+cIGJrqP7GbOu8Y0Q3\nOB/p4pD+PQCT/nbstlhfZTCuDK+/yjzouUF2irZIcIVSjUPHsy+tBphMIftv\nOSTD1X+RSaRquh0fmwm2WOWOsYUrw1KK52XqmrS4NTGr6lr1vRqsx9Cld5v7\n72RwMrlIOm5jyK/eR0VquMWV8Zz0lfHF7ADQUymDsEhA7LCxidwuhXHNRgaH\n9Nn/+oX8/LopTcSBvzXbzgQo+4qo3fWsf7ggXcenNSgOg503m9ezIthcVd4g\nT2NUW4X7Hdh9dUyYbUpTh0+uIq7VH3Oz1kT53DR2JyOvy/IBlCTscrqa+29A\nPg3cRyUcceHtcNLo2R9If/8PEkrCbXR8XQRHrjXii2cnTszblpBEfDrbFdFR\nW0dxaHQrGIOKfRa+QNEPIrBqa0rEOvkNqRq+JggPtOH7Stu7ReiGtpwpDwlO\nW+/5vGg4vq+EsYX2k40Mto44R42VanrTmfuJPY2P2yZERlAsb3tIXqWYUYEA\nOVqrWBneTLs2PjBVbn55mXeKj+ppZOpmCQg9NBKij4LJ7i3Ii451PQa+Haie\nh+Iu\r\n=Vz87\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"82909202031ab37f94629504b214351e3c74332a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-4f0596f-1591305030945_1591305098596_0.6339127719916513","host":"s3://npm-registry-packages"}},"1.1.0-canary-d890821-1591569709557":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-d890821-1591569709557","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-d890821-1591569709557","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"909ad03110fea9ef7b4881bc63433fa2ea66a97f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-d890821-1591569709557.tgz","fileCount":8,"integrity":"sha512-ShgRFqTx5LGNT6nnP7BXLQU2n3JReY54T/YZHmQe0c+FUKmIw8kAjsg/c7nMYBGuJDjSsUujTpqquhUlX0hiIQ==","signatures":[{"sig":"MEQCIFuzlVeOH7IVLX9vaXJMl3s17EnsSi3Yo6qaeG7cRFnmAiAaHRviolOwC+gQZubY5dYZuOMcKTnRfXkgBiHJdZHpgQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe3W1oCRA9TVsSAnZWagAAeDAQAInjZNUtu/Noqq8LLACc\n6yCAbjcc32N4ZoXv8BEpH2nneZszOD3+rP1EO4+mL9YpQL1q8Q6Cr3ITLrNG\nx9u/7EfzJ2wqcmYttDYDqWFF4x+xT5rJW3xSUW2oH+oG1OoKQpqcEDvumM8/\nhX2tvMJ5wXFaTxlGv7Re4q4PecBIbU4gU57c75yalPOKxkw/DbDZe9XmJRoW\nm9BkNFR2QFqBjZeqfAH5nA7O27WI7Pn38k1kKgWgh3z+L7/dwTdAGe/FgI5B\nbumEPZD6GurnxzfC4QidGFmhyGS95xUL+XlPKBMCWYhGymY6OtLaWV/OepIz\nbhNmd9WYWkc7wwThjBa91+vrNxvEe23Nqy8SP43CniJYpKJLYIH6g65aGqZu\n6bIWqM/togPyyAKd6DRbRVoWtzupjSfBcJD3LSf7KLndSohzZxkRvCAi4Os5\nf9znYTpczdr8LB3T4RgrTHrl049XdK7G+MZ9bZvUIJUnZKef5TIbN+AVnIJV\nwNCHzoxP88DYJZiGmVry+e6cYwfM0HwMb96+wIgYjDW+wTbag9fJ4pZYa1QD\nQLle4ngmnBHF9QLX2erTa8Pn1mRtlMhDAxjmZwGx1JmFDuCKZNXW3UKWx/r5\n+l45FOpmQV3YFbIJuTBtt65OTCf1X/Dce2XHi9pGDZndstdF6YOvmiSyLet1\nG71L\r\n=rb1N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2f6bb4e52d14009261264187ea247de21e2e334e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.14.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":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-d890821-1591569709557_1591569767760_0.6901126770643633","host":"s3://npm-registry-packages"}},"1.1.0-canary-04b04b7-1591658231490":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-04b04b7-1591658231490","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-04b04b7-1591658231490","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7e8e4456c469ce940d524e6df347e7b62d7c99ad","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-04b04b7-1591658231490.tgz","fileCount":8,"integrity":"sha512-3GWT+3819WZVnzd9VTjWm6P/jKz1Ye8iK8cwOGC7vMkV/cTv2rhQnRmaWy0ssCC7b2EvFTFi/ZPqGRcaa5s0gg==","signatures":[{"sig":"MEYCIQCe7RYwBvyjeRVQNCREslCuZrc3dzTzTu7PxMJyRmZQZQIhANPTj4tbQ7odfem6Qv5l3xhwSl5YNQKXj3fsuEZDY8uL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe3scxCRA9TVsSAnZWagAA0HAQAKEdfIyRbayjrQXwbzUD\nE6Y2yNEZhRGznVqBt5/RJKjBkAI0MUhrYVhkja61Ag1YrP7FehcVyGPbKc4R\nYglw1/OF4v20AMFDGHD/fiHRV22BAr32JjV+kn0Weip+tPQlIi4AYhGV3KnT\nPdb74gDGWOT4eusAqS9+Nf9N9rcb6/WQTEdzY9K+N/ywcP3jxFPpS2yAVi4w\nevShVQ1KY98Kzzk8k2ji7ZDPFfrMCF8idC7Q+ekZdczsbumSob8rqYnupeJE\nDWtmCsDCgcnYLp8Q8+Uv+lu+qGKTJPUtbdJhTw+NusYFiFPu3H+uHpiGrWod\nnk+oGfWAc1MPLN0oAh3tiN2e7+ekZcDRQAvFfHj2JeIAD6IFxG1oo37gOU0k\n7TqU9RjT/NmJ6nXa6DS/nk+s/efm4R/ZVr7UD5decjQrJ03n4Z1mY9z5Kwnn\n+O+dSWm6W+4rZdxXwmz6vwUGj0++YBxSgelnl34Rv+sh1cezuh6uq4+xcr0b\nKjOldhb/QZleaZIdaGs44H1196fCsfXGOuZaeXCiYbrJ/BPllc1nKA02a4uc\na2xxxwHvEm1Fh8hAZC1auBFCd/jyxhtUubBBMubj3YgUs1n/QmMb05AazxUU\n2uEAMuY3v3JtxTyuvGQKhQcMKxu4sBLpMP3pqI6GpNEgJ2VVRptx00lAeF3Z\ngSwa\r\n=l19n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"adc64bb305a25ce7e938e35efb48d1b9b34cb7d7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.15.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":"^25.2.3","@babel/preset-env":"^7.10.2","rollup-plugin-terser":"^6.1.0","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-04b04b7-1591658231490_1591658288483_0.9438928880862729","host":"s3://npm-registry-packages"}},"1.1.0-canary-ae2e3f2-1591741234969":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-ae2e3f2-1591741234969","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-ae2e3f2-1591741234969","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b28bf2b1dd4b1f42625c7ba2232916658b499043","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-ae2e3f2-1591741234969.tgz","fileCount":8,"integrity":"sha512-kVLGIkPtla7FuwoHvs/xBP/m5xQQgVrQsx9E1lzJBsLVXLmM5bypDR/Bj9yIQRIUSdSs2VPcXCl5r/Jwxsxsnw==","signatures":[{"sig":"MEUCIFUmeNKdTYyYmt+M/bWfeDlyt/s0dUSfD94gbZkhUAEqAiEAi/z0as018v3Lcypo6d9JKa0zIu6NLeodPYnQwyJy2bE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4AuACRA9TVsSAnZWagAAyXAP/2ILWj17RA0bAA+2SDN9\ns4IM24Lx+0OfJUjpIRg6fh845r3v1GSOutlDSLPDeYmrvCJ38GxxPXdRoG9D\nsHRrG5enuuL8zS95DHY9jXq+3xtlUCqCHI+4RPO0FzJDrdo0WHb3pWxeN+KP\nP0Lnh/XJhfm6rKhDjy3c+jb6rCu9ajUTGRSzQG9N1gp3tAAiaCY5fUGWyEPr\n8gRT6apTLd1XAUhte2klOexDAV7DeL4YRfKZyg/VAxXeaFBAQErwwK9AxoGd\nq2JCUxpMCuYA681QepudXb4LdCoj0+ODozWTvWuomUXTCkDlO+uWmuWBWk6c\nwPzagvyLzkJPUlGjlDfAfWPmHrYZPHHm9iLYQUHhKmSPU0uOjJY1xshejTdv\n8+87fgYh5L2VNu0kNuIp54l7J/h4tkw5Z6luUS5djI63jrVoIdr/lmfD8XJy\nJIEWKEjzWSwaxk1fKXHyN6LG6Rx6vUXRNdg3hdKXy0STOCrkfzngBr8+j9YF\nsFbR0wdshU25kntDssZOcK996Bx+wwkh6k58u5+RHfmaIWnFWQrwsqPMsEsl\nAVQBen63MXvQkGgkU5QcXqPpKwj+n2QzGwidC12GhoTMo4zNqUDCE13mzHcs\nRDAmT/MrZlFvhGBojpqjtEG97LJbHx6TaOepyPqvUjenLz/VwWCsLT1R9duy\n83x7\r\n=20Y5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"54be2cc4df77defb77dad5e7b370e2bacd70e36d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.20.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","jest":"^25.5.4","tslib":"^2.0.0","eslint":"^6.8.0","rollup":"^2.15.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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-ae2e3f2-1591741234969_1591741312261_0.4991562031278858","host":"s3://npm-registry-packages"}},"1.1.0-canary-2520b7e-1592175902594":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-2520b7e-1592175902594","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-2520b7e-1592175902594","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4265942ebbabb24d7ce023cafb53f279618dabd1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-2520b7e-1592175902594.tgz","fileCount":8,"integrity":"sha512-Ry8ZZ/EHJw7mUYyivst2TmS3gTmmjdbnIfCKXZI7lbLwCHnBn5avTvPGrT2Y8fyUSgbwcOxkzQDVt5O9lSHHdw==","signatures":[{"sig":"MEUCIFQCUlMal41A8zvHubcoTfrblkm3FpD21GyfqaF8x87nAiEAhGVqAKLI2TKtkBqtAOGoK83y2eVAX1pwonyWR76CYLc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe5q1oCRA9TVsSAnZWagAAMcwP/2D9wVWfwdGbZR9DwELz\nwxkbmiFvyM7EQ3RzphJ1MGyVz8imwMUsfzl+7y0Z0gQyDM/l+3gC8FBoVqBH\nY8JYE7W/J3C3cT4b2MBPduoBL+OFyZ64Il7eYlJVSHCowITdGK2VMFsh9D0C\nZE9hHVb1HXoemNYgcjL4vpI42nnde7fDtG0Cyr/Lw9Qk6aiO9KUafsCPq7aL\npbhelgATKjT0Y8SYbxwcUWnn/nK4TcUrKmWYEfXawzxKqJb82cg215OSqqhl\n2kgzS6EZdaBgjgGvuspe12tVtvKnIEAkfIzlD4BM4ACkv9bHE23JMTgyyQ7S\nywPtpjQIk0l+AuLT5pDxbs9jUUgltVtuariqNc0/WQo2/JPcXKrHuuO5FKun\nYvlWo1Dzo9SFIWHAlK4smJkMyO3TVKXHlOlvjAK78Zm6dr4SZ5EHhFtCy/jP\nnFMEyxmF60gJAaNvKTY96HiM4loZPABgZTi/Q5EGAoH0b47KlUlsixqUX8Du\nlw0EBhUOK1b/bO/zYY16m5v6QJV+VsQT805tr55Km1/OnxaIdjGvTOLE3WLx\n486lrLbzieMKYoM3MWWOTAlay6pklu0ZGTtjzdeKhY/ZbHsK+eSfX5Gh09BI\njRC4mFYbeY4sadDR5g+S3/cT/8nQ3JO2dbW3Zd6wiFd5Nw5vdH17FGNnXWqx\nflyw\r\n=WniC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"03a0d5062429fe15ce8abc89f6f80bbb19c28ed8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-2520b7e-1592175902594_1592175976049_0.484658530432551","host":"s3://npm-registry-packages"}},"1.1.0-canary-e44ecae-1592430687157":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-e44ecae-1592430687157","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-e44ecae-1592430687157","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8ffcec0049522079ba66e9e071d722fab7b0488d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-e44ecae-1592430687157.tgz","fileCount":8,"integrity":"sha512-lUxHujljerDGMN3UhVStVPK71CXnFMv1+YQv12pBfg+Vbbk8WOFsQLwk8XscG813YrH1RSas57FWOmIE9NjYIQ==","signatures":[{"sig":"MEUCIQDTcgZXmuUUquP6wj+Pz/5g3DMpxwniK1Wxf9j8a2fGAQIgWyWYhuWrQHOCIrw4lOvOtk6JJJ9OR2OZbBkv2QVjlM4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6pCiCRA9TVsSAnZWagAAZZwP/jvGJ0EYfgya+EejSUAz\nmWZRyhRwecWAbP9iUcE6k3GR7nVEruHn724jJAmOakHeVeTOgHs0/5P7RsTu\nFOQqQrszjOq+Mnuc2uUxAs2BEpIGw4EHD20BvQG5Yj0j9c5Kvd3w3TMI4Ha/\nTy+3yPBPMsyEqYJ56kJZlDfRIteQaf5PM5y3/lfR1EDDPVKE2xPmTR1K/2me\ngnKiymqT25L3uQ0HNdiQghOKW9izyEN66HHZRmdQ0R4PcWjbQXzFoP86wTnb\nvOe3XPPeMlo/gpgCZQE8kuTpXgICeFd+V1YMxDX/4DpySis5cra34hPV+evG\nKCEntRsnMthqFY8TSgiF9f7ge131TrRN158sl7EqznprsN7bZeyqgSR3t6/y\nDgNYN5aPX5mA0uNW+KVU+k53jtjzbedwV0aPlAbX6bkXJsPz344YQRas8uLm\nvwKTcRugwTMImho+Pzj+brIWVI6VKLDBijgBUxDpQco5X5P9UoJ+3F22Qxcs\n856TH7CL6vmRN3tF5Mkjll4+SpP5ZjFPVd+LDnn6fd7HHyixp7paCXgtYDiE\nEYEC27SgiPYjIbpkt7qtwiEpkP1ULW2zKqxgZEKu/yPoAdw8JHHof7tEWHeQ\n/WpycL7azTIiNfmwWEuVTC7PWHb3pYPzvyP4IawihIo7m9GS+TFDZOCi3TRO\nln7D\r\n=zcdD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c37983769f7837830a27a07663a30829279b5e3e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd","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/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5","@jarrodldavis/remark-changelog-version-bump":"^0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-e44ecae-1592430687157_1592430754050_0.17397377187579255","host":"s3://npm-registry-packages"}},"1.1.0-canary-48f3c2f-1592678994388":{"name":"@iadvize-oss/opaque-type","version":"1.1.0-canary-48f3c2f-1592678994388","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.0-canary-48f3c2f-1592678994388","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d199c630450ed0b54af6c4c9890239a8f2609ef2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.0-canary-48f3c2f-1592678994388.tgz","fileCount":8,"integrity":"sha512-/iMCTaBrRaAi6vHq+k9v+rk1YpY/pnDI9jsQahkzJxDhMnpGd4dMGUAVxQr9+FV+kzcAAONpF0pgK5pmZvkQwg==","signatures":[{"sig":"MEQCIAFVYZRsTIiH3mYLS480whnZPvONVY8noethl8rawfuQAiBham5EbvvcwRGtI7VOMQW/7GEOaX/c59+oHkR+wukoYQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13815,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe7lqHCRA9TVsSAnZWagAAJe4P/RVDS3/8hw3Ig/StjvME\nGBL2HqXobZM5BsvO1XTHk/QSe6HGtUIdc8Tm4uw2pJNLslRK5jj1tyMXHq5r\ns8k9Ae1BQ5P5y5cEcGRCo0/QZe6XlF/SFxkqgB9YsbJgFs15TKeVbyDZUqBR\nZ7r2ONq6Bk/kbP3bFcnKSotUf2fE8x+kXXZvEz5ZWes9jPli+cUer7nbyjZh\nWh8Bv1pn7BImfTQAFZXjPj5C3U+IozWeqisIFZV+gIyy+YOVnu3kvJesJCJr\npSbDOoAy6yPPdYCThi+7thg0icGPYjs3SD+WCEvdkBihlaOoURhtEmbJfMht\nHdbrS/8ntKr/w3OlFKHguQKtHiiF/8KwWR5l5jqcy+9UvzSBV9YndANfV9q9\nhTmVujlCqu2j7DoxXSuI0GUQ1LHloLTWCdr1dtC07xj8znKcLauL9D3V10Qm\nka2kYy2d7/XUjeb5m2szghKtJKHqwYsfEobE4kFNvP2SIB+mjPPJ8qaqK3Qz\n9mDxAteyd34ST1wD22c1EYG4bFE/mfZbqm1wagSnI7hE3x4BC2e697Ut+3aD\nqggbOs0DkUyra8Qe+8GwQjS4BMDNhW9794/E90gq7RbbKkRkatSbpJhn73aw\nJcxeo2tukFB8CHsvfuvEAbg09o0niFh5jSXFeyNuSAXEbuJqP59x8IHUBSC+\ntIkx\r\n=is88\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"98360e480c503e00a5d2cbcd9dc01bbfce03473c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.0-canary-48f3c2f-1592678994388_1592679046523_0.5603300701089116","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"@iadvize-oss/opaque-type","version":"1.1.1","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"61f791c665d8a2b65f707f1b243b028590f41880","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1.tgz","fileCount":8,"integrity":"sha512-qECMHjm28g6YadUSMXjJUZuMErfJI52VmXJtxnJTnPTSbgvGblrwmGVY8lNIsYLahTDsd3iZmBBdCpPF6wLAFg==","signatures":[{"sig":"MEUCIQCY+Sb3VkXnM5dp2uswJb+uGOhc2xOQT2uJ17YbgGnuNgIgK2wZjvObvqo9R/71P5L3P51jrglEAJgXz/6EL+9e3/Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13879,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe7ltaCRA9TVsSAnZWagAA+AIQAJOy2zafaUZyh8n8BRG7\nDsl8yeQ2tSmdLd/vgWuRVv6YxUqsDlZMDy9QqmxGtO0W3PIYF3YpisUWZDxt\n7+88FY75Xnx59kZVEkka1uW7ehF3hg7o88Odplxtt5DTTV3wMvrXZE6lMoAb\nfjNwHiifkyJzlHki3d74Pll5lg29Tbutn4Gbea21NUWQhT61vxaIry0mdfyN\nSQmvIiBx/b0acc8QTb9w47g6Tv7S1cHh2Y7oyLBHMjQgnvdEDg2yUMW9IkwJ\nRb3iNgANaRiXOIh5XuTkrg+loozkhlmZrV+iFQm64sFCxmi3x7StVmZluhz5\npHoD/b+kwLuCg1BqZSXwIa5e4rWAYyBg026mrIBcGOOyJg1HLauJr+vyN1fu\nvZGXZYNKa/so+5hZrYMPZDBxcoaUwKboKW08DVqiwmGhHOqOGSOjKIhs7aG3\nrN9vV2VWyOgc2vPUV+90ahj+TQgQJvCvIE33RHwLhfojxvSVWEDAeFv/iBxL\njBU2EQ0IJkDxEFDjHxYyK0Bv9ozeJzetkn5J9g6+p7074AffKTh2tBHAc7QH\nPC8i2GjzQdLU+JeD9kdTuqv6s+Ck+EAVHTwQZN/FtVZ15Kjouq8dsUEt/ET9\naielkuk6G/sfnCc6Y827ch8oEGI0OSKWdSAp0Mfxndb87JuLYRXOULo9QIve\nkC4k\r\n=do09\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","gitHead":"75cea5c845aa5979e9e819f0fd8591fa4d4bb574","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1_1592679258165_0.838953525390663","host":"s3://npm-registry-packages"}},"1.1.1-canary-2835045-1592861953392":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2835045-1592861953392","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2835045-1592861953392","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"021f16292d3f2ee2eafa87e78b83e8c868c9d923","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2835045-1592861953392.tgz","fileCount":8,"integrity":"sha512-uXr1flJajUy5juS2o6ddagxifrZO13q84wdbB/QVUrslHav0u7Hz/48IURXvgAbgbTzHPvjh3kDQkKa7dsZiDQ==","signatures":[{"sig":"MEUCIGmMVJzfjoVfFKn41yBA6H76CU/w3XzRYTY+QHU9YpqJAiEA20YQPVI8KCQjDQpoJ37LHr8ZhxKdrlg4xZfZdLTA9MY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8SU/CRA9TVsSAnZWagAAbFYP/jrnyVMSavUSKnHAmQf5\nJVgvI3kV3+dATurIDrkpdgcQz8Ahhg4k+eYf1mtlUwf9PQYlP9uUiO+V0a40\n3rYUTJI1UGBiUrrTcL1zZWYSdhC4olfbPxKIHeB06JeO2tk4VUJUQtiMvSjO\nH11H5+g1ic+ODUB0u9tzydpvhZ2Chx4PIQN2kBGlNBCAc+DWBfXyJjNFY3az\n0Y33OL6cAGfb21lg5YqKxFDPgho3af2omVfqTNVVRHmFb/WSidfDm6VAoBkJ\nmUZ7flDn8lGP2fdwTwujrdhuvJhea1jXwI6JFEN4Jje7hw3H3pyj62LG8lGn\ntjevpmWnh35lgjDTqcmXXaYg5FvNt2R/bD6uMnEpvQieeM6r++yzBmBJCVPi\nsrLFlCFam3RCBOuy1U2SM5A3aKRSqk3Xf7LSnQBV8mK1SnU9xcRJ30vtxfdg\nlNq/asa3P5dPdymFUZmPwGJL7KiaqEiB1QC2t0qYUL82/i1749WZbcxyAytp\nYVsjsxtDhKNJ6CwmVgMNyqNELj0i9KrpgwsjEyv2kMUjO3QoTALUemN3csB3\nz1imMaakxxxuA2fN3HncO+5aajucn3BealDKD49q6fEz7uyD8NFta53Jvnnw\nhdBY+6f/FI3r09kThgjG8US/ptcA5eE6PhkUhF3NEyvQSY8+xrX1ZcFyfgWX\nWAMk\r\n=APyN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"21dbf97717f63cf7b917ae80734be7d648c6a6ad","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2835045-1592861953392_1592862014588_0.9655796075115797","host":"s3://npm-registry-packages"}},"1.1.1-canary-9f5ddd3-1592863004027":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9f5ddd3-1592863004027","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9f5ddd3-1592863004027","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8be8561d1910b6c4153a6264c34f7ea3e41a98c7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9f5ddd3-1592863004027.tgz","fileCount":8,"integrity":"sha512-vPfrq6W0Pgp8SlAhDA492/Tfb9TR74j3haFtXe6jFQ7syjYXbNo911sBun+pBid06CXod3EnEue63XVkmrfsRg==","signatures":[{"sig":"MEYCIQD4sEBVnEUhbwJXI+bf1ulAJ8JI3z0J5aLm59rkmzrajQIhAJ1g7qeWctcNUG/B9VpFaYkrf+8nxkf45geZ/upK7adN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8SlRCRA9TVsSAnZWagAAcHQP/0yDP9w5o3a2/F1s6NrT\ntJCBlZ0H+X2tsJ0RVynx3zw7sjabsQuGs66QFZIBoEZuYeK+9zGWKBNYxexG\njtCuJshg0InG1TQushUbDs8gn+CCl2VYUdZkeG+0el3OtEK2lEqLuvEbi1cA\nenL8xDH6Cobbc1mcBvEKMtf5lRUYEszpTO2zJY6JJY1+UtqTSrHY685/omIf\nSX/ZnsZhH4t5h0DRN46aMbGc8B2MjFNkSfw2ohtR30gIim+kV53otigdHNFx\nxCmNlFArX0YILRHX2nrS8OQANQAKQooqiUlhCj2YpihBrPxleU2MA8rFyHa9\nLsRoWbzlUpPRkiKwWy6ZiSku3BMgZBSDm9NZuhks8bwFchvPi4NEColROp+o\ntGdu8iW073eq0XiAcNJ5SCxFn0YfIH3eGGo2uGnk0pKZ+yg7aIxKkrSpHPpg\n69C2bVmxUDld0ua0oNWm82m8JSlRrG00Q6jFs9R5YxDBJWZczLCfPQBaa1uF\nZEIDvb8BMWvJtOPzZOjpRxmbTatS/Irh0PBKGXAZx5GeX3JvFSmRgIIRypR7\noGdpXma+NbAdeMZVX/MKRZw894K2cCooXkKHYM0gj5IuFq7khDvFZSDf3uXI\n8mNs9MEXxaJieH9YshTBduNm2ge/jbWsWdWzu9qnL2NmOGdNL3OafzBzPvAD\niZav\r\n=dd6y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f7cf747ea696f892be24f3ebfb78d8f3f94e7ea3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9f5ddd3-1592863004027_1592863057021_0.07350677160932806","host":"s3://npm-registry-packages"}},"1.1.1-canary-315c2b7-1592963825365":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-315c2b7-1592963825365","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-315c2b7-1592963825365","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"333b9ea9228d33d126dbede0ccccf3372c7c04b7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-315c2b7-1592963825365.tgz","fileCount":8,"integrity":"sha512-wKVacYrDsaGndnIs4eBIO06smfFDdLV8wBy86Np2xsjpjrTDi9A6ZO5UjRRgVCuWFfLNg9SstPrjW4fw8HqmqQ==","signatures":[{"sig":"MEUCIClljFWJ+A5THeriyVOtCIMFvAikAV5tMX0nAwf+A2fIAiEAlfhjAgVPDebMb+Px78td4mVchb1ViaYI8KFJNWC8CR8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe8rMgCRA9TVsSAnZWagAAn4MP/3q+eMB/FNS0LD+HQPIf\nMNlTgNfjexZeeUiZ7N57rJQad+e/C5hZBSOljX44+Yq6A2XAKCAegb2rBEiW\nSjzC+EG1e3weBm3x6pEFhDdDticXUd6KsrF3VAvTtyRey4ElvTg4P0eTdVK9\n3XuXv6QgFgF6F5l0PI0rpojyuQ044zFIPHmFIiXNY5J0IVIrbCIDu3jkqpFZ\nxAdBWFgsds/xtIIbh9+N0sD+RthBKmbChyk21bdWvek4qaT48Taq4pDHLHWR\nQcwVYyvOAFUD5aDlQVIwUnh5Uww1nMCJHPpNkGpqDevag6+gdCIrOySQ8XvX\nSbs+iJxmhGAoGmKykmwyk1vCHICyuO2zca9RmkSqx0RS+w9e6Gxjk/qnIMcQ\nysaXb7lAowYxWNjTSsbAoGhcPEbcYED1vX1wdcv9UUZ8ErIHHwaNJ0LN33NC\n8fqcb1Dsp//qWxZUzGvPcapkzAxXf/ZTc7U72rHIHxyuDBtkqLMka/jL1Ep+\nckfyiprwFzJPyOTjGCdA8PVVLuYcXurDrakRigGZ5pVR1cgZMQ0pMerX8OFj\nZONp5Jc67ALnwYjUiSvwqLruSzdjbkjQeP9RixW5VXoy6yZzmqO7i8fZXTJI\n7e4YQGq3MSQTjLbzMKVIoOtkII2zo6YP8x75XOxTCuak9VtWvGjsNhUZJOPx\nm5hH\r\n=NnA1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2043218a1d6757e7dcfc1eb135b2f966d19da175","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-315c2b7-1592963825365_1592963872087_0.00010062804792676516","host":"s3://npm-registry-packages"}},"1.1.1-canary-9ac4336-1593026141405":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9ac4336-1593026141405","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9ac4336-1593026141405","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"99a29a44a2561f9117eef9a3260b0acdcda5bfa0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9ac4336-1593026141405.tgz","fileCount":8,"integrity":"sha512-jr1kTWS4xTNOjLeo4S9JWe+hnSetbPcF4+hEHvSzFC847uxdZFXlyoobIJMmN3GyAFiDzXlTmFpnPfukL5c4/w==","signatures":[{"sig":"MEUCIBxm+wxlXjLcH4uOdLi83/ViI0RSwLwmeOTK8rYiCOC5AiEA1z5YMOTbS/zSMdyzWVjosOsB+vGgqa97VHhbUsbpkQI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe86aVCRA9TVsSAnZWagAA7gUQAIUc6LCgae5E6LsOq55+\nN98z/AsI9VU0AfkfNBmwIOLX5uliSt5l7jn//2RyvSsQLg+CLJrLMsNzc72T\nZyWlduTfOCI+uZb0O9fia6GAcjPBPPRu+L88B2X0nNn26VWejIeuhA6krPFM\nkfp+RQMrxBnykve8kpYghZgDKXDzHTcBQ+7BsZ+21riX6MdzGG6y4whFSXrD\nPyiNZMf/zfnOeHbwGUez4/FEyEdyJAvyXBgzkCgdH2mEM9HjycHUESw3fn7M\npGXU86vzIQRFW7dx7Kpz+XKz+ZdLU37LzexmurcXTFlXZ2S7/9lHoEnk51CZ\nFAbz6+acSF7OPkxeGvme69by9uE0sRxPzUXMEp0soidYchhSpL4lYaPNJlHY\ncdHh3GoFa1z9cdoZJVyO0361rXIJj1e8tGH2S/yZz2XE+qsLxezx7Cfdfo+J\nVeyI2940J3pReY46TBLAIm5qV05yFnzoRPKyehV4Dk1iyszwudbE82601gTk\nygVbTBDXQgNIxDUpOW1hQ8Cx5CqgG1OgEuoMGkLURyJJHYa8VbAeHwFhurR8\nAYtxxRmo0uBdA+dgTgh4paPhaRZpfIV+R0yGkZ8i1Olzh0DcEIx94So8pvbt\nDvvVJlev5yjfzpt8RV05dFQsjhqROqbPSx10QldIsFIsTI/2+P5PnLLrnn+K\n0Uk0\r\n=G6Iq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"670cad55025341710e9dba4c9957ff058dafefaf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9ac4336-1593026141405_1593026197359_0.7163299650538746","host":"s3://npm-registry-packages"}},"1.1.1-canary-2dcb984-1593193095672":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2dcb984-1593193095672","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2dcb984-1593193095672","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"325ba8b27641a1e60a951e4e01946e4d46f440e1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2dcb984-1593193095672.tgz","fileCount":8,"integrity":"sha512-IzPeFnNYxM0QAFpFF0S1xTrqHKDgHnvBQ6RGgC+Iuy7s4DyDXLzuAD2aBey8U0NcfY+Y7KemVwLIQ2loDwdDYA==","signatures":[{"sig":"MEYCIQD/3dUdtzYyAzeEgQ/Z4g4mtPf6/+JVWipXX8vLe/t/OgIhAMl543ipl8P4GbRlEppHXiOkmisVilrc73vrPNIMTJGL","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9jLQCRA9TVsSAnZWagAAPHMP/ifx3TMQ3lDJfbU9exZc\nW5KMtAYOeN1jBJ1OBPA6DzHa/SyRYdOnQw/lcvSL3e0pbIlmVBu+ADUJa1qp\n2RKCApdCV6TDlwwmzJHxdJOmTeokWG+aa+b62CIt585rZ5VpRSe7m6bWDigK\n08uJ1BNnYWfhK4+j41w/jrRYOzcYU6c39Gg7wAqneF4T3QBmdGwtOPvFaiCE\nC/oQ7cqaQnqwNzgGMk0tFJ/U4KY7mwXdtwwO9bU0gEaMbvf313LeJwy0lcRZ\nS5EzXvlpwqpfHXJWgvW7pFR2sCn1cjMOmeOdwC3wbMestosTcVyeKhreN6NB\n/mM01rxmanvS4Qt4UZeeVvy03GKIqoagOSji7VrAPHYxiMsk3MnoFBxDf/4W\ndb3nm2f8Uy7N8SHhyK3L4yZlHOJdfJZNOPaalFNFmF51/5CimC7rqLJ0Eqqx\nieDHzOxaQJNfn7kHvla3J4yoS4P7axjFK7JAoscXaqa4OCF/VLntLKrHv5/A\n69WbJ5uSTbFOkV3FsAkGq1XbLwTZxShASWdF+kZQxRlGsiNrtpogqXbFnMyo\nsJ8Wd5zcau91DeHlhUqWpkN9IhTO+YB1FiEvOXNyro10OkBEXQkCc2MWDndH\nkhlnLjHGvSv4hk8rp/ymT+YszKINjX70Opvy+0OiTKI7gopVhwPLO5maI1kZ\nD40O\r\n=DzAC\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"641b0971b0b5775002819bc2fef5a1967fe1aa36","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.2.0","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2dcb984-1593193095672_1593193167959_0.27372885831002725","host":"s3://npm-registry-packages"}},"1.1.1-canary-0e0453a-1593200935579":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0e0453a-1593200935579","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0e0453a-1593200935579","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4180838c15fb8d5d78a253880176b77b7242e0c4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0e0453a-1593200935579.tgz","fileCount":8,"integrity":"sha512-r2mWU/RmwHFgL3Nnu+Q79QEzIQIQixqJ8skOUEG7PRbdHKrujehku50yZGk3shDlVvX6qzufQbTt1Vptj/5GWQ==","signatures":[{"sig":"MEQCIH7TTOabXNFRD4B1Dp8wdDVzF3sm7Faro3NoC9X/LTmZAiBDvxYPWg8wqLMRi7jWQmLlN6gDFCEzswClRxE8Mvpz4Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9lFWCRA9TVsSAnZWagAAkRwQAJRAs/2+3VgtpHImnAUD\nZdM9Omrp33A8Q/exisCF8ZEmEnnko8SwO37wODnpimMWzgYHvx5cEnbdiD3s\nl0dHGvZHLXfhHvIOziEQMi2ExH8fd7sNIowTmFdRBLj7TATbGEzDDt8/fBch\n6tcRvlvO1Y6iX+Hq7lVYPnKl2LrLg9qiBJYtFn+i+TqDNZ4HtX9BLBWOSgx5\npyClxzF8DWfbxoTOlDsMLx1uFlFlza++Fl1SiAYDuTMA16gd/sbWwuUnEIKU\nDusbX7i0EoL8TjnW2P6B1r37fsp6LQSZSItf1UvzbMeXpuZdtC6IPOgy1sUC\ndCuO9zvL83SVGkyE2RHRywclJRuXgFh0oOUB8Db5v5qjLAnem1cDNW7TaWAI\nYq3ML6wSNoSKooWWe86nlXnbIZB68eoGjRzeJhUeqj92gBl46Q64c6ZR2PMy\nD/PDY+aIuEIR0MVkVi5q5o6aBxtNXoivUy8Q/YLhFliXym5FkEepi50rhhTC\n7PNF4e3OtqbqVU7Kjy0KLFOZLQkEFDQk0sO/ddu7dcz+NlesaIb2BynnOeEE\n3/Ni1fzD5XM4Mi2r2dKy4OK//QV++15akEx0RodH71h8aeKnmpePde5sgpEp\nwLAkFlu6BKMH3mBXcFnpqfqLd0ZoW2Tqp0P/MhhxMrzDO4hcwJBu2dqthTiB\necS9\r\n=bPWf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"45802919a1f4e1ae51fda7ab5a83da4a4857a616","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.1.3","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0e0453a-1593200935579_1593200982214_0.4822393498315982","host":"s3://npm-registry-packages"}},"1.1.1-canary-28381e5-1593348286133":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-28381e5-1593348286133","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-28381e5-1593348286133","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6d62fb1b5e407135dc3a5396a330c50a7bd874a3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-28381e5-1593348286133.tgz","fileCount":8,"integrity":"sha512-R8kJ/jLDqKR47S3G0EEJZY4WchJMe7OAjUFF2AMhTH9ZFEqhPyFCMxSCgc0qcFgQ6J4eKHkG/B7elbX7LMPqQQ==","signatures":[{"sig":"MEUCIQDN3CHiWVuOEuZXtboLjBSULxnRwkjJmL+I8LcnBHxgQwIgU1NNo98F7e+qCX9iv8UG43Lutf1L3RJcX8RqyIKqbaY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+JDuCRA9TVsSAnZWagAAO0AQAJjLBISn3gbFEk6GPQd9\nR/xUTh16GqKIJRIvKhsl+s9LLQILPbRgQRxy+50SlQbIqFogpcNnMBOQrOTX\nlE6XgDauFSHeBnYcFR+yXD1TAts6npvAnHpTF479PHnZqbCpsaRO7MtAEUKZ\naZ09wkx//MOkjNepNn52hDCU78W3JMRtnSqno+we60GdvMQggEBHm3jR05aU\nTu93KDVZqIiV0pMKhytJFhwiPjzZBBTntPyOHWRqv859k5jsRRmQwCCBPF7P\nBK1N+lNhsLTLE0NEhSpmm3eljvbZ8+RMPowQ2ZAVtX916h2j5UkcwhbgYih0\nUL53adTL2kPE2dCjZMwkv6hhjcSr/X4vN+EsPikVyZmL23hx1zY4h0dZyfHg\nGlAbLU2Iy5nzzjCKcYzDyeTY+DG7d42Ors/aGYXreV/ZTEStpaatFfShPJ9P\nuC0Z2GUUGioOl5dyPHyhVgDCvheZqgmpMdSu6ACloNPt14onHHYo2D7J5GZk\nfVHNVr8DJYMSOVWsg/u76hmLNQaJuww5B7GFTbH2gLW2Hl/cCNVDKRJ13vxW\nJsnGiBz0nRnbB9Q+Fu/6EEUcxn07X5D5jWbyn7UqECr4XuYrIQzm9AxioLtL\nzNLn4A030JKmUOEA/Xz1uBxvttpxXpa5/++VLTTamX9EB83XFjS6ggL+JRky\nsBeN\r\n=tI8S\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cb9c02f6e19f4269a0bf4bff77effd2369a906f9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.2.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-28381e5-1593348286133_1593348334247_0.9930581707968835","host":"s3://npm-registry-packages"}},"1.1.1-canary-02214be-1593394297099":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-02214be-1593394297099","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-02214be-1593394297099","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6ae08e4d45d77a567a7d2c4154e1a7a185abfd79","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-02214be-1593394297099.tgz","fileCount":8,"integrity":"sha512-PpRPhTXkgO1Ytx7NTrRjG2YEBPuqKEXwnU29VQXGke0WFCZTAVbyb1HONWBJV7B3ILFjEL3EZJ755HveJxS3kg==","signatures":[{"sig":"MEYCIQCmYHOpmzBRKO5iYx9sU9xZeOYjh277KVBmz/uhYlLBngIhAMB7CacBO5LC7gpx1wF/q+F64/oAsYB4az6nOaB+o+Fa","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+UUICRA9TVsSAnZWagAAXJkQAJeXQZOFWx5Mf9Uoaqku\n+I8XbMfjnhw9kSrf4S0UwNXKIIrbGU9WgL1ASYO/6xf/2M1prGYwaJBDfowr\n7EOidiyiObOhszunsAk46zMG/E5FskaCnUC7bGJUs4p/n0YBvta0Qy1l89bj\nxp91GpMQ+nBolRkNw8pCWr/yTIIu/vxBS11YVT8oz862mn7MqBXFYZGIrEV5\nVdAIFd09QcRoPQAFu4cu2CRE2RM9Ed4xoxa6R4k1IKr3L9NdmN8G/NASYPPO\nYoqYZalTx/BYhfcMHM3TVB7ZJAetuWvga7/1e+CairUzSOSk4DoXmSUmBmbV\nQLBrT7xoguomkYGQetNiATkg8rzjoGlIFa/lf9pOFSkZyW/qFsQEmy477/DP\nVqASUq0hGcv8LmBMJ/zXC+BHeIHl5Zj/Bc08zQw7QQwoBRTJn2TFjRpTbtyQ\nX6ViJ2sIDZCYeZG8JjBDuxUvVuFY4Bpn/mFZw323xri8GL/hJbqOLzLJSlSm\nu1fNy43+jjLQaLJtuW4SMSRmP7k3K3JtPmyGwasRKNvTgoYCs4ZdSIy+eQZe\n2rtWHx9bfYCJeAnVO0uILusy/7ytkG6DIhxRExYg0oO/lqzmwOGJ07q1OzJ2\n5PeBwnOj/5H9Iq/XiVJcPoxQxezIsyZW9w2gOiq6S8DGnoPF861iHMjK8Nlg\nnXjO\r\n=/+O2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b7a7d5e216b99f926c508cb98b1d349c3a98b719","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.2.1","@iadvize-oss/eslint-config-jest":"^0.0.5"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-02214be-1593394297099_1593394440256_0.4982076163709417","host":"s3://npm-registry-packages"}},"1.1.1-canary-b4e7f51-1593435350066":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b4e7f51-1593435350066","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b4e7f51-1593435350066","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dae8e88df589b4a64ab87bbd2278b1ceba509b9a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b4e7f51-1593435350066.tgz","fileCount":8,"integrity":"sha512-5CpxR6a6eY2na63MKzKzW0wjSG7q3lEseS1+bToZppy5ToMD60ICEdTA80dtVZD7fN83oQ4YE+MSIE99tVmvkw==","signatures":[{"sig":"MEQCIEtHVdRcndbBaj4E7PjrLoB3LJXxuZIMTGUMbXOBWMLWAiBNTGjRGhh37PRCXWynb2g60nDdTlVISwiRiX+2fEn5yw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+eUYCRA9TVsSAnZWagAA//MP/jJ95+bQQ18D6LNeZdeW\nLMEu1zgZZ+5AfU6TITvkXCf/UymRdXXA+SloFdhlexV3tf9uvqy6qcx9lwrB\nTiD4ZkH6H8ZwdSTAagGnCk96Uu0//ZEx0pAzITc3Z7SFOBZ0YU7ckxacSgFf\nZ+OJ6d+hBPMCBk63ToQg9ATo6sUuLrlq37W0rsizz7904LSbsCykdG/LJ9YW\nGHND1qA1OyCk28FqOLwB/f2cEOwhPXscy9jbQoRFtumkPhEo/4cbr+7c+V1k\nBhklCLieBf+RJ7A82h6JU3QE8muZiio4sv5dy2ysFfMhnJbbm6hjozamdGVx\nPkvMdf9Cy+sfnwAGSWujSK0pL69HfcHgAGDdrGbZHQ7uAVSbFqyaQbRTp7Wl\nAmGFk/pNOY9iT0nJKaJUeUIjJBsS24rYHSCfS86AzPYHZktFiVHqveazhjh5\nF017jjiiwFBhwR9QRiak+puZiuw+np490g2l3JaowE/NB0CGVoEj11C9rw1E\n7iYJHM2xssC+6lb7zwl4QOVDIhZfmttVj9Ps+/0WRtH7ZbLqXQApb+7m+csJ\nT3l1cplZYauC/PiO85tLH4adhNszUvDLQW1jQS144dNObPnpFGZQ/zndY/o6\n+W82Vn2AUIfh3Atq2iaXonHu3LWmKlcUJD+9xeGKDBDKV75yT2K7XW7kwGDg\nbB4k\r\n=0Lbo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8c13b0e37db10db259f8e0f7fc15fed8623027f1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^1.2.1","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b4e7f51-1593435350066_1593435415608_0.09609764719196279","host":"s3://npm-registry-packages"}},"1.1.1-canary-30cf674-1593438454258":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-30cf674-1593438454258","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-30cf674-1593438454258","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0b064a8c54e8060d502c42cb333fef2804eb975d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-30cf674-1593438454258.tgz","fileCount":8,"integrity":"sha512-AdjS1a0IB0spFydg5TSRuoGNp/VY7sSsneiIUo7n/vyy0p1AjTlbYQlkLAjXgntitB41i81DGhjHgrcV+K95Kg==","signatures":[{"sig":"MEYCIQCfz2B5PNODqCJ5/xPOnL0/jEZlf9iatBumXBZ14AOxsQIhAI2DAsmEKDSSCizpBIOm8y+KRAJxx0nJ8ODla2iSP5AT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+fEkCRA9TVsSAnZWagAA4KwP/3KfEvV8xoUzM2YY6TiV\nPQZP4OjKHJS54KAtSoQfj6DG7VUnbKo/LPN6vQlPCxcuPvkVA1WNn08JO15N\ny9KCCZgO70caiEmQ4BTUzeNgV4y6jHapdfXpo0ayeMZSkc7417LMcJWjIs/c\nBxjs8b2z3e08YwidhqO23oErJUWZueAIqVsIEuQqBjXXJGchpzdX40+mqlB4\nnEkcXTuFF++EFlyN8ViEvOhYjUSsiYdJ61uhCoQn/MqkVmpKBzZAnFQQpFFz\nWgkf/WSOBu1UMu6cZO/foFFjCEvOBJcxo3SMx0VwZR61DaoMV9VJqQ33i9dT\n6eM+kFevUOEYiPRRWyKk2b33frNLc9UJJYuT6otvE0RNSAMPDF3NrXZ4uL5n\nf97AZbz6fFXjRBIu7/wh7wEIS0/cFi2aoGW0m8QxIyT99gEHoUxIDeLSTsIO\n2i5RBvNY+09mJD8w96IHOcVWIcES/1fw1PTcYTTqrKnt7RkFUCrLjHRy5rVm\nC4Z9m8lhGKsxFFCf7FwITt4GqM8ytoy0/vXel7oLqTYD8pL3NsNGuiopDSQf\nMgz3C2VZpiGdAN33wIzKi7EAYCXrKrqRqksI1P+fn2bOnltTTb4WP9vG5O1B\nRt2AvuDNWr26sUTa6gEshL8/TS1wtvZxKoCMc5Ej8t9chL0zvVLAI7mwMR13\nM448\r\n=AqDd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e4592480a9ce47312d8bcb323953eddd07b4a8ef","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.11.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-30cf674-1593438454258_1593438499902_0.9787884412022774","host":"s3://npm-registry-packages"}},"1.1.1-canary-a143360-1593454105193":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a143360-1593454105193","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a143360-1593454105193","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"577ffba39ccf75e4ebb2a06969c7dd261d8ec1fc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a143360-1593454105193.tgz","fileCount":8,"integrity":"sha512-kSSzkpWBcoX5HLdRq7d2tDY06vFxk4DyQhS3mNmAgCrh4xcLPdJFnTAFbdVH3mKqY/XoDUD9SsDbkAXNXlxwKQ==","signatures":[{"sig":"MEUCIQCIV61j7Boj83I6RpwhjirfZuIHeEcIN0prLnU0WchtugIgO78g3e556M7CQgzvuutbDtlE67MsZEomBt3glMEdDhg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+i5JCRA9TVsSAnZWagAACEsQAIp3yHMTehSEg7tk/Psj\n6QhlgcLEOCaZrHIGylQldCEdfu9pfvdfDwTguxk+hTW/SHnEpg7Lo5u+PrXE\nXvyVexqNdumU4nzq03S1lWXT0xeBTZtY1Gg2YYBOP5eLlZBsNF6zxo8sgeiZ\nONplBiQFj1SADTQ/PgDn147tlp/qhiKkphDEUV9o63Qk2IGP3giHd6CrhotY\nMD9izb3wOMnQkWhp+VSqL9NFFcX7chIVeBn1M7acJQXqZzlM6NacILq2mM77\ncGyv9v7zmCxbKiWZY8knkOrUBeZv7cHJvVWl1HasgjSwOiT68YuEHSZ4b7Pc\nS+Z442v36rFDF7E5V96+G3w0DRrW60zPVnyh6hxkxSfruxzl/SWuXJRFy5xw\ntzEYMYG2CNFG5IP+q2AAv8OF2YbJ5d7otVDRuArwGSn9y6vT4w5ib9cK1Nrz\nu2H5sKNuwFiXO42t+hjHHWrmpUjAKAF3xrurWM2jzh284JbrH2bbMJjQCCGT\n77TBMQib+FjOmAsyJtIh65QShx2p0jINqXZQYfX1Xp4JkrBSORlnwWB3q1F6\n428m3jEspY8oNcaWpegNSDAaVfPWmzjU0mdmVBUwBHYgxNm3t07L+q5QwIHi\niAxRCBRrJM1yROPAYYo2FhSZP0SJxozEsnJK6yw1iTBrfmNCjCn1ePYsDSHA\njHHf\r\n=v/V4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d1cb64073a19f842aefaef8c4db5e214df88f375","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a143360-1593454105193_1593454153220_0.03994227344069601","host":"s3://npm-registry-packages"}},"1.1.1-canary-b234752-1593469078439":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b234752-1593469078439","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b234752-1593469078439","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d49599aa0c0fea216e75468075323fa0b8101291","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b234752-1593469078439.tgz","fileCount":8,"integrity":"sha512-kTPj7QAetUqlD2zFwJyFRRRmG0KLkW9U9dmeMzQlS2K/GhAr+iGCU4Sp+nYmIgAiJq2PSWIcktcCyn5G18rWBA==","signatures":[{"sig":"MEQCIH8XjPujJX09OX0bbZOTGxtWfOduYcac/PdSKZYOs+GqAiBHgt+70rsWduLb+TUcAzDKMMuzDMOePkhIfh7UaZ6ung==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe+mjDCRA9TVsSAnZWagAAmHAQAJ7IjU23GNk+jm0MJeeV\nLTaum6JrXJ8agwqFKHEs08jCxjFDsR+atoWzoXT64LxvIGsy2ZEtEAkVQ9Wx\n8MiUdCAS3M0jt6+4Ix9WELuNYKrndSTjXJP1tRSvr5RJPDPIZNAWB2Vew0t7\n5YQ+fbghombVIFOCrTUqL7q1lTtWwc3KR3MiPzowyaOIOB8EEPwVd5r96UUU\nFR/jvYzNxddkQqFLZathXTItFRZT+CccpsCW8oxvsaYu8vh+sAEyJcnViuCb\nF4drwPkKDNpU6lF1xLtvBEM8/ygb2xXUMTdrctvN3SlFsJHZNHaai6pVWH9B\nPR4vFQ2O4JIPLf70OQSdCCW7gfvBB54OwRZUtqXI/0OUYRcRZA/OHU6Xqblp\nBrGoYX4a+LYV1i94YV6Y/cf9Zpv+78uXCLCApbGqLoUGkZ8J6SgrhbPvmFz2\nsnsXPr8+eii0ON2P1aM3QEhHGbiFfaLU/ZRRw5eqW3/RnhKvc52Ydsm1SQ8x\npw725MstAdQr7vxDD5Gjxq7hX9WCs1tUJHQZNZSQIhmdZ0n7sAMJosC4F2ML\nicbFUrohlNJric5NFSzHbAKlW986zWh2sMHQOS0yGq7HUHQJdArGrnsO6bHx\nkogZHLg1j8QSNAKuG/VTCZW95w6d9gYuQtjyNAt4ecWqZoqWdQuSgyRGyla5\nXd0G\r\n=MJqJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0f57ab07f2ebbeaceba1608f271602296d8d8d0a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b234752-1593469078439_1593469122839_0.7766141461006273","host":"s3://npm-registry-packages"}},"1.1.1-canary-59e8c5c-1593636922345":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-59e8c5c-1593636922345","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-59e8c5c-1593636922345","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3cbae0377dfacbb82d1b68c4631f132579279c93","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-59e8c5c-1593636922345.tgz","fileCount":8,"integrity":"sha512-+l/Izk3yICR/KTbog5iySi5jjVuQk70frMqMrfh+aCiSsXnZzl/+/c/hNTyuuVm0j1AKmZn66wC9pvSrFWcWhw==","signatures":[{"sig":"MEUCIQDpYddHb5CAxLckNUMEFg72rFC6jmOW/TPX2gEv58BFMAIgOPmER2DsnHr9r3CiWDMmL8VOeZ3SUJtZDr47LtcQwuY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/PhyCRA9TVsSAnZWagAAv2wP/3+O4AldptAtUNXaIZEk\nhMGErxpBwGvWJPNA2rIvX/KOkDkosr88TFG3w15+tyk29g0YQkpVveak07rr\n+Y1MgiexiYSy+Nsh8XtXQbUWaGq/G12yJAkd3cGGMbEUy7tKSwPUWdJdaG3t\nCRD4V83f7MVW47r4aeoZoiE4X4yu8RRG4V7kNKx/KwR7nlY2+MOpLGVXmNzQ\nfP1N35QqKcim8xWjaHTo0vpljVUJuCfueMkKwHYWsz+E8D4/faiZS8wHxh4h\n7qirlcdIe2nHu+OjdT5LZmMkwZhxuPuolkTo6Olu9Z5IFHJAr25G0EyVQdJI\nffHjwwsJCJ9uCzSEUlzImUNZxTwpXurl3LnyA5A5fUb7JPCg2g8//8XrDmW3\n60g0Rb6nKrm6tdZVQwQyyFhAf0fr3xGvBpQMfdIFOUhJr1aP1Ej8fE514WQr\nfrMjVhW4EAge0Ri38RjjW5FXo2Qqlga4WGHPNGw1qVNPmRDfc6kQVNeRAduB\nz17MuHrZ9mZ7SPijCcaeWtCmfjDbwW1sPVQVmmEqW7Vy3VqtNCKB41aWyutj\n+T8cDZ7jnDlsj+BpWkEBGEDtjtp2Vx/Apay0aF23/s2+9Eda8MGaOF4GHiYo\nC8fZKe95yCqDJMtmGPfbcrHyK2d8uULoQwl4uBy1QgbsChTAsU+nQpn5+nJu\nthTe\r\n=sZSU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ed0c8e18001e52e6e9f125c72f6ffd86f8cede46","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-59e8c5c-1593636922345_1593636977850_0.7776440734917129","host":"s3://npm-registry-packages"}},"1.1.1-canary-9048baa-1593664043026":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9048baa-1593664043026","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9048baa-1593664043026","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"db173d46212bbc6ff4fc122a130a6e8341ffcc4f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9048baa-1593664043026.tgz","fileCount":8,"integrity":"sha512-YSbfDtUgXWn1QG8fKe9lOJtPIWFe4V9b1DvCAPr0/61lqlRiPQvYRhUkGABBvuC56OBm8LqIogENT1O7w0zxrQ==","signatures":[{"sig":"MEUCIEJg20z+MDU/PHy7jm6T8ztt++WBJn+GuU/Z1+ILkfQIAiEA2yC4XyeU6y7b6HaBH0vS0XDwDe6zLbLY2VHMcz8MjVM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/WJbCRA9TVsSAnZWagAAae4P/Rxikl39MAs7yNM0vutq\nkQPZRPSUM+iOxxb/qS6EMHMXoMN4NbAJuXI2+TwahPqy1Et7OSARWR83wVNx\n3AvDKxdibiM2KIk8EU4+Aj5d/5tgjbfflYq5MHKsTcpHP/8mKxfZ/eUdhDss\n1B4lN8kBtLOuxTlncyoPPAQBrOLEL2Uy4bd1fZx6bEvgpAB6j86U0oqCHh96\nlOTvMP65ZKgrd0CseSreNWCUEbUtej/OUiP2mQpNILuRdkGLvnxoK48JXrm8\nuRxTRxuahor3InMImCZkFWPd97YtyYyVnP+yJi2sgBWtWlt2s6uzAKm8RAQE\nqRWfXm9RVWh5/0OhZM8iDhJKqtmkESrHjEvYyG05hLS/aG7LYWRieyaV7YvY\nHID0tLQmuQXebl5VofDyODb6cy7rJoXKgVLkqKCJU5o2lZTvV1Z58P3in13X\ne/2sfQY4hS0z0ljv4rJK4PDhnB9IaznDnyieb6Vly+K++8JJMeAx+v3kkl/y\nsiMnwztdplpHgg1g8sAF2xaCpYtxL/TE3CMtKjAXEHjoaxjo1b0+yQwy4MLW\n+LbL7Eat8lkwAUrzjiYkJ9lrTlgNpWWZEEitUkjVjjm5FkUqXhMo8wcqJAKw\n4/1btFLV4Uyj5MpKxRWHudeJL0e/9kXfPOZeVPSF84HShS6PhaZkRNz+ZGpr\nW3pe\r\n=PwIM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6b80cd4209989323965f1d3374ebba6fa78ae792","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9048baa-1593664043026_1593664090996_0.42335922272048476","host":"s3://npm-registry-packages"}},"1.1.1-canary-e235d2e-1593710139329":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e235d2e-1593710139329","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e235d2e-1593710139329","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d041247ef3f88d060a946b60691ceb0e5ddbefe0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e235d2e-1593710139329.tgz","fileCount":8,"integrity":"sha512-iloyfywCqmOAGVNQy/TA+cBlCCMvdQRIFQG6SMC/RwNu6X0yN93BZHb7n9y2jbwygYOXJaGwrpJwzNnhgnChMw==","signatures":[{"sig":"MEUCIQCUI9SB8nZ5vUm3v3gY1kqdgrazmsvGGTJWD+aVgEGdAAIgU7ZWn3LMGc27WT7vbrOkxTrtETfeQlFlY9v8kpRCLT4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/haICRA9TVsSAnZWagAAfI0P/2poW4XcwjiNmU6imFnx\nz4qElLPfy50ooGHbCP06+JtTLhefoz/Bbz+HtL5SpGZLkGSv/2m9N9/fbbo0\nfeVKqDRMMo+5OsjRJVGc/HgZOpUC7yHIjRA7bWeXD3S1/OHf0SwSyg59XUKw\nFh6aU1bhxyF/My11rqcWVlRZErSW/AdbLH9h4ooOGtxLzUodNiToEr+T7ib7\nplSCKIzxOqul3h2370q49VolZ7e/xrDMHIAqus3Uy4POtkSv78VPmly+Ga0l\nEYvyyCI2CxRkrVqgkvN+kgHyS8R3AMdF7H/kFE+sVDiEPSVsHFEVZB2qha8p\nZfUJE2JlhrCVfsB59KAtOBuJekgrOGVM9sD965BnRBMSJmIuMmo0ZZZRgCq0\nChFc5pdVYJEERj2rtyRUhILFejHajOUKEi0ccRpS5yMY/NMIunhUFUMoSWBc\nlmuI1Bm2t+4Ud9N4ATODXQRR1ehLAkI+sWB/TjlRx1Bqgeo3fxYy2h74PYtw\nxgLsvVcPEHSt0Sm9p403Bwlc8AyeEULwgNHzv0MMv5ZMaZoZ9PTcqk3PXyNu\nxzZkftby2DMAQUg3fZKgO7amz1DbK/wrleIxrKlehTRNX1PleCWkk9sXRm5n\nFDuT6gqKxrEGUnkhUOAFjDobHuD7AcnsbK/IEgWefmQuhp+rGbKido+G8hdr\nUpu7\r\n=zBnM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a2f98d937f6668d8990e03db3d504d5f9bbb40ae","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e235d2e-1593710139329_1593710215923_0.3149061296619864","host":"s3://npm-registry-packages"}},"1.1.1-canary-89d55f2-1593808150498":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-89d55f2-1593808150498","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-89d55f2-1593808150498","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"958637e7c2df46dc889526fb53ed4972c9e93d91","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-89d55f2-1593808150498.tgz","fileCount":8,"integrity":"sha512-gMa3PiiHSnUlLHn1bitC+HCjg10n4Ewtw6Q/si4ly3/qjauan6k6c4YT8FFY3/jCyn1BMV9TuYfxJbii5mEJrw==","signatures":[{"sig":"MEUCIQCouYJBPBVl5nUE8qRBphlFewrceyLto4nK8M11BqG9zgIgN9Xz7Ugi+1A8l3KDEmBVeicLTW2CJTSQOQpJJIdM9L8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/5VLCRA9TVsSAnZWagAAsu8P/1F6CuUlXf6Lqnf8kFqM\niq3CFHREIgKu7pric05XUZU1OqQZAQGvYpqShh1JDW9GK7ElfszsMiSlrkJM\nu4x0fWwaX8kY3BDXCfseI6g1+M3Gik5x8cPS18SFUi5T0otCr9gquc0bPyd+\nLRJXhywnHSlizyiyWAqGn1AJyOBJXd9slALdyhxM5qJUZ+rJEIF/A7od09DO\nuObbzlniuK3/iTKCg+jUIpmiYj5NysLEu/ZC8k/vTKPalWm/AUrYIqMDNBVl\nTVQv7WH2xVfy/batWkUbewiqCcKdfduH+X2DIjw46/JJVCOADZqnNGrEr0MJ\nxeFp0kzL7bCo14LQlBhz7BCzMWBuBnsHt/s/abVCykqxveHDq4E/GiSm+UMk\nZ3m0VYbPYlNM60Bey1Agr4EpM5A4exVLFqJl4uNYPKfUlfWr4moNf3xdmebB\nwWk5Qr/LawEtxkaHhRgEzRgopgqmUMOh93BjTLtr31ujWNXLp4IF+wu0lg1A\nOH3eUvhxO3AANpwhDPV29hW36HMRF8uiua2Y13b2KzXNO9Cn8o1HVxVqOt7n\nPMTwi6LKLLZZmwvoxdhFU61uNjK9IYzLq5qVBYsmy53yAFM6WwRpL67BOTck\n+zgXcM3UjYHOIRL9U34H0KP/xg++usQICeUzQc0VtTlkUD0tGfFrGNOpeZKt\nQ3Ti\r\n=Kd7K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1ef8cba356c2f1bc55569ebffd256ee3eac55171","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.12.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-89d55f2-1593808150498_1593808203128_0.25104992282657634","host":"s3://npm-registry-packages"}},"1.1.1-canary-13ce33b-1593860332468":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-13ce33b-1593860332468","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-13ce33b-1593860332468","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"cf3d55811d56df60c743197631b70422dde728d1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-13ce33b-1593860332468.tgz","fileCount":8,"integrity":"sha512-Ab4qg/z/DONb64h6HK7xRZDXRG57sPFielfq47qfXMJtLIdM20AbKNTYZEDEVhSi3kLU/WELrzZX+bIShejccw==","signatures":[{"sig":"MEUCIQCY6YsxinZhSci8cShAVk8dmvzV2myIliOgNKcBZ/fxwwIgCzQIYK5LegKDXQDucVaNSKVZm4YPDEGXr8wPeHgn/ak=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAGEcCRA9TVsSAnZWagAASkUP/j9WAnzmrgELPVkzWZSg\n+M4Jcp8r3rHyOYmDCx3B+xn+6T+DjuzBrXrIPMOmxL+5qTu/4CA9El7CIELV\nFBvzqiypl2Bg/GtFh3JH6lPvHuOAwDLzg68fIxZ3zKC5sJPG389ap8FVXQv9\nZfx3Xz8BlwLEp+YG9jjxdMNwvKnZG5MCVlU72ayyXpu9zIlKL7dhxYuzs3M7\nzufSqR6emXczCfbAsQHKONP6390jAQhTnKCXjMIQWx8if6Eptpak3KO4yXXq\nBM8y3uwaFpLN7ONOspFx6HqohfCaPQhwcVUsC9LU1v07+kC0jwddJHH8RP10\nrPMCR0Brfaw4+V0nzrthYP4OVdgnEs54UvbYSUJ561cTAdjc1dWao4FVAhY/\ni/VXucFhH5o/axGiQPP7WBO53COlyTJVzv7L9uvH38erUOva9tghLjx+kU9Q\n17ccZ5kQ9CyVdtDvKY9/GpNvnlLKQJ/aPhyesJYhzhZVFzZwvmxvtlPOcTRr\nZdOHHKjKfgVobrojcecS41BISjV2J1qRTFvowvGBO7npJpYgxhFZUKuHas87\nxieGzYeaBgFer8P6LXLuxBNeeSoDZEbx8xOOKFw5nrXeJIzHMGPJR8Me8rY3\nfx5rS/vd1YC1JobiHINBo7LPerNcfyR0TCgTy6WskcGadU+sABSrlz773JCz\nn/97\r\n=az0D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d39e6e566cb84760cb42aeccba357340b392568b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.0","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-13ce33b-1593860332468_1593860380077_0.1487237203332421","host":"s3://npm-registry-packages"}},"1.1.1-canary-ddbf940-1593865597717":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-ddbf940-1593865597717","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-ddbf940-1593865597717","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"05d36c4899bed2004112465e4539c39d866e9280","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-ddbf940-1593865597717.tgz","fileCount":8,"integrity":"sha512-O1Sm9HDp0rXE3glgLFdAOiaP7Mgy8vbnehDIOYGtAfYOtaSmBDpK02tkE5XLE/nVZs2Uj5HqX/tizmVeh4p/hQ==","signatures":[{"sig":"MEUCIQDvpQUSfWzjI0OXx1NzSTPWT9T8D97in8otuVqjOGGwcAIgQ3uru71lOOviMQAxp0sL8pv5Fz8AX5Hy2lHMBJsNz8A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAHW1CRA9TVsSAnZWagAAe2kQAJgP1Di/5/k8iaWY7TM5\nPJQjSKx2mqOq4+tcArqtoz1u6V8HPasgYk0tihXvZcW+l9o+50qXEi/GvHIQ\noMJj5JYCfu8QFSQuMfsCDbO7VP2Jyuz4k+xI6vQXIjeCZYQXcr3W9YXKMdPO\nQsvIJUYvzDmnaCPoeUDheZqfjd9h129a+Qs7cnp2CBfY8R+eQlAR/HySakEO\nqC6TwW7l4WmPDIamnWBqQhGu7aZNA6gTwMgtE8jT5yz7b09JuyPF7YfXr8z9\nkPnbtUYfQACLWBUcAQYJM/ERKNgLyw81/uoel2+jIN++eoDMAp/nczZOru1u\nGieRdl4clyyl6pP/f3dnFfmklp1rlVZUosyl2bTCeVkKbziaY+fjkyD71ol1\nDgQ+IS+XJO3g0LObl/8Pmok4cXfWYxAkR4YlRnLrO1rZUJfPDmMXoAotJIE/\nOHkGwmqxBSN1ccIsDrJ9YBz2G6RPx6AbkiM8NQTn3hvptT/poc8bBAV2FS7J\nQmFtdavbLWgkCu6pl6k/XMurvDvR2Mw2QhLKI0LT/mw6pOtwb1NXRe1KfXMe\nh4E3VVG83aIgmAwpJ4CI5nhv63D488HXZ/Z3iKrNc0mckdSFWn21DUr9SS0a\ntkMNNEVrXmfLEaVnx5eajoCwGW4V+p3d5P0xD8KhuvatwV1dasXL3QePvMOt\nhY29\r\n=UlIK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c127e1d03beb9657afdf014c997a69d4eb6cae82","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-ddbf940-1593865597717_1593865653403_0.9692370981557368","host":"s3://npm-registry-packages"}},"1.1.1-canary-b290deb-1593928066513":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b290deb-1593928066513","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b290deb-1593928066513","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9ced65f00c2ceb31b4c2d118cbac2c5a3a8be7cb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b290deb-1593928066513.tgz","fileCount":8,"integrity":"sha512-l9qsM/ne7GAGDWcHWYuqaX+sJMrYgvnHIFTJ9SNL/9KxnV7KeblqwdDkhPbHUVPu/hcHODEnrgNgA1xKkgDq6A==","signatures":[{"sig":"MEUCIQCN8DYmr1qJf61NQjjhQTOEgxWkkri6MZ0f5gTDc+++vAIgMjALlm52Rwh21dNt8ey90YLRAFrZLSEPrPYlBg9DIOk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAWmyCRA9TVsSAnZWagAANH8P/37/2hIQL2uuzB8nvAbJ\nULhb27EieYPkA1izVpmk5Kyr9WDKgwg8L735Gqqq0B5Fl44ShuDhFQff/7+5\n9v6r0ayi5mVjBGvRKISzMcPukyttBh557gAkku59Y8tZguxct4kvScHYaHfm\nnTnhLx0IiXA3MLK8efS6Z4AuJT7mnMfKf00eLfqhkDsXR/FNlZQ+SwgquSqg\npEUDIDLro3e5NS+lfwGD5aVhm3+LHKj4wSk5F8GwzJQyqT5xXjRFlMMgoIfd\nSpnRvhvxIpmO7DDL4PFQTrIde9jEHNzYpu4gr5Ri3McilOz9IxouoHwdt4Ud\nQeHqBJzoJ+dh558aEnYpriFuzNLyFw5hqcymqn2SfcGIS3QihdaNLKcT3UkU\n+nfxOQ8i81iG6TUckTthVTd0xdY96Z7O3t/tMQ2FG2Jmu6UjwVSwcRZREM//\nYTGq7hdH3YVXD+gDjXR4OSPjuGlAamAnat3BJl8WOhqfpAzRMHgaEtz5SCx9\nEgQuYlkvNYuDQ1Ou+QzpVSK1BSg6/R0/qqVAfECsbOXAyvYfI/YPa7XTv8tp\nPv4nL8wWt2y74xa8tDoDUZh3l98jk1etxciAv7YhPprS4+UtevaFD3n7tLa6\ngImPJYRFr+RTn/VXz/Q3r8/DroTgaN+XqK9CW47tVnPGgZ5bmrZ9i/0exHOC\nmaFn\r\n=2uzW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"992a5eb35bfae4f4d79dbf71e6d39559ae99a4ac","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b290deb-1593928066513_1593928114293_0.6578163128474319","host":"s3://npm-registry-packages"}},"1.1.1-canary-eeb26b7-1594080074979":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-eeb26b7-1594080074979","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-eeb26b7-1594080074979","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f5b746a2c48db70680c14a8a2f9fb7ef05797749","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-eeb26b7-1594080074979.tgz","fileCount":8,"integrity":"sha512-SBnRAdinKNnZhDEF2k5MTWGOpi9NC1OSGlQgI6PJkugo+IkBj8hdJ0+heEwF3UK2jLI+JzgndfwfMN5T9QMKNQ==","signatures":[{"sig":"MEUCIE2CfeE4evyWF+7maWrvUW7ujLtp9rl4ohLCMjllAQ4tAiEAiz0ctwZcsf9AcaPi0XuAC+AZ+j17Ge0xJ36tIwKsfhg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA7uGCRA9TVsSAnZWagAAt9YQAJ9aT+RFMepC7cX1Q/7p\nNCnAR9jlEUpVdnbC4fg7TTtkWieqKh2YKuYJoLJHNNzqu8JD065uGKjkTWAs\n2dXG1HubIM3bBWZj0DjeW1pbRUQSikMW+sXliKG4U2Hl1392R95k96Xs3spN\n77BXMX1O9q7eFggUUCvvaaRvjh0gWsoAcIbjThLvB6tw+P1vaQGHbWWmjpkJ\nPcyJ0mYzFNHXK3ca+ObvrCpWMWQqoarsuUrdV2qMzWu9NIw7F4Qbh5zFLr2z\ngnn7AFs32SN0Kqy2Zu1bDAkhURK3winCF0r5Gb32XAlVXNaBrX3rirmNg9zr\nkv1BnKwOkkU3/RRkRh/oqG6kqbj+mo3IqmIhj01KyTwM9I9vr/hZ5g8Btg0b\nE1lHZRFALeVDmeOgXOuuCHWpp+NTBEIiXqWb4v77GZBbc56RHfXT9QngzO0s\n1wjacEJRzgUIbr6DjsbAl3DCNdmsSAZW72/UmGPtBqUp2VBi3aE+m0r+MXu7\ngo4qigvNC6CUoq6twGfYSu3GrVMBIM4a6FqpwhXVugsRDe+DCFP0xIfngu0S\nwvkTi463ifg+GFYmaXUQvjRMSy4utbUwBQ73Tsji204GKZZfuv5YUQPMgjLs\nyPJdIz1iIZpL72B/PWT/iUtk5yXKL3ZcdbfBVuz7bA9W1TF69RIxZamCGRPw\nLcGB\r\n=pk7e\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b1bb7f08abec8bfd853437fa5216c35b82e9eabc","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-eeb26b7-1594080074979_1594080133574_0.16266781714473244","host":"s3://npm-registry-packages"}},"1.1.1-canary-bd11d0c-1594085260830":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-bd11d0c-1594085260830","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-bd11d0c-1594085260830","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4876866b17a77fa8d9b6402fc1e9d997ea8385ef","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-bd11d0c-1594085260830.tgz","fileCount":8,"integrity":"sha512-MBE6+mY8NvV83H0LNXEccri6Zoowr1oz8P/e3vqOuTO4sDbRUBUZBXqXBLeTDH05UpytNIFiWs+gaXiqJRvAVQ==","signatures":[{"sig":"MEYCIQCRXrpcAz3MM+xqBNwvyGF4UgMHBokGqFHRgxmaJnoilgIhAJtQeOcwQkZqlxtGZf9+tEHfSU5VR1y0WhYM6C+07p2V","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfA8+5CRA9TVsSAnZWagAA06gQAIx9TPgbKNPser9pGXcZ\n9fBqRX2K+LMNmPUxIvgj4HzuEGJyah9RKxUWGFAbSWkLYM3z91PZzvL+bn7a\nQ2DgnUSMkxNkISFNjCJplX+I1FHzFWluPTrbvPGezeyToKHO/IGTlIt2mpet\n0CWI3K3Xlc+shoa3yC9Miq4rG3HFYgyDC1ABfTq11EDywOzTbF4x+yYq0OeE\ncOqeKKIvAnHEOeDNvdNFN2grxri5qFz+kzsgNOmlrdO5V/guPik1/EP3uu+Z\nJprF+gFecE3cPu6fPT/WDf2Q3omlNheXDW3s8qW+UqOX6gyyKoutTpm6+DiL\nobny7IwQPyG86Wa9ghsCyRRyQMK15RuHenotQ9w+hCSk3Giqn3zb2xycHDBu\nxAU0Q2xeluBhj/0wTRZz2BUZdT0R8zri0WWRUtUWvVacVznKW6TcMLbGY07x\nmOBPf3YKwtsrUQmj8vdk40vSDBzgrRP92QWdmRFnJr0HUFndO8f8yFCdhh0I\nJbntPBU4lnMlHcSgK+Y/MssjYmOnqx3mHL4YQDqR92RUj+y4rG3/uwgo/ype\nIb/6iL7O4i9WAReQ96/lW+YUzFrf/wR4JRAbl75M+gQRcdVBKB1mypyA+1+p\nNbUdoZ0NyhUGRPGfDveQh1jRKI7Z1Ux/oWIZxLK0Jk1GDU80bnK5fFSq9XI/\nOO/a\r\n=tPQP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cd796f5e0cdcba237464ce086d2dc60d6f4e646f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-bd11d0c-1594085260830_1594085305395_0.048301357043301296","host":"s3://npm-registry-packages"}},"1.1.1-canary-f45a7ff-1594165990895":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f45a7ff-1594165990895","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f45a7ff-1594165990895","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dc836357d516d47bb37347aa6335032bded43f05","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f45a7ff-1594165990895.tgz","fileCount":8,"integrity":"sha512-PJvbfjOZsBkxMy9BVqzS5SBsOCZIpgzt175odOFMoyo8j8ZZbR06ukqoDvRlJpGi94ejLziMUsaQL7t/KJeCdw==","signatures":[{"sig":"MEQCIH8ijv7QVeLBA4LZCRel1TwgAaX/HWEcl2mbF5Vgs10TAiAdaFCX0hL/SmmgdbvLLxKo+wH2yyXSbxJqIUZFbCTs3w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBQsSCRA9TVsSAnZWagAAelYP/AoJIHgLsPKYL5qlRAJ2\n7OoqAIMuaVpLoX7+WA/WAEBPco2QoiBRKjslraGvsM73tEB9Ze4JCFiCJNFZ\nIu1mEC1pYatl1hBvbc+OmJO8gumEjtaAYNk4uihVN+g2Oo74lXncuWFsJOk3\n3Nxc1feUB207MFPDRV2nWm3PXc6N77YOYIeuwzwN1jB//29KSjJng/yN24S2\nDorNJ9ZdU24DWW4DlWOMVyGN+ViTMq1oABaAJebO9CjzWq51DaT0kG/bp77+\nrSbD7g9BTUmxD+Txdpi5L1RA14ifZbALUJO4Pxr3Tp77N1RJnR3J8LHVf96m\n6JuqNvzrLTcgEb5H0UJXmREbvDra80m3j74aqjI1igAH8l8m9qLx9uItMM2G\nmtxpRX2VwP9wR7gh4lle6e1tXWB+a2gpkaSvZrmR+wjwgB5EARnBxKlRU736\nBskN1OKCK6oRdJOv287nxX66OpNH9Fc/+0jM5jo2hwv7Ubqgb6wW6JQKMdBZ\nScs5nBXAUxgyExWkJ6+jYxiP5Vy3cdBXhx9nbgUJGzGKILef6nEZ+IkZlRRt\nyYMQjcyd5EbzY/T8KzusYYyYQ5uYuW+DHYzSwvC+/nxJFc2j+Mnsyk+27+6K\neLM7OP1H7khI/wZEY/0HqwQ5ImNVrtN+0D+PK4+oeiNTi3/Pf5vVoJc/kF/I\nOhu5\r\n=zGc9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1180d761263a224839a080826bcc14c748460a3c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f45a7ff-1594165990895_1594166034207_0.553178965363472","host":"s3://npm-registry-packages"}},"1.1.1-canary-0f25678-1594663692687":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0f25678-1594663692687","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0f25678-1594663692687","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e5c60fc702fc1cb941aed3f8ba79fbf80ef7a2fb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0f25678-1594663692687.tgz","fileCount":8,"integrity":"sha512-Bqqky+tg2GOYTyM1ySL7m21uqWFOc7pqLZgao5/TAYUZTTNy2XorwzHk48EISTuxt0U87AuLl/MABYIIoot+EA==","signatures":[{"sig":"MEQCIDF/VlzZhMNXs5x4muESmg90K8YYsAeuU583gPf0I5D9AiBMR7LNlVCegBitVVWmrZ1gEYSixJrLCkwlt3RssCkisw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfDKNKCRA9TVsSAnZWagAAGrAP/0Fku2XbgWO+2zWgiMPg\nMyCEpRgpIzxlWRg560oAVGZMZHYf8/tclozL5DCQ5i1xb8xUDWiTaN2kVLCO\n3+Ov1joou1ENXcGvuuL0fwB8JtI8vmavf2DIu7xA/rGWR0YGiFp+HbUKylcQ\nORJ7m2GicPqxgeIOhHihj4W/vhBAmTlqkS/oW637PZNnuFpHstUQUc8GCa0+\nLmFIFyNF4lUrX+iv3wszy/XGMUPMBhiDo3RK9RdFohgYbKgoJ66osU67zQK8\nmKcnyT5eCQ9YJHk5PXL4NFYLOMl9j6A5dFOs3rfDNbK+Nc8RpitUy8nnEo7Y\n0XeAGqkBsNY6lnqQ3v3ZKVzqq0wFtmp9y+whjdDPPP859Fs8LdJ9K69FB9VX\nf5/b/JE+91++1LALy8H+MMtBOcp1i9/bb0JuzIa6tREDRfxdFKmLR0++ffYo\nkP1Og0jCejwxZ8go5a4234uc8zLIOlECc4BUxUW3nXIdgedP25qwnecgMfPt\n9ZOrd/KCNJYbKvtcA8XEQ2KRj96BqJtkvXnxM1nGUzIvckysQccys9sJVTp/\niYCQYe7Fyt/YhEBSzdQm6JKcK8y2k4z6wu6sPq0e2jtm/lYx4ZnorSgkkoPo\nNsT+YF+sq5bT2BQ8ExoViLVfgP4CdXD7/PAljzx7sFipUz8LvKb5ZGON6ABD\nm6Dj\r\n=R2s7\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6ed5ba6f0968f2fdc4fc2fe9079ba4a496dc4f38","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0f25678-1594663692687_1594663753961_0.5643906913730223","host":"s3://npm-registry-packages"}},"1.1.1-canary-c5aaeb5-1594857810973":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c5aaeb5-1594857810973","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c5aaeb5-1594857810973","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"390eefdcfc10b3084250816ea0ed92584eddc4f3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c5aaeb5-1594857810973.tgz","fileCount":8,"integrity":"sha512-pPmyLgEyEiDAWut1/WKNrwKNseGpHXsumyO6D1O/bbREcrC5LMKtBISPGIZmIB4qGP8fkz7J/cMYx78+JUMH5Q==","signatures":[{"sig":"MEUCIGNgY6t47w/P938BivrQ4IJS7OVA3pCmG1Fw6vPsJ5FoAiEA8vphTuLf4SMCNenW0QZmiRzlCHiI2nxYIxjcpuwWgNU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfD5mTCRA9TVsSAnZWagAA4TgP/iD+Z801ql0c6Oy9gKVl\nD01jnSUorw0BZ4UcnakNsIviEqMu2lASmJuzrpTJ7uPtA3J26IgSxou5bPXT\nsbABdNqkMiB05Y8PfWvsYJn8PfD5bY3i5ePZmmMtqQY4SOYkmMyWH0+pZAWG\nmfk7FC8m+QInBnYEPMt3b34lnmNdZ/712tL4ovQuWlnDJc7c2bSpK9slTNvx\nkzxCYeooUjzwFHTZx+vU/hRw2fRw7wjbpesqGghJCCeITjGmT2nGw4yWr0JE\nRak3hpqZIJGQKMaiYu/bzRharzL1y1W/3lPZxMrB4d7qGEZXNg39LsQPkwYp\nRQTFwWxvSNaHdwey2QA4tNFRlIbVGm0jSDizrzoVoG3WqI7AIgIiwjqSom2t\npmGPxW03f31JIxyBkWxcgx1xmM1SGMFTjHmsJfDE1HRhjO2LoYb7ir98fL1X\nSvfBBKkmaXKGcH0KDSq2NQM49ioUvmSckYyRQoySYg7/Osn97g+dxH42xt6a\n6nmovNKfQ85H29CVCGewdMbxePTqFnZtDujF51X1v1Lh5KTIK3JA91fDey3p\nAg98hSz4h212xq/0GcemrUoCp/HitoXSwScQylizhnO/FhSZ3lvweVAZKEEs\nMmp9hQoBWidi9Yo/EdySWh/I4llBc0XbkotaXbQ3FsKnd6jGjlljI0GnsK1X\nO+Io\r\n=sILd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"389e26395b3d490c3901c130481126854638ea4d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c5aaeb5-1594857810973_1594857874447_0.44525756076737566","host":"s3://npm-registry-packages"}},"1.1.1-canary-97e0dd6-1594930378573":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-97e0dd6-1594930378573","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-97e0dd6-1594930378573","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"58e2ce416af824633ec87e58fdf9c7d8e4621e12","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-97e0dd6-1594930378573.tgz","fileCount":8,"integrity":"sha512-VYZt8ZTvme0J+OJlW1+TjgvPUqmdQrFmO8jRLk3rzn2nYO941Vsu9jD9KzPAddkHu9KHEKbGZkpvv5rCENZonw==","signatures":[{"sig":"MEQCIFRv8QHif3Kc8iVit5yEsE4NBIEPs6cSs/b4WYuDeB22AiAZ3byyvZsYXwzY5KOthgE3+wRhEszbdB0t5zynKBFd8w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfELT8CRA9TVsSAnZWagAAZdwP/RYc910/HXBcEPbIZILU\nkyVNol6hNhiVFUNg/lMXGeXyqUXmePK75TRyJorN9i9UWIt60kipUFX/CnOk\n66othtS4A3TN1JlheJQLD5LxWtVtjv0vtDDR3GotpI9w+sfDcwGE6rFJMDu2\nsk5s61+lUJ6rUIBdjPBcxHKMzMxkokOkYEgGQ/WFFWg5ncWGrtDB/FFo5pLN\nvC/hqh0S0WM3kdVfetzpLjOCRKOfGqJ+66NdQyZgge6z1hK8kdhLzY/eHYVo\nYP4DGOtdGk0iic+uur2rDXCKGd0J/cFr56DmOeDybdZ912knpHosvgtfrM1r\nODsmekaRp07GT4ja8mYEq8AJdPRRrpGBwjHy94xXkrHVLWOrdvfkIRryMLi4\nWI9hpkFaN4rT/ROWQtHAjle6hC/Vr4WLPp8zAcNbwH4n65+bVqTHZLDRzeO1\nAUIspyesuy4PGiv8u0rzjMwWjjwU7BH7g1Ihfhi/K3XwF6e8y9tbK7WPITST\nvMHS6fcqINYu8wujqUJG3mSg3h7faPe4Q0ML6RQ6rLJjWSBXjlSqn/ALqHf2\nka/0AkzXB4bHPMf/DH9yGUeD6pXCi2q3Z/6w7b4W1N8tfiYOasMrjQbK/QGR\nFfaGfBDMTV8ppU79mFdOPEPFcI1A0jDZx0GkHj2F0/Jm4JeVZGi9fF5eA6OT\nv9ZJ\r\n=yY0N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"10d5024c7f36689424abe6bf9b19c85600b5db97","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-97e0dd6-1594930378573_1594930428576_0.806086638163628","host":"s3://npm-registry-packages"}},"1.1.1-canary-ef3ebd9-1594967039662":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-ef3ebd9-1594967039662","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-ef3ebd9-1594967039662","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"70bf1daa32c5df231b808be9e59a185dda2c9b17","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-ef3ebd9-1594967039662.tgz","fileCount":8,"integrity":"sha512-JrNN0gz/X7qjr//EAKcJf3rMW3a8JpG24/0mF455OhYssjomOtFHYinkxXnbPpwLYgaJsG8rvKPyNwGuG9E7FA==","signatures":[{"sig":"MEQCIFnDPB3mSjeUv947+Ozs+N7o7EkaNTFnmJn2zXXzl8vsAiBeHZY5wMYu3pPyBeLPzRc0E2NEgoPf7op1LMEn0MGzQw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEUQ9CRA9TVsSAnZWagAA46UP/i98JCHy+eMEyWfoHB48\ndbizeurMjJHhjs4Vo9C4ZJvL4jtGpSRRYoYdkFLWh5iB4Y3b1Z1kLgs9xRX7\nTFEHRm0gDIWJ+z2NHqggohuyrAtNiqkXnu92zcjbNfjrT79psgINYf87Vu0l\n6chdWEsZlA+i3HqYUGH967pgTN2pHIhaoDA6K8i3wP1pGHEux3AjDdGOG/rO\nRPGVM/TCqKoV2fcgWvDjRKYw6SnI/gIb6s2J+JuzokF0VSOsmSwhEUxyQhHe\nkjKudD9j/69r7uu9iot0puBU5H4RSfvLAzVIuJH51QstHRfASL5z6HZapgxe\nDT2dYN8FdIlh2JPq6I/1RknnN2ASwyPVR+VnOPast/8ZBhKwPaQPSWYKq0bR\n11fCWJDKlQangtZs8sis6gY09L2GFmWLTwWMpyPZGB0zlJUNnjjnUqWonxEu\nlMBtDr80XFqxUfB63RuIeYS3Ocdrq+vFF6kH4P2VL8cDukWqPnOZjMGj3bEA\n28ENIiMqUNQAomx3XhGSxdGm7vG3qBpTNj363XTkf0ZcUmyRYGUXq7sfvjcl\ngI0yzVtQyvQdVH6n4jEnK+hTuKI5/eiky6BFUG3SiITZx2wsmZFDFK5ZArIN\nEcNNbYXWCpF6zgiO2juqOFCpuCCQXCWIz4jkProA3JNWo1DvJv/0L2sxiySy\n1VEI\r\n=6JLA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"53349b117857540a02bf46b811d40fbcda682f9e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-ef3ebd9-1594967039662_1594967100818_0.9476263865952275","host":"s3://npm-registry-packages"}},"1.1.1-canary-df4352d-1595047577310":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-df4352d-1595047577310","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-df4352d-1595047577310","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5008c3242503631e3a6797435731311c4cd81c40","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-df4352d-1595047577310.tgz","fileCount":8,"integrity":"sha512-nuD2fAymsGFeFHGGkm7iHJGyogJ53WBi5yYuTKsDTtU3TYFt/Tr8cWOjIha/A1BIEOHwLOCVROpZvXzrTUiRmw==","signatures":[{"sig":"MEQCIGymFw2YxHqbw4HFCHQ7QbvDILd2K1jlkoRljL5oQAmfAiBlJ9VzhVf+5P3bywbbBx1eeSF0o5VuzWOexeFyPOHX5Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEn7HCRA9TVsSAnZWagAA/GQQAJFS+wN/GGQ20UZwsowS\nM1PJfATX9up6vVm5EZTSEaB3NgWpkG/8XRjcxwx2j1TRVRd3arQXsFyzNlMW\n7YgtAJRx5inwzVBsXKRsin92JCIBlJ/HSm9Emi6Goaq23K3HboY2kDbLHXpd\nSOVD8gZ3bVGo6q2DbvqKyEEUJzccfSmgv9aOnK+QDmbtSzhLUuASA0MDPqFA\nuq9IBYTfU31K1+4zCfnBGJQSnMUCChNgrl19CJZtykOtnTU9+OQdLcPAvOZe\nBcPnGj7Jpxg4ZC+Gx1sJUYvdhmge15schV2TXfCfvsuvIg15Nnnuf/OyM1eF\njlHg6wSFzQLYyBtCSCVXT5xDMhrfoc/5RlfcW5BXgRN3F1ZL7xUGw1xvqUvl\nFz5md2hCYJz1alXcpxwwWqTEUO9XFJp3RJrEZpueK9aWK1y6GSYpXz1AGiBO\nT8fiWDctxs/dAXmFMOiNJrLESJCAV50SblQaRDAS1U0XiI4bQmYEbSJhD3g5\nUxI1wuwrr9FJqwW/Z2Sr6cvLEDl5l5fs5z4SZF+ucziE8YVBSb7zrQoNOXVT\n74/xQ4BHua0rYIjylymv6twElGo6MWgdZg/N2BtK6S0pPck3fIDCUZduJEyc\nuXTTVXXyuxdaWMs5WI815cIjACttgXCtmZMasXdJm+uh76vLd8VKNPDeLzcp\ng4YR\r\n=An2K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fde31ce9dccd9d03acde156ac1b53edd4be5e080","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-df4352d-1595047577310_1595047622965_0.4750556738771985","host":"s3://npm-registry-packages"}},"1.1.1-canary-95b8ff8-1595088595024":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-95b8ff8-1595088595024","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-95b8ff8-1595088595024","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5d4f476c7573b99e9d94e8838a37047650510f25","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-95b8ff8-1595088595024.tgz","fileCount":8,"integrity":"sha512-MCS7rONnYXe6Jj4/IyOJj1xBUzc3sPA1l2cghGkc1sBQlR/8ezfX9b9V+XRRlkVW2z+HLBEBMK4SJG1Gvx1Svw==","signatures":[{"sig":"MEQCICUh7lOn7ZYFQc5QEauEd+ilpd4pwYvEMJqvC+qk11xIAiAdfjf/OeNg9uojhJFwSOCZ0sE1bJna+WtuzhTEtDWbsQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEx8LCRA9TVsSAnZWagAApZYP/1IkZtDMEhd0T4MBUbFm\nKFxlhzXAb487BUzD9qytHz6LNCQR+Wv9+QusVWwYegF/ln95GYXXbPnISszK\nh5LUIKF7zMPg1XEM4yzwa/4K9DKuYGsJT/kEKqaZ6aKrVgsNBRmZCJ9+RMor\nv7Ty5gtvit3q0h9qOSUHJzPvmAfx55Y4Ci5BdIltv0GWvcn4tF0ikPtoozH9\nkqGtxfEqhYg5vEno6hMaDJ1OIHgmbG0ZtHxi1L5cu+b+3gCRLwhBnnsv0Lnq\n0Au4HU/K+SyIj547s/l7D+hsKdjWc1oF1eHPjX7UI9tILus9TJr71dqFx0dl\nYF1UUYyv0wqGv8OPYlyRglYxSFcThqNdIjlsKb/dFl1txb5JP7hFhhtjPqud\nB69XGWq75bx77QLcCjfK3XVZCJL78lZBPuW7r2tghqRrTRl9isBntGkc3OEX\nUlbm2wSSHbEbsAlvnvnXYre6x1ZizOx5RUAcxSNrw2m9JSjx4Lf8urqEwHNt\niKfCk8QYfB1paFZTU70H8WWScZ7ojFkwpfSN8IEXGbBWi8i2VKSMfYdAqR62\nHhrjdZXof6HbXRNdp6neUfM6QTyXy6PzWM87FtLe/p0DjaI1uQpN+AhqP8MW\n0bQWA5yx3VcW92NFlC5jQv4bug11APXuQDZfBKl7Wy+L69weF8ViGV6ijpdE\nRcKt\r\n=Jo+f\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"59645dfdbfc1894c42c43866f9d08ebdce60b79b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.13.1","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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-95b8ff8-1595088595024_1595088651236_0.6911437384831267","host":"s3://npm-registry-packages"}},"1.1.1-canary-1aff06a-1595101006498":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1aff06a-1595101006498","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1aff06a-1595101006498","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8356bf7d3a10d71594fed4993ed227fa3828b4c2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1aff06a-1595101006498.tgz","fileCount":8,"integrity":"sha512-DduAsxFsu51gRn5GuaLySVvMgKejYmAw32zAjV+XtZUlGLga+esPHf0Ek4JKBFt2obAH2g5zLAMr+o8enkUA1w==","signatures":[{"sig":"MEYCIQCUgI+hCX2YsUE5bEz0s6yt0qlb9HIANwdLUhVTm8GZkAIhAJixlbhUWaGqKwuC6hxpn04+nQSouMdL39Y3fWNy+ORr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE0+QCRA9TVsSAnZWagAAvMcP/2ImXzrc55bxW9i5doNE\n6xm3hbUWyMoihIBGyxOJ04VqqxljcPZklbtKk8jwrRxZ34nDaST8K1TQc9Zy\n05mpdH0Gc7qWQwWJ4uhz/+sVKVi52xag+n0fvT7mbebn7lJc22wrsp55pHvD\nBCiGuKTExEUyqMQcINrECuqkdTSffGYGas+jcmhSQ/nBWt8aIC07eyVb0oTl\ni3dP9rP8Ha68v/qkJHvv36Al8sAX8hD0BGxJ+kSiJPHkjjj4hWLHk8zo5kAt\nsGBDCoup0XN5XewZ/T82YJmTbotHMnHMhE4hhq7IaGTrrLfbq3koF5S4qCgl\n3hzdiYZ4iAirj4V79CCpcpGKtrcm+8FfOVoUh/AmUWeDhHzpfjfVhyT/D81g\njysm+3hCYkzRbfBrFI0I8pdeAlm37IiuBukTOgzEC+i5bZrNjy8jjUUBs1zk\nADjTKTC92ce+VRmnE+4w4Q7lcB0a51JLLnuwiYKzuePaWRdnC74YsoOBbMNS\ntCOEgbB5rIhZZ/S86yWPlsnFZPz9O0evU39SrHbuW1Xe5aGEUGqQYpO3elHM\nS5WLJYR9dObq1inPb/zzzIhEcw7vnuGBBptNpf8veCrTpbxljStZ97EMWLV7\nfAnPER+MAQlQjvL95dACf6mhj+dB9R1Xo1to4y5aNKn4pvITbJP73J4t0jqN\nVG5Z\r\n=M8u/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d80436594e70063b1c9c1bca19cf05edf255ca14","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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.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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1aff06a-1595101006498_1595101071803_0.6199602180268018","host":"s3://npm-registry-packages"}},"1.1.1-canary-13a1f8b-1595101739339":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-13a1f8b-1595101739339","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-13a1f8b-1595101739339","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e81095062895973f798158c54d622fa3393aae4f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-13a1f8b-1595101739339.tgz","fileCount":8,"integrity":"sha512-YDJDsXZCmpU6M+vJwELzEjxNhQBqOfDugCoE+PavTWi54jgCuvTk8od5w/JvRYIqCLmhE5nazTrKBmTirhMdug==","signatures":[{"sig":"MEQCIDqY+BJ0+a/anuWWG7Dr7e5iu9r06hbFdicEBX9pSIDiAiBCTn/jR4gw/gmbNNjhN4lBFxOvS7wUE+J1fcy0Sc3W1w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfE1JZCRA9TVsSAnZWagAAMOsQAIObWiREgn5a5QHGHP+a\nWT/tMHf8pidWDL2Ul4YGYZncEdDy9C1mGBwI7uM36bdtYbnAz72kWsxu4N5S\nCuLKzVyVSIeIDQZO3AXK3MUabZyep9Knvg28SUQbefjvh5YwOpB2A/rmJJMc\ni9JYgEKKtOlRiELvaTdJQ2XuLy7Y5Q0kEpFDAMCaisDElkiT4agqK/avKkwM\nrTjee098iB4cPM0GycH2JwZUif643E33E+Dftiy0WChchb39rIa3QLJJ6uU9\n8OJcpuGE0HQeqs3I3QblE1Hr7cf02kfG7qaMBP7tJu45TcdzygOv/aRa19Z3\n28mYSDLsfqWvfteKgHzgPUXwIReia14bOYwufUYA7L003EYRItt0ZjyEBykA\nOcLcsGGFNgpxi+tcWiCC7laGZGzGDeZk1kvOlczAmRiY0BqKGP9oyeFrnyqa\nGnpdMQ+cSdiiU2oZYXBQBpnc9HPhm37eJuoAhTIX2hwCDNjfq2XsEwr/KBK0\nomAqxDLepK/SlpBKbv59hZzAdUhYifi5/VMlq+INFY1Y4dakiHNpr7lUZmFG\nBmlfkEduoa472dujVQiqewa+7OeeNmwOvQYHEbkdgLTpzi1qAzDq68svZShj\n/jh/azdehBoaeP7p+unvQe2YXTiTlcCegqjYcqWMhzLf6YSeIyuj8jSeWdpw\n71ln\r\n=r7+g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"63300f6aaa9c2c9cb43fae67bfed655da5ba10dc","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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.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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-13a1f8b-1595101739339_1595101785431_0.7269292866894022","host":"s3://npm-registry-packages"}},"1.1.1-canary-f22df89-1595398538126":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f22df89-1595398538126","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f22df89-1595398538126","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b88a02a24ad5023777e467104d1ff7b51567d5b1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f22df89-1595398538126.tgz","fileCount":8,"integrity":"sha512-lYk38pc6vxDR63CSztobAisinfqDff14sh6f4iMMBwt37FbQLNt2d37yJvoNHAh1BrRGN0A3SkggOfNkV8r9yA==","signatures":[{"sig":"MEYCIQCoejHnrC9HA2tVlp/Uip6qu1dY4rOs8QVMwE0FiU6VSgIhAJYkv8Wk3Ei8+4LsWj+pglW4YeujtuCzINaXKistB6WP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfF9m9CRA9TVsSAnZWagAAQ1kP/io8b+Xbcph9QBYEU05M\nce7CiXwI1yf0Amf7bpqNqSlbnBUC7mX5hLKV8nPEamQMquq8OejmQkYut9ko\nVNOSafx+27sxNHr32ZeNIF0taovruws1zsDPkTiaclAstZuKMrU3a7XljpxT\nDCzZVITQ+7//1ffFX91Zg7gSavhRWIEHoiErXFiZm4pmKziNhfhx1laPxwnA\nQu33BEblwlUhk6dwU1H4We023PX9Qd+omw98F5vCPgWuzzxOkegmllwFp8aG\nj7HwyxKsXhzKzC/c0JQ1GZ6vzIaES3UmUslzqSeTAkfJK1Wzq+Eo803uSvN2\n0hG+7htZ0Rub+JHqB5E3SNEVKAPsmAEps9F1gAQNKRLWhfQ+Ptfd5Fzb4h1I\nzqpWLfqsMU7XryZrKsc/opVetzqgiQ0scrwnhEAQ4TycdfH/6/Wo/zaYOzM6\nPe+GclW8bQ+lPY6scCBHJfFdyW2EH5tFyURT4Eu3Hl62bloD0rswu77Dc537\nk0Br8bx+cRGTIjISrwWz/hJhLNNtoyuwHdGgSiY55wHZdNWu5QaJWcK2Tbrb\nWIlNrNAazf9CGUIdOM2F+yDWx1Wz4UaFL6cgjfhEItu8F21+sy1ASIZEajPe\nmfTAzItavJXZ5NZY7+et5sKWgkMFPUXg+R3D/LMDZ/Mj0az1ZA+XgucxwNQx\nWICP\r\n=/Fb9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4ffbbc33f45ed2d997efd5f78d9218201de9305d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f22df89-1595398538126_1595398589057_0.7165830873867653","host":"s3://npm-registry-packages"}},"1.1.1-canary-9b5608a-1595527860204":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9b5608a-1595527860204","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9b5608a-1595527860204","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0c00a459be864d00a7625a510fcdb0775b128f68","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9b5608a-1595527860204.tgz","fileCount":8,"integrity":"sha512-bgvukVlcv7sOCQeC/Ri3qMJdT+MFnUAVkApapsA7uQpkmZo1+TBe0245rodusxZLcrk5QJ7qPSg07r+DFgHvaQ==","signatures":[{"sig":"MEYCIQC1DuiEbK+B5/QBKjH1X7h25LIfRj3usydx/J5t+V4HEAIhAIAKlNAxJI53WB9bdwwZHde558skWY4cSo6yLxskvHPu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGdLoCRA9TVsSAnZWagAAr4MP/RFccthn0Agm520I+/ST\n+RRPO/2a7oW3yg7yqlQ7SQl5w2JqIlVxVeDIfqYTlfCI5Op9bjy/wDH/7WIg\nAmXLkY8EiL3lBvdHoMSdvX6gtHO/yPVx9IJHE7KOTDSQNldxD5BXwWJ+nzv1\nWFeLnOaZawxFPtVDw5cGokOuCsDNEB6EGgtysuBAzR4ef3a6R8BXu5vc6BmP\nxy0v4V0uf6qkhAMSgCg9KcPOIBQB+DXZGlScb8x8V9mA0E05I9vfbthNSqML\nQuLjT876wiJ21FoGWAK4Gr4FgG/bs5cN94dS3Sz2H3mFZLgTT6o7zOKju95T\nWaR9FMFr1cP7wLpXIhZSV8hp9JPhB/5Kg0jJxrTIHnhKWWhY+LGMP15/9Ntw\n6Bgx6vDaY7RNX/nBwckVEet/fnUZzSfz4bxMbNRUQlssj9l0HVkDPb9ztai5\nUmF2qoWnj6y1J+nRB9qqLihWTdzz9m10U5Lrohrq2/t2HUg2MS+B22cbzua/\niJyrGDufhI5FcdoVFOVjpZfsvgmemQXUo0+vxfM67aOcyKaFSUQ0EitV9e9V\nCK/IjSgNNXQBqrDILAgRrpSEW9rJQNy/CQnWS/3rK0Ez8Fna2XsoxItsmQGa\nVFiaAsAUdW6C5vC6NLx57VHmX11cRy5Pjys6I9diBbdGiMIiZyQuy/i7AiN8\nk3rE\r\n=7DVH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c687f6564870b1a335c78e0b26574095e2a2d332","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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.6","rollup-plugin-terser":"^6.1.0","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9b5608a-1595527860204_1595527912067_0.9330551035198755","host":"s3://npm-registry-packages"}},"1.1.1-canary-29ba22a-1595536520777":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-29ba22a-1595536520777","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-29ba22a-1595536520777","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9f702749ec62fb53bb0b607a520c7e984502a9de","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-29ba22a-1595536520777.tgz","fileCount":8,"integrity":"sha512-CACafalEsHy88Du5TVwo6D3uFYzU0jOEn+gx+nNGPGOCdCzzbS9WhLQLB9/633nrHqoS83ufpwuo5tiqKR6P7Q==","signatures":[{"sig":"MEUCIQC/2VblVtB1ZvXXbGNcjUxWWXB1JYgviTONLd7LETBpAgIgdr8E92yMSlVN4N9sy/Q0N0SzeDdpi5DD7ntYGnbfmiw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGfS6CRA9TVsSAnZWagAAniYQAJnT9IR+GPiZ9B72P6af\n5L5VxkVfua5NUzZzWcH1PgR4wADgYwTt+xTog5og+WK5Rt34DkMgKCyROZqn\nJX62DrHOJ+q9CLMK/EsYRfYWSK5kDk0L6eCm8ce2gkSMQf7XeFB5y/pTVNGX\n83UXAW7zZmpOd9Oink27mq/novtkO3i3s1FWYXhl8Or7Tfz84jrCX6QErOlj\n9soeo4DQLofjLfesulLSSQGbyNBkKvS+6HN3XuuYnbVrJK1mdY81ltbScmnj\nxmcb1U5ubs2Bui55tknfkl0DtvtVBOseie/T7xzafL9vlzi9gAvjbPSsSkEX\nxdgbGJ6uJNQfLN8KxWriVOz8SeMPhpSqYmgBICp6XiQQ7AfwA4FrNyg2xz6g\nfWo7L5cFEX6xrZsel5OUGcXG/SNUDiVTqOSh2TUgo0u8ligagKDRje1He7F7\ngWJfTGQ5PSJ/c+48DWyA4xHBT0GZUD9SZjXGl6diMLDxHdgfJN5gqw0sC5t/\nVZ3o2BCz10AzNH2ZQoUB8sKkeO5iyYzAV98woUYPFiET+oZyecJLPx1BbGsc\nEeu/ifOrmYPLMG6SU5DJJFXCsfVwx5QbTGG+oj/eNC5btGeu3z3sNMOgotyt\nCjzCSXu9AAS4U3EvuCt7/l94gj4PoD1eBacCSf+ulqVuTA5nXsmQNFwNi12J\n6X4T\r\n=AgOW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3a2c9d9e75be2d82317932f1b3ae2e1e2bc36e65","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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.6","rollup-plugin-terser":"^6.1.0","rollup-plugin-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-29ba22a-1595536520777_1595536570193_0.8426278806717638","host":"s3://npm-registry-packages"}},"1.1.1-canary-6ab07e5-1595550278146":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6ab07e5-1595550278146","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6ab07e5-1595550278146","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1f3c550def6bf68113c655a2a9cae475d4824700","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6ab07e5-1595550278146.tgz","fileCount":8,"integrity":"sha512-xB3gDH2iEpXSR8s42Ak1Dt0+P7GfmRZxHFYM+PzlQyO3U7xvKj2f9sTOgAPYzRLOMq43cQIPfoaHT/bEi49nbA==","signatures":[{"sig":"MEUCIQCC36HftDRYC8z3urBp7rCo0EAH3+mXQ3HZSkqS4ScoRgIgCxqVwpgLPoEnjdcC02RuvZcO8ebf1oc6/MaA6PMhVhI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGip1CRA9TVsSAnZWagAAQu8P/3QgkbLOYQQF/rnVKsVq\nFFbDkFfzhLW3d2SaF39hbICIy9O8VlgnN4LIDz1dhG0RJsM5ZJlNYSNQMIMt\n/FwIw+Mx46v9pIoPV1d9n9scYU3nR/lOGhbb54yNPplEcVWUKvH+Lu04FGJq\nQv76hwcNmMjLO8/gw5yxtJ0VKKgERiZltAzBwcKY6wfbaHcVXcPq19w1zyMN\nGfZdYMoZnToU7s8yvJxhWGrEnpPO1Zs7riU4fhOkeb0pmFZgpNuXU5WcIduj\niRTX8X0zS+uUoBFK0T4V7F7R+UEoplHSGXwn8eBQ4OFyB/azacuNV9aEk1wj\nMzHqkbOeDkjU1+jOe2Pzij2ZiBdyhidlEpNjCLATCTEyHtA1k8Ehtzp+oLlP\nIGfsMDIc03vBN/66NfU65Jib/k4VsCb4hgR62O5BLMoaRPe4x4Jahg4jECYB\nZoPXCTMvb+p6nYEdMO7UvYS56dvnPqs9Kpf390+J+n7EfDfyQHNcslK4andj\nQ0ExAgeCzC59og4K4wY1Csb4+VfHxAu9qVh1Q34NHAgGVnCCk/kDviUBuA7E\nGWJ7A/A+2AO1zqxGuxOdLERGYpr1LvtPOjOcN7aL3PUXJm7w45VbmoNnbEQT\n1Sh9gs1VJ9sM74X2SE1GyWNbKcwjofHWIW4ub5/JIFgowsbld2wcKszF4JLH\np0Lg\r\n=VbFe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ab235cea9c341f163b65ded64a4fe75b3bb8a8b2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6ab07e5-1595550278146_1595550324573_0.645919115724048","host":"s3://npm-registry-packages"}},"1.1.1-canary-4b015aa-1595947718763":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4b015aa-1595947718763","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4b015aa-1595947718763","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"451c3951c2a90dd894511c8a145ad8e286312056","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4b015aa-1595947718763.tgz","fileCount":8,"integrity":"sha512-1P7a15MgMqB45aORiqk1MYWsBpMd/Q1Mc4hMGV//k1T0aHbCoj8YHL4kz2P5r+2Th/Toc06A6gZOPYPAPXNI/A==","signatures":[{"sig":"MEYCIQDho/6RCzPf22kbOTMpB8QzWUB+t3VWT7nAwjupdRuleQIhALiXaqJ4QjHKZdlEQjyPk4Pf7yfNS64Kn9mdfjDKhzdf","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIDsLCRA9TVsSAnZWagAA/Q0P/Rw57PVC1ec20jfmxiaA\nohvk5zQlgv6yLxYqApyLaQJUzZLf0G3+ICf6ozMZsUQqzLuBtmVXDKkO/qIP\naF1iKq+y/sTxTqvCpnP7yGo2lFWP5D7z2WOeyCdN0mEPz8Gh8LqH8ya1ztZD\n0kY5n7VtGn+izPzLZOdqUM6Lc3qkURNT1bSrQs8r4MvmNJyLKautmhdiYBKG\nofowJByTpWYsNZXKFy96SrhxxdS//cmo8PaxZ7KKZxH/a4IsitqjV6FxtlIH\n6BaOOu1foVmWqYSQDWlEM4Pw4cYbeyjdBiZnu0GyjBnduIVZGAfzuh2+4fN6\noaT9UzxUhGdkHZFyuGVhDVrq5hzborp+QyrPRkN0ErbbxwwDxhdOhtzm8PJ1\nhF3PcqHA3CHPJ39zD24XsTjHmJtoFwqsbh4VQPf9VgDzH003UReRPzLTKl9L\nkZAzLfBzs2D1yF89XtRHjxk8pEMV53AZwhBw8kOQj+9eCBuGG1wfigGtB7Tw\nM0zTyTfedhySCXcueUNAQ3kJkch/R+T+SKq5+O8yxLn6Guw38dJt37qj/7md\nekE3K+YrUgE2XJirrINA7+S5DbVmjmVgwJaGEyXlg69z7PFHxJ+ktKeR/dq8\nhi7d1CCTUxaVMjRxei5C2+J9KsBJqmtgTX1Ov8neJeL8BbV+pXQLeadoDBOh\n08sy\r\n=aFHR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0f2575a07703e90e3bb23c433f8cc21e67f3ada1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.4","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.21.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4b015aa-1595947718763_1595947786986_0.7986522664962241","host":"s3://npm-registry-packages"}},"1.1.1-canary-8f9789f-1596139189833":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8f9789f-1596139189833","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8f9789f-1596139189833","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"25cc7e51635a0fa438e26e09a2346529c909e2e1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8f9789f-1596139189833.tgz","fileCount":8,"integrity":"sha512-kz5abSIxk6dJYDORSmf0gOlGWA0Q8fjHw1Gg/o0lBTHg3z30RZwgHtJZKTb6DGr1ltF0Md9ZcuvSrwojWWvfgA==","signatures":[{"sig":"MEUCIQDKH2XC6TwPkvvdAXnADuQMQ1IGQSw6oSfIYp73oKlHvgIgRdJbSXdy3dA5HRIOA7gYJj5nwnSSE7mHqIOs1cFSMtM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfIycMCRA9TVsSAnZWagAAFDgQAIOY4HnPQVPRFBl/d/m2\neLk9Ay0Aqluv4O/exw08FobQx9kf1H3RF1gQYx212Y5QMhO9jTo/tHR20XX0\nKG6CJsTCdjkYAQ0kXujuKlDPtc6cjdT5YQ9ga2YHDqMzkTI05PdayIsmdH3w\nMaDymrybQ+HN+iD3/w/L73DKL8HG7SC3PPE0ayamZFAOIfF9W34Yk+Zkkvw7\n984/25Sfyg+0s+nX2HAtQ3mMHQKkZXBbnbBJILoclPglnn7SBycCrsoTfl4s\nfLFCpqgKrAnyRg3vrJmarK7uPlvLFdIiKBvXXyV2C7LLpUKEtaXjs9q7ptr1\nNlisRgiyjbdcFXqJFNwJu4ZJ24oLwGPQk45SUqJQC84XriApgVIr35pG4oja\nkbsRdUCgl7+nDObYiyiIw0ElILpT/lMLIMQjHG+XFkOrujx7QyEPhOALm/5g\nV4/ePEX2/rHSuYokZ88OzLNBn7RwRM6JypuKJXl5OG7FRZP8ZnMGVdcDEL9C\nf4xeWarjOWMmj5+rRMl4NJl08wp843W/AumBrOFcd1t+OiKS8rI8eGtAl5Lz\nMClT3UP4rj/qTGEyUHhED0iY5zQUXSL48SFZcbyd1VrXFymYU0CJd2DvCeCo\ncRYqlkP8X2zQuOMouFi5XVmjaN5CA/arVUD7xS7wwGkRMcdl33VdkxLbBkTP\n027V\r\n=WF4/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fea346fccf63978b081c297b01bb6cb5c39d69fd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8f9789f-1596139189833_1596139276278_0.6664180579275814","host":"s3://npm-registry-packages"}},"1.1.1-canary-8a52c06-1596178764805":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8a52c06-1596178764805","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8a52c06-1596178764805","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8736f3b2631b60574c8e768bf5017bf5e7d526e1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8a52c06-1596178764805.tgz","fileCount":8,"integrity":"sha512-ynSFD5hrnl+CRkRm/1ZIBwAeA0pVUepT1tDGCfTtVRfesmXiwgVpBv9YafJl1X33WAmTDgzXorJLmj+612so0g==","signatures":[{"sig":"MEYCIQD07H4NJSd5E8fJIXnflG6SBxXu4CmwxmaMops05CIJUQIhAO7IUgwaGIAuuOxNFIa8xhjXb8VF9VWT30F+gBuOJwGl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfI8GCCRA9TVsSAnZWagAA+foP/2glHC7pSYhkRvfuLwNG\nwLI0QlETU++v6Yw8LSc+BreBzJin/baBijvjA2xEbPiZx/S1NLP4DJxlx2zc\n13VOdUbZ111PejBCSq3sVHj9p3DIiUgx6NQIJzxbTI8KtrDtZoDkeJEc7xce\n0lf+KecvsHdEuvT2q0vfpH4OhNd4Z/r+vnYfiYJTGxraiuCeX6pSHYX0gEoq\na2SsBmSuwmeRShVvJzI9isiTfC2HdHjwWInp3h/OBnKE45Z/sQRi0RfoKvLJ\niUxA0Zw+5vfmPTSlN2Xurj+rG/L+O7oVhiXBU1vspJW6EY++uJn88gzbGTZE\n88Dmr8B/KFbvdmqL0aitTijHpTp+eGtzas/mQs5II4k19RviUu5yQSwvqd14\n6cKXno5Yn+Ip5FZmjDUEILXGMS/OUuvz9sdlQO1eJA0XeB5HrBlqmBwbtEHn\n6ryKwXL4livILxCL/EtG8PpUCyJrGlZtCldpqh1TYuapGVPIkgStb8w/TDvf\nB7eQMKz+q1iUgF3yD633bx5qWyz/2PlvcZG6ykNPW2AnUvVVjE4GsK6MQmwd\nY+VUiwbCzeZIytiALmF4nEMQDS2S0h+DhaaQ+vHGyKZYDOo+cu3R2RdmRYSc\n/E5KYkpci+FzuW9Ae+LYNNpnaCnXK4UYNm1K88USQ6wefHf0DIF0YXdS0m6i\nuVHQ\r\n=u8/B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2daae7e1dd528a3d2fcff626911a8789f44c5b05","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8a52c06-1596178764805_1596178818339_0.041249258852877","host":"s3://npm-registry-packages"}},"1.1.1-canary-a09240b-1596249252055":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a09240b-1596249252055","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a09240b-1596249252055","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a88a091bfa76003243f2edb333c1506ee316984c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a09240b-1596249252055.tgz","fileCount":8,"integrity":"sha512-IuHvoRgMvDNy872EzlEBN9Zf3/OQC5zQUHhh7dQVpgSPeXnQGAeBOYhF1P5j3MIb0yssi78ArQ+jiFH7TriKMg==","signatures":[{"sig":"MEUCIQCBSqil44bxGOHSeEQxTYiWWLieHoKsK5wFL7/k8bEJbwIgNo/qy/EzDOlT5J2LZgm9C09a+gmXoqIebRRw1VQdTU8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJNTjCRA9TVsSAnZWagAACMsP/1u/XpLRtmdy2s0ztZKP\nH9z8mUWNzdkc5mcDJQ9/x8hXlEyXVuRWOBqIqWC2CRcPM/ZGE8Q/6J18O6BI\nPn2NAkp4hD5SrPEKW4BuM9sj9fec0YYAVH5jnphMbhfw/jIoh3xUciMICXfs\n6Sic6YJxUibR0Yyi00+qEt+PZyQPrn6z69KTwgeJSLPd0PqKBtCV/pPeWm5N\nLVT4pfz+0FZEKYEXtnEDpHfN5kwrufhq/HFek9At1BVKvW8et7NtQmXvugVA\nkWJRhas4zG3aOdYygta0fvr2kchNKoTnmlVtrjbQAw5CrVxys9G4mdTajD9p\nY+98J6jzSsicg7vaCl4E99q0iYtLDoXGPngNQes7OkXL6XUKJW5UjqdrUqH3\nYcOq1YSCcFHpg4OEvC8hT9qPKG7fiQSgFeL+hBm19XRDOGLlWv1L/+FC7bJh\nX2/O9e+8GTvn5qIBzxLG7G1jdhbYgfwFVpyXEcYuzJPTd4Gs5FZYQ7B+ySTz\n2V4FHn4NFgHnlGGlxaYvT8SRE4BYk8U+eGW8A2pHocVC2b5AgXlQ2+2995Fl\nssyccYGPpy8UGgB3OAhwXq6YAZyOq3AC/ADA1TVvLltXDHCaVtnpTAT9c8/O\nSPp478M4wu1pfqTURfbcTiw3uxwilJso97aopdGgrkMfsRjhbRtcHvexhJc+\nb/GJ\r\n=aPJY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e763d4fda8d9a23fe742c17417d7e1f53e541c6d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a09240b-1596249252055_1596249315003_0.6694995310983556","host":"s3://npm-registry-packages"}},"1.1.1-canary-11cb359-1596279455934":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-11cb359-1596279455934","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-11cb359-1596279455934","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"56ff941c085d382631870beee9f6482defbf5899","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-11cb359-1596279455934.tgz","fileCount":8,"integrity":"sha512-OV1X5XKuVIac9FBolgb6mjByh+4LMybRL0Ba/gFkGL/BYK0cyc6J+S7Dt4duHjKYDjNddGmVv8eH2JXns2QX8Q==","signatures":[{"sig":"MEUCIQDbGvqXbDP/K4B6IkuIQAmOxqqdHwoNy0ZS7h2nyHqVxAIgMjJQB0kUIeKSPe+TxMVSBnwKL1NezgqwEfrkyMaX6HM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfJUrTCRA9TVsSAnZWagAArDQP/jjyAgxogeuK4ubWBjdw\nFwRZQtAoQ/y1LKWfg9mIxUvmTqPkuwy4fzIpJ/fFYL7FDz1rH+Q0UD7JCd4x\nl34EO73oR+zfmcK4+ZhDv08PqHi6nC0ueBWpV3jbArg4S8IurDgVaivUc7oI\nyrC2Irvz/Bm66URKOotMmBOow8riSfO1pL7wmWhW/3lawvJMR19syQPvZncy\nuXiCbVBtMNA0rlAjTZq4jkBraV6SZf+NqlerTuGNeA6xnNzSZ9xM98DqfCY2\nDjMhkMBSYrcRylM0dEoKE+lTQZtlJagPB0VQLnVqRu8Wmr/3rmmjf8xutI46\nNKqZaiPc9rXut3Tq0tar3Hs7ZCo9oADVu2R/CmIFZpjul8tR5V5pLhUI8nTE\nfxnPZeXflYjCx6Qv0MXmafSlmxzbED1pFUya8MyFQsmT7Gn6g9N0RH4TrX2J\nmmo+IiTBWexyKpUw4KF+FuAyPIyys8vQOw068UKNY86s9k0SGpBRRzH53o7y\nQdPX0KUPmqZIaaRL86GiuVY0z6aYQAlleY/fNWgfrokiNPeOIrMu0DsjVJtG\nI1udDaoOKao+oyNYR8Z+j+kpJJElakoA1PILKWeS8Fn4Em3dy9yRG7/BXe6T\naRGs+DmTrimMSZqATvFkWLE3Uccv0p62l/LCmNj03qZi8tdERePvAJyvGo89\nNj5F\r\n=OxZW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"564ffcdc19b1fcd785130c86b490afbef179999e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-11cb359-1596279455934_1596279506757_0.1794290055556247","host":"s3://npm-registry-packages"}},"1.1.1-canary-bdf5814-1596677952836":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-bdf5814-1596677952836","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-bdf5814-1596677952836","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"36b808641c2005ce55294474ec128397b83e521a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-bdf5814-1596677952836.tgz","fileCount":8,"integrity":"sha512-Urz6Tk568f11a+ZwBvaP1G9OSU1zljLVmKY4SorFiQv3h7IyJtFJ86kKIMzNlaWubMJnHb4a8p61QtToI1AvHw==","signatures":[{"sig":"MEQCIEnASFPZtuT1/TD+VNqlmldNX8x7JYDHAL1zlJU4sjOtAiB4y74konXl/x4fW8yE0BViaNG01AuNreekdeSjAasCdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfK19xCRA9TVsSAnZWagAA0tgP/jutlVgYP0gEA9skmZNR\njhM6mwdowBPJsFaJUmVQtObmzP2ZqPHBrWi7wZYWkrk9VP8I3XqpcnhqsNZY\ngV0DGcE906KM4e9hJ/64te5uuSKiGNJoP4Ys5gnnj/bgA6dxPzXVg9L9qDx3\nn9YvXNQwe1NhRfOMzpTV/cxvwLYh0ZkQ05pjqP2US6JkR7moN72/7EMj6rMJ\nKDRoGRTq0DfAkcW1qTN8x9RfB7oJ6cEWw3dzwHGfRZkMtVfJPjHYNYgQe0ZI\nRYkKWmgSBozpjmjh9RB2bGIJYAe4ReR+3we4MdUl9duYzc8Vx49jpgzhkEQg\nhw4NBcgOHwVawXtesnJimVOaTtp+7WibbcLoD2LjscfwR5wvJrOLcLJaPZoH\ns3QKuYi6mwB2FbkyihaD8/SFKybgTwG1DP+fNARrBcxR3eTY6cRu1obSok0g\nZSztmRo6luZvLnaMzGOS8bRysRY44AhCBG6q9WIeVwerkGSKAyHgx/7J2EkU\nua5PbXnBCsk4BQBbiONjon9dBq5lq3F5GO7teSKyEoezkr+iv5zx/TSpfoaF\nfvFDxLX9xpnrKKEyHMT0A4rSDWhMkZA+RQjhNYXlm5l5Z0I93hV24d68PqWp\nxH6LMif6c9/VJ6qUO6NzHkG/4UTsaEcY0tAbzJWlFcfSvRh+gqU+FIoEDyhA\n0bLo\r\n=TKaS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4adadce768e6f58cfa1e88004474c80a79a50c13","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-bdf5814-1596677952836_1596678001192_0.8917500373560578","host":"s3://npm-registry-packages"}},"1.1.1-canary-0de0a23-1596756645961":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0de0a23-1596756645961","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0de0a23-1596756645961","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"94c1735930ea2bb1d7c49720024b8b3271f0517a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0de0a23-1596756645961.tgz","fileCount":8,"integrity":"sha512-i6TgsgfyrvRFH1m1DIeI/OC3hi5gr3aLgwxdw0uai7q1EGNobx8s9rW3fNSMMS9LDs/MCXy9+R4Ln2/DN5gsXg==","signatures":[{"sig":"MEUCIQDTeyo6+Z4BhjD/rZK7P8fhfnaCX9l/BeShdOi1arqEeQIgEfHPD3PIj21xgSWXui4kK/YWrwKI9IhtA6RX916wpzA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLJLiCRA9TVsSAnZWagAAmqAQAJrTLtcm4d4WzTx5Ps3W\nEdWlsBw3fG1T0fIIJI4DBQM3tmbm4eZZ+NtODXpcADmCOgFGpNuFasylaa20\nQngxTc1gbLio46LEKMY+qUk6MQ/gpTD/meVkLT7FU27bPud4pIO28Ws7eHak\n7Io+SMqHON2cAkZWqMpKmvpa1wou76F00MD4Lbp+BcYtyg3ES+Szv8dc2v6N\nX3NZJSSZVTDhMGbtimljBrgEdDcDPFEfvez5U8bGVFXToccFskZySZcCjalE\nRpOXuJwtDtcxzyyv3c1e5V8KQbyPLH/oIOn/vpN3SA9NzBeJcNh0P1iCPPZP\nh6xvRFuNZqagy5L2bb2Q4Z24Eu6f5rzoIGTZJIwuHPzaibHU21PXeNFMnSPO\njdLAl1Dys7HbPO3zhZf2FkY5ENX9VlDPPDRS2jxKcCSKV4R23GzzPW2e54aB\nFpci6YG4aQm9DSGW5/tBFibqL0zs6Mews2nzfxjLtKMwsc+UQiNNNoQPI9UB\nLT2vfSKBGxu8lUW5vHfIpWBRbBD5oLARWLZU1ROhTTHLEsGEzZEwnhXz8WWv\nU8lZMUSiscyM1D5swquPEs9mwQGcvN0+qkDjbYBhEz9KfND02XoxXO0UUVtW\nBzLdQH5ZGFXZZt6KrGNNQbkb7lotecuoTyCnWySUOFXCPe5QfuPoeVOxJ7zr\ny6a7\r\n=roUH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8429eedb4f6376eb504e6d12b514012eb9c2589f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.1","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0de0a23-1596756645961_1596756706150_0.5215510425727612","host":"s3://npm-registry-packages"}},"1.1.1-canary-59df1ec-1596828276128":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-59df1ec-1596828276128","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-59df1ec-1596828276128","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"82edc4a4c2ae95b29021e6497886466946b5c065","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-59df1ec-1596828276128.tgz","fileCount":8,"integrity":"sha512-vQY9sEQBXZ9ZeWtwFsPfsvlX0FE5jevjqSwuUHUBqKoYH+/+eaU8vuPcdz/8+Y3Tl2c2/WwIdNOzl1z15XwNHw==","signatures":[{"sig":"MEQCIFPTwbE654Fxm7swPTYfV55qCUxG2X9gX/EN9fTx/x1EAiATE9VlwyWw1Vn5fMBPf5HtGJoS8m389mKdH0cX1jJEwg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLaqlCRA9TVsSAnZWagAAqRMP/3GyNdzzvGJUlvlD6dhI\n2vex0dFX1cjK6WjhU3QuIKxac/XDkld5+O+oLmFKOhr6nf3HqddCgG38ZLPe\ncI9BwhybeTpAhtT7G7DKz6WBdLBN3DVdC7Qpy56MwA+XcWoxW3IhuD600Ap3\nMfD2HJ4tS6yBu25S0qsN7jLH8XH9yeYbUoH7nPT+A76veR9GjV0wIvrEWZgC\n/Bv/SKJuxBeRkFwd2t5O2t9aXqF7kv4Of/CEBTiqLqLMShmCfn8NJzOIi2Y2\nzZW9KTvd+WVdcYHoOMmfSMVa9652F9XChT0YHsF4LQDYTCODXrTxzZn9k6Te\nCrhpPwb+VBk/1lln7+BvAHBwGi9uUVS3tF0E6oscQKJ1LWTY1oZnNwhQ/lU5\ncvP/wd2tKqbvS27BbTxTJLAjIX+T9G0oT2Yhx8BX5U7q+l/UxR+cRgWLXtW4\nTTKvMtZST6PKpk9TgR8+JxOi9O0vib3Aprd/LfEhDkjR7zaLiZcPFspVp3RR\nsQDdHK2vhyHwq+qGeGmw6w4jUGgF/XANoTEEDmzXhviPAyTiLu9AoMvZPyI1\n57s6Pbdq8ywt1f7ZU7KF36qbXdt0mwvAe5JgPug3bb3wMWt5NqKnDmAcgWmd\n5uwsYT3X5MUi1fA1KPxSWbq+PI3qr2+c8kHEMccGeT3ZIVhu+9/OSjetM7BJ\nyAqB\r\n=6plW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5658867f2165d889b0b3a17e544473a792eeee0b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-59df1ec-1596828276128_1596828325189_0.6253078125199261","host":"s3://npm-registry-packages"}},"1.1.1-canary-d94387b-1596832372333":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d94387b-1596832372333","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d94387b-1596832372333","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9b87c7a7e13a06f642e3590856b285d80c304009","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d94387b-1596832372333.tgz","fileCount":8,"integrity":"sha512-Qw+6+JFpecByFKzJ9KpgFHfdYB/J2O6bkTm7fZ/6DEpqSy3t7Ev9QZ7IqIxRZuIdhbRPTg7dGCgldCLaObEhMA==","signatures":[{"sig":"MEUCIAHHkfn59n9u1XXvkdXCXS1k7XmZT8jeVY3vg4U7es5FAiEAp4lqWlxB4p7u+HAK3M4DVLQdqzDhCS7JcvA/YxF9xm8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLbqnCRA9TVsSAnZWagAAVhEP/jvFdb90BMOhGrw4icCl\nO/9j5oAsorhIuOJaOaVJpc65OBaQpoxM5/yYGWAXU1us2FyrdlZ4T99WZPjC\nTpyP9GSYRwuoEs/lW8rHDnkPsFELvqn0fz3mtA0jE9A3FT7BMpbonDZc8pTb\ni6leOWdjJCua2Kw3PwHPnUIDSm9rCbp1ICveJSwwfNlR36y5fcCPbK8Evh4z\nvUZyI0Jzxfu3LbVN+8qY+PJcHFQM3pNgRqvYh7zAICbldGY7o8V0G2veeggv\nbpLTcXJsNhPebu2nFHrlavfGCKxOhl5R1rWKAlE6lYi9dcfHvmQ4QPHwkRR8\nd3pjHtNwMdntGNDestFvqPJb9025/FYc8Pvn51SkZuB2Gc+wG1giXmzkPYIU\nBWdSqJvFBJoMVzldmF0267ukxX7Dkd3rPO/RlsiABtYlWykCyWgOm9HEzOXw\nFXuDi2efPkWR06UdEyhdCo4lK1UwU+Zmod4F6fhP8fS0BgXrnybbY3UDf8+M\nlLq7lOdwwsVRGdFtt1Zdv9AzolpJPrJ1nprSzRHxXix5qI2qWl0m4ZCB6p/S\nCUuy3weVTNKgBLAIx9BBXaQwwoz3/yZ1Y3ha1ojZ8B5BVrhOkV/qMN27Q4jR\nOTE11wcYRqr+q/U6dRaiCpfuwZETIfiftJxrhXOaVyKqW74ZBfVbdcDelkhh\n1EvD\r\n=WLya\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"24087e9f32c58ee1bc5d076676b2f70df3f077f6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d94387b-1596832372333_1596832422638_0.01569671177735521","host":"s3://npm-registry-packages"}},"1.1.1-canary-d125172-1596934252991":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d125172-1596934252991","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d125172-1596934252991","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"712ba01a9bdacf557b4031c76f8c01f41c7f48cb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d125172-1596934252991.tgz","fileCount":8,"integrity":"sha512-YAm+qpfktRC1b7xKfNC7h06J6NDOCPzs/BGHJsWyz0wvbetxJE/7oq4k3Cg3+R75FizPq5J5YaeYhaxzuphyOA==","signatures":[{"sig":"MEQCIB9obCDnRFHiPjnMjdOrB2IheEtLvIUgk+zgHvOK7YQiAiA42VBTKCwYl95UF41gCFhpXQSlDHaxPMTMl4r4FUtL6g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL0ipCRA9TVsSAnZWagAA7X0P/2+Ke0nSMT3aJ0Uc6qMH\nPycH6U9A52XfRrly283LOeyY/ceIgasjYor3x7jT8lrgfTP63/4smUMbEiIq\nGOE8Wwq3iF9HJqNAGRS7nwkpcs/FRjN4Hr29qra716gY9ReI6+EW5ri93I3W\ngbSsFTcw6DtnyZmm4srTDs0eTYTJ+DxAhOpB0qapyLO4WF4rb0lXG/YNlIg9\nDtvuXsUZ9uuDh3uRuV5Ee9ODM1LupTVxoW3buLG6KOElDUjEJZeWaHQUZ1tY\nq6wAR4pWkPmYhMsu3QyoRoZE4ASe6SdTP3Qpi0WHA/fjA0V/ZwBnXB1yph6c\nDypM4C4o3wlj6gvMKq2s6unVjfeWm5Y8IjFnGGQAbhPCKv1dj3eTi5vOdmvH\nzF41/kT1mQ1hI9DroHlQC6+44PEPL2qHD1E/J54BvO4R5HU/vsJwsGbP+nfZ\nlvAcxBJLj2n6UC6LrAwJfNr9H6+9LPGmktPCRJf7UjJj0nHB8a9Cw7QJ+fJK\nUWiWICUsmhhLpfMAt7OkgLLYv90X5nffaI1webiLzBuE4BThpGJiYxRwcYvp\npifeP0+7dM75Wfn2i41CRhBQfqlypFjxzMHjWi+ijm/tSeFXlfRO+FRpE0ax\npsa9VjZmmDlHK7t7b4sUab2KyBt7+ZgK2WB3sIknE9d5AN6rwtHNzP6p65ZK\njd4J\r\n=jluS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b667f568802d3205a006418d60f6970433f8349e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d125172-1596934252991_1596934313464_0.08484289267886114","host":"s3://npm-registry-packages"}},"1.1.1-canary-fadce8c-1596978679443":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fadce8c-1596978679443","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fadce8c-1596978679443","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3ebadc92880ad335eba60b7b4f6c8ad2c7244fad","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fadce8c-1596978679443.tgz","fileCount":8,"integrity":"sha512-8XZC7jiOq/0a4XWmh2mvd3pK1V1PePNiRwQW990LJBenJ6LqHMw9q4r2flBJtJNq+SyWbkXptELTmWHD+01W4A==","signatures":[{"sig":"MEUCIEW9XXvGgi40p0cVyFmJUWE+qfy53mXOkKLpnitMgyLRAiEAyGclMHmlX2pewImbkhwMgAVZIkHhha8filVObhkXsfo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL/YtCRA9TVsSAnZWagAAqV8P/RrtIOsvV4oJnl1VVU9P\nSjkhlAWp/eeuT/SpxNaG68GNpEx56sBXEjYOMvuaskr4z0EB92kzRvU3UroH\nD8TYNzjgQBzWwXjtcUbI1cHh4AQ/KkSjt1fFYBewWTq1nz3Rz50D9EDg/RC3\n9yEGi+48WXFLgCW6dmWXfvkX/+rZSqwj/CURQrbLyUIQxDoaWWE0rjBnq5jO\nXZM4QzGKVJhtqeklcdMNQHpbSslSWhSe3WyDj4SE3n2c/1E9lPFCEdEhTA09\n3b3Y7sS+VF5uZHphEN791D7+hdBsCDYZkH0qeQoZs5ehScHloJGodUz89ga4\nFkslHhLxV35dEvgh+l7Lj5KlJ8lgUtaVbGEXWXBYwWyw7XRH4hxEPc88OuLo\nVSzOnThmf6KQvDRuJSTLbqTBJ7XSRRkxQgFHeLWzaUMUhwtIGPWJiAeFY53u\ngjJnIg3tegCZS5ZMXiVMg3ECzv8VsRQiDHfnTC299W/8GG3BzlEKCF41sAub\nLFp6Z705mqKAD/wZ748N80J7kUJlUlQqX+tpBEPlsDu+sSjnNcYzm2XnJr5n\nTQQv97VLVHGlni5txu6gFouHW2KJ2K7b7k1NrKNbMMNlHfnPla9CeMk7Q/dT\n/AHJQIC7nyrsagJstZGIxJCmfqDWQ7/iFPOEYkbdU/KIShb5ZWubHqyBxTYu\nxODw\r\n=P7Ky\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5601921dc57c8552dad9eb192b5a90adb6ffc4d9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fadce8c-1596978679443_1596978732980_0.6086206287877933","host":"s3://npm-registry-packages"}},"1.1.1-canary-6a1a741-1597096056568":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6a1a741-1597096056568","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6a1a741-1597096056568","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4a90c6f6d92f83938ed051596ed8583984c5a609","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6a1a741-1597096056568.tgz","fileCount":8,"integrity":"sha512-0Cv3FFTqmUFqqfzZA7ztY3okOYMKMjEKiM33U70fF8n2lRA1PfD2w5jGUKrnjMHNf37DlKUg/t6QV5V1Vay2uA==","signatures":[{"sig":"MEYCIQCp0kHyZzW7hcMEaimQYSRsMOH8JHl3bQRDKAfnE1d75wIhAKf69O0T7pNeEfkCOughcapKMHzOblyNlD/9w9pSBBbW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMcDMCRA9TVsSAnZWagAAkgUQAJhvj30cGVOPrKPr7H1t\nk7hRKXWG67S2tRa3l4Gp6j2Na2WbYG+0wx+K4WSpzf/K8yJuBurWS0ewyN/k\n+M1F/AcYQlxUoIjtTbjzNkBpBQyRZiR/nArv/vlImQqh6yrjS4FVxBiYttHJ\nk10dF4StIawX4AvHdufMx73fL90CyEEPDdhWAkhza5DghdLNsk2DgqRf9WA6\n5yEP3wlk+Y5lrW0Ax7vuelClnNsQUUI4b56ZZLbjt/hF8WbnTY5uJZy4rU80\n+iZjeVX6UuG6fK+GhujcSEuEXtVJNrpJZULariJxzefOaKLD4gQl19nsRNSr\nXGphkXL0kcyMP5gh5dM6UXkEPJiOZTMfohEhcam4qkAr7IU2mYDKzWuYZLTC\nKwaj9mfRerEoySQSYIsXfaE3vmIX65+aI9Ixz8eK4hcGuPT01ti4Y3HPE7ks\nqeT3G4Yb35USoC4V4kyDq6ybJqUwSYdikoQKBNNR59y5T4SjWeWvedMBgLKZ\nVXSxxqOBtI6+fkThxkL0rmU6hE7hj4nDE36zatxCzniJbQHxOnGPYzBasnvy\nrmlGPKZ22RJbXid3X7fyfw8dZxME1/6BK0YY/IzOGrIf5pfXebyF9KzT4uL8\nHyYyPakoFOPDZ/FIfRf22Vk2wY0oj4Mqsui/CciuDwOYLvYtqil6CEM8X2OI\nRngR\r\n=5IrZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a23ac69dc5f5f4abd62946c22394fa947ccb6a46","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6a1a741-1597096056568_1597096138889_0.4639985885459932","host":"s3://npm-registry-packages"}},"1.1.1-canary-9602310-1597180556145":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9602310-1597180556145","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9602310-1597180556145","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"49a91fcd50a038f6030dc303d2da84b928a667b8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9602310-1597180556145.tgz","fileCount":8,"integrity":"sha512-EPSfqsRBhtJmW0MSyjX9uewpxIY14mnqOdvMlClYVlA8rlnrX+47l+LXu+WWp/hLHyg+awE+jTkVFP3b0v6LQA==","signatures":[{"sig":"MEUCIQDbSV5OwDCOOYTo4VMc4cQHwPyfL1obWbpgw2S8oYcqLgIgUcFomAQ8diS2KePStwBjVWPhska7CjfTmY9jrohgK9Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMwq7CRA9TVsSAnZWagAAA2IP/0zgZwZNcV78iw0jTQxb\nSRzcbr4aSBreYceRowONOs/Rjf67Vjg51BA4YRICy9tjfC52X2eRWqyUswC3\nrLQWyAAuzOZhMXFdDbRWm/RfIyeOgb7hx12h8ZrWgC3wdKVN9oco+mu6CiJM\nEKlCS9mHTD7URLSux824PeZIfRM2UdPGenim0+APAkW2QV/uwlR10ncffo9j\nzgdBZy4J9iwP77npMveSjzHqHzaM/U/qIhEXa7ySAzWgk+ze0WdswLIEiecp\n/VVSR+/duX5IYctpsck5I3JzRnH/GT0Zlg3e3OleY0oX4dhDBrq1E1V0u1NV\nUvCnqnvkkIP+f8556y2VkK/VgCFi9FHMByLNBWK5RxNaBwqq6g0b//fDHtVs\nFH879BwdpZh3KWjW+nxr8tdXgO3FwrR1oUQzxmJb+d8qfkxVlI4wDIJsDC73\nDVYVUZmVINFiwbdStM97qR9A2O6pd7F2XF2Hu6r/x0r/U3yvgR+ZNw75BDW4\nY0VAtNFzVEn/aQ3dVYiywSBxKsMdFp4ha/bnt0UsGYzf6+sg2Gfn+5qcISi/\n5IewnoGh5/vF+XPnGyrxvbNsGOZ9AStwLh6RU2mcO+QxxOHyUK/J7OgIrF5J\nOh3i5UVErzfzlZPe0kDB9nFPBAoBT6ctUupcVq5Ky498pFSUOJXJuQiehAPP\niDxp\r\n=g1Ii\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"888e2e621a9ba07a58b05073e62358ca84163041","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9602310-1597180556145_1597180602710_0.4531973418423294","host":"s3://npm-registry-packages"}},"1.1.1-canary-84e1414-1597288691922":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-84e1414-1597288691922","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-84e1414-1597288691922","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a804c8628da0f602196638df2ea639af348863a8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-84e1414-1597288691922.tgz","fileCount":8,"integrity":"sha512-Q7tV/IeahCD0+v6ucXVUyiwobTNaxQr1MvX5pUvv7bDQG7Q//DqrSIfT4PWlrSulRt7qiiDENfm5HrUqWjRe0A==","signatures":[{"sig":"MEYCIQDFPNT5ZipuybAagCu904cX64RLYwBks3AQS1GyVL/D0QIhAN5fxUaIdlnjcM/BrbiGQklLH4ssVoMRpGBkE5ndQv4y","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNLEkCRA9TVsSAnZWagAAiKAP/3QT2x1U8FZS7MwoNIqp\nmdfxX8dTOUN/odWzqqUtIRqCJgIy2f3226YOB3KCQrC2EzzZR04VHB6/w3f1\nSGF8CS8gu+HVBi9O4bfFtDfhFkwTsQzYOvjoQ5JYGNvRUbxvlwvApsB3xkqC\nhIdSFl6q+6o8h0p+boBsUbNI3fsJe22z3Ldrk0QcbCyiWYJwxLgr5HKLdHlH\na0wzxUr0fdWOwLVUSmQkXVNcA+6st6G7k1JOCV382N2qkTrqO6FRIBnHiljO\neNHOCCHZIjcKvLIzIVmvFj9rC6RPgzkYgsdFhTUIdZqrpSeG9/eSEFJYFjx3\nZCWUcGcBHMxt7TPcN0W44MPqxaCW+rlqF+XHieVy0WJGMzThDw9BGj8cOXDs\n2uJ/PnkOdYvWQIjTq7J5G2gcrV2agOtYcsT+MdOKrEkQiYIwZ7SkPTiv5w0c\nuMktAm+WSjB+IonOUEghmcMFvimxhGAzNOYOyoQvksLHT6bGqP8YVL06M8Am\nHqTIHvZOFDVrxySm14CKVnhtRwFNLFilLzRUFM8NcgFMUWtQIDyqpvFWUh8C\nCUXSHQTlAzLjSMvLis9yshIUrIkZmS6B/mm30EC5w6atmX95IsSA8//7Pi2z\nEyXTtVb7eStB1SuCXYvUZPy6g8U99OmwZnpIoY4sHUn4PMpe0nerY3cui3Bm\nOxeL\r\n=w8q/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1801c09abe53dd30fa27f7af6e847097e9e8531b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-84e1414-1597288691922_1597288740074_0.6108687508920927","host":"s3://npm-registry-packages"}},"1.1.1-canary-a7ae075-1597369520429":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a7ae075-1597369520429","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a7ae075-1597369520429","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"44bef474c750f5b8ecccc72398c98840a7d0a472","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a7ae075-1597369520429.tgz","fileCount":8,"integrity":"sha512-O2/8+UCCLNy969AgahtdBj8ZBwoRNIKz5KREPRJJTiIFU+YdNdHqZX5UN61r3qM8hzI1JouTOY22bKwVpkUnrA==","signatures":[{"sig":"MEQCIA3hAQzgRTBINnwczzUzNQZNNq230RoQwPWa9P3OdqSLAiBRE6+JaizwvGPQPWA8rh8n6bw4QMe8UwRg0WSARXvUAw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNezjCRA9TVsSAnZWagAAW0IP/jHsFzEHBAijKjZGl+BJ\n1j2opVGxiEIj0AtpbNHv45opnj+5xWJdSF9ezxgtI8d41Wnvljc6QiRzgeZj\n/CM4JzTBUnelrMXcWBmDxIVSuBoLuE+cL4WFwf4+imK7FKdp/oVa7laIRHUP\nMyPNRsYfoxkpmIoqFdscHCkoM1ojLZxXDfleZhwfpxXeWWahVcV0/gIIR3XM\nnnWvdNQtna5SLq9CoNqQ7uX/7eG1Dwzt9e5L+hFOLqlE6WKbyRq1awv04Kcl\nOy4L9tubvCyPhMWfQFdZB0So6hwcM/Xh/V2cw2XMYfIOpHDXMrJdgMFwRoDi\nn7CK69qlsl6M1R7dJcP7hbdQK0S4JRXToBg7/RzUZI9EewHZEKIAlL6o56hx\nQeeFbfK+EUpjiVAaVCqNi1sGc7uZbN/dhB6v1M/s14Y4rlTJ0s4e/nWlm+nd\nnwfezUL6r3ntwdJnlBJXQwhjYxEbFSiTV2JJQm2IMuDgsfPYIYh+7tFOqfI5\n35V4Io3CXTZ1O3uwESNV6HpBNTyDwjsY6XYOCbDHtqWoszdzeVIOq9uO2Rpw\nf72gMVYdwQuZqWKVSLZMBrJUA6dCQ0tXBrlVegHZM3Ec30KfqXm1pXxvbBVp\n4Xud9mi3LQXGHu5qBIzwrha+6cXQGQzW22bCrsQ39VVw03JuwTm5J+bdQBv6\nHvoO\r\n=vVtf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"61b2b15662c2fce8e9929ef726ff17ab92957382","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a7ae075-1597369520429_1597369570425_0.6084424659957846","host":"s3://npm-registry-packages"}},"1.1.1-canary-c57466b-1597400116052":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c57466b-1597400116052","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c57466b-1597400116052","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"89d3c4171f1a7582e73f24c2f22264545463e6f8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c57466b-1597400116052.tgz","fileCount":8,"integrity":"sha512-epQCY8uPVxSZhNkaOmEYowcPuhTrmLQq+LBAwlKAZHLtf3fqyJM37wY/sC+CeeSzOYI188uJt5/j8XlRnOF9ZA==","signatures":[{"sig":"MEUCIB7/mltG8AuT3U9WATRUDhdQstNY6IWvAgdCp/54P88NAiEA+1+J19zxmBfuwPDrjxdxAOrV4G4L0kj5t+fDNyTyJeE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNmSECRA9TVsSAnZWagAAv58P+wZ6cGrBlz4yrbzPWjQN\nV+/XfsHZA4huYS2fMyv2xlUtzeep3S4yuIZ+wNfiLdTvLKzRkV1/xrJ+IHfF\nC8HNfqfX6UD1asKMTgLQHGf4S7cpNpSUZY369ijFP3iTW/22fTHAkaVgCcsO\njhn4xA9TCyotmDpmskNbUZAiOXzPOkhxDHF+CKydW+rCKtZ1Z7Con83OR3oS\nNmnlqFd9r10Lhdfh5vhLpwKmFhenNB1rl81SC5ruQA26AHdnh5wda12d2k6e\nLS8t/GT0YIAQPB+voQF8/jp+EsDpViHpVozU/SrZM7ABpnkU84D6PxcbGIq+\nIe8D94P2zF0KzCvE7mJ9LiCi365BC9U1RHsRajAqzwsWtG+/RRZRtkWpeBbU\nkoL+7O+TR/Mw3Sm32XSzzLG4tCD5T4rh2IaL0IlZQx8oN2KHJB4y6YUfLgEk\nVj8VJ/zLD4KH2hC6reujk33Yk6c/I+lg40ZamQYHjgMjFLhxkkzBAm2prdGM\n3VoOzIMhMA8vimI93Jmas0ZIRlMd/tPzsC32U5roFGBJczQi6Tr0wdjKVZjH\nhWxGiWo0rbUO7G/XGI44aBf4AUCDpRTUPtByG5mu/HQhW5CbjznsnFQ60ARi\n6nx2+aCUwDo8S0+HWj1e6aC5f1hPJ8uLUmXKQ0L+faijeB8F+Pb/KGYpMp4E\nsVwS\r\n=0CVX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b9b841dd861f33740550ce1f12d75455ba25827d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c57466b-1597400116052_1597400195639_0.6156984839992419","host":"s3://npm-registry-packages"}},"1.1.1-canary-cdde177-1597449664369":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-cdde177-1597449664369","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-cdde177-1597449664369","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"966446572aaceb28e2ee18f1f2e48b22f5f17d6b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-cdde177-1597449664369.tgz","fileCount":8,"integrity":"sha512-ci5bOKDG5p63C31zcq530XpdfdXFvEtKIAcuf2qvFsSPxsCdV52eAEMUtI2SAjVEOcWTYmz/UGPxEO/aEvHB7w==","signatures":[{"sig":"MEYCIQDR4HOR0bqTIe6765CFdCWZLElEHlHVPkfHZCNl+j2dPgIhAIC5aPm4knWh/14I9F0xGy+QWIjaqh36q9E9f/Yu4q8M","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNyXvCRA9TVsSAnZWagAA4n0QAJwl9JqLS6NSYBVf04KC\nQNBOzNJN/aDUInwsa7ggdQbvH/dE9REgJvs61rmgCj5/T1uXHI3KG1YqRJoc\n+lbOzGLUbyd+s+cApyHN0PIXCL5F0NzWTWfD7gbqPDEYyFI0DxA2INnyEUnx\nZ9Dz9WG3lhjP/3Z8EYnamkTBIOdbW3Y10SEzaBPYLYls94mrGOR9h3W2GDPJ\ncvom7G9IFvE0AjKJCWN2qZizw/SO7YBqRPZ5lQqC2m4Bvsov9KwHJV1eLf3M\nF5mO1kn9xm4VQMbkLmQD97w0m6FqzsVPTFenI3WT9TTJO7ohl1+KBM5jSYCL\ncrl/zd06lJA7Df9uZN1ToswqwvEWqJDu2mJtjjE4H01X74TBX1GzlrNnrEji\n0h58Zff8VDj2Hzsq7GzSNdx/+bzUZRiKKSe/T5O0cPqW8/dcg+WlxUY547A6\nurQeguL6jX1ALCvwvdyRF67p/EjEzuzqnUfsPdnbVi2qG2U66KtGajKvLX8n\nP1FpMmpFmK1PUub8N+vYM7k5SigJ3Ta+2SRKBqdv80pfHGTxygq60jX4uOHB\naTjl2inwz2EKzO/7f2fign8HTNFCK5/oUKGR53mohmEVIOSh/pDFcgszXuD0\nzukGMyMp6p/iL7G6Jbt8BM5uUJe8Ga69Re/t7Xxp6DG2byR9Y+ILS8YdtN3O\nd8Fq\r\n=RK/0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e664596e8f07165d91509e8d942e091006d8284b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-cdde177-1597449664369_1597449711211_0.11189270758241743","host":"s3://npm-registry-packages"}},"1.1.1-canary-bb41975-1597453968183":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-bb41975-1597453968183","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-bb41975-1597453968183","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0a36ca1965583e423338a14757c8fad03496c36d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-bb41975-1597453968183.tgz","fileCount":8,"integrity":"sha512-VWp3iSMiD9ddCUFzxnfwGo7PSWPNLQT8pRH9wrwQcS3NMSftao/Rnb0TZQpGz/saTdaAfpim/9gMg7Iny1T/0g==","signatures":[{"sig":"MEUCIQCrJKB0RGFrk0XoDJb7shHKk7B47QSV7qbDju3jqxtyaAIgSFT4tsbUZTVhmfh0OiZlb51rua6HQdNTW4XpshnHL0c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNzcBCRA9TVsSAnZWagAAPhsP/0Jewu8dnIUQbIQcf0Fz\nR2h4N22iS/uHdQQlM7dZ5+nd7VcrypsIXm3ZYQSBvx3mudTTb8iuKi9thkXq\nzKXJ+/9/bepesmcb+vwGcXXuTr9oBRAzFRsFva0+uCddc/mtuo7FY/zqRR27\nb5J/DIAFp3Ve3kWh17DD4Hwqqx/F8K4VQgf+HGtBAYMq4A7ziufnnErJT94W\nI0bblnLwWRSar/kX0TPbWxIr7CFzR1ezEejnjRA67rstjwmx+8YGVQvycTVT\n911VTp57V1S1L6fvxoicOeUcqcdBSHi2z7yOLaQE8x3kg6gkw9/fZpAFpucj\n7J5HwRTp2805Wc0ZfkybYI1+nokIhmKGW1UvAjPQCw773+vgGWaiLz9SgqjO\n3o03cAqsjodBIpfGhf/jOJF86mNDEGa1vsRm4NBnuKv/ACfI22UZbmnz9zf6\noPa3yAxAmY4VjwXg1Kt9szEurN/DYVdTsLOrXlKp4TbTNYU1f1+VhXA3C9uB\n7yxEorTaEI8clfPakIebO+VLyn0Xntjms7KgZrC/PvmTaioVWA9Sky9uuBVG\n6stkum6ukAlgTAcP9H0FWA4vxXkP2ZKecD7Q1w5r9Y2Dcca1ABWpD6gKUgjr\n/fNTFafhfnSaVV4ZE4oeVCpER+prN8nOecyB98wigtR4M8A8eLZ3CceLlUWL\nv2j6\r\n=9vFz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1123021f5a33ca86850391ba84286d76dc1de5a7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-bb41975-1597453968183_1597454080644_0.0791543199818725","host":"s3://npm-registry-packages"}},"1.1.1-canary-0ef57e9-1597467249834":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0ef57e9-1597467249834","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0ef57e9-1597467249834","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"eabb057afcb6e7e95865e358c1049deae52b9fb8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0ef57e9-1597467249834.tgz","fileCount":8,"integrity":"sha512-ZIG6POBwhHOhFWNufIP62htOfylvwVPirj7Cg4YfIJXbygohCjtR7EdZbihRzbSs3BMW4K1y0eU2JgL1rrDGvQ==","signatures":[{"sig":"MEYCIQCWq3jKuz1pd3Rd9XlGWJPhfAooEdwPqkcPOt3ZjkPxtwIhAL/+k0OVf+o8tZD2JhKtLr/aWhVPC2qpByiA9dBurzKs","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfN2qgCRA9TVsSAnZWagAAOAkP/0tAbCcwoc6cDzs5/Fyi\nsWyQ/cBEf7EEIRWmohrWvdOBofItbpISjxg1O7RNXWMbki9xrofYr+QSsMP4\nkqguGuj5SLWIsbGEapwnaTw4rvmVuwjIkz1trIULJlaQM8CY2LftDuVWB8Zj\nGXvjMU4ZD/b9XhcC0CiT9K39n0KtQHkFX8Yeyeg250FnRb7r1zVPf4ZReraH\nkW+1snrcvZAH3dmf1LUOP6l8sAAoSe+eYwHfRt9EKa1Klq8VbyYsdU1JWKGK\nT4xmvc3b0pU/UVYz0KI90MrNmhCgvBPghlX048NNbIHe2KTweLmfN+OgtNVj\nV1uazMErtS//nbZXFY7kXCABytKi0CVmzykALLt1GnmWzJCxFbc5TIVdVPCp\nra8trBt4kPjhRuXK1zb55ip9wnW2aAh+dub7VU9iZ3KQnJCQTEmxXFfOwPc1\nMEXiAi3CsTEgqLCWsGbvIkoCTr7Vcrrs/9gl0zCnAwPgfe3KLI14/sNAOvnw\nYCMGHoywdodEZOvZYtwMymBfT7VWNWbhvUAJKgzTYfJl0atWDsgy9Swb7iGp\nCH3k5aPLavy1tKhv9w3Mi1kZxz8sMtQSu6Vxh2PsBUK8Ee5W26X4QKda3QDg\nseKgEQDYg/3YoB8EkiRQLCrfTJ6vfzI7Kd7iylNIHThtuQI+fsOQHMxcQWw3\niQ+T\r\n=mPpP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fdd4116aad2ce3f9d554a877d3e4204415657502","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0ef57e9-1597467249834_1597467295662_0.21525292262342188","host":"s3://npm-registry-packages"}},"1.1.1-canary-9fdc7af-1597553784580":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9fdc7af-1597553784580","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9fdc7af-1597553784580","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2f24c140e3cf6aa2d8520b82518de1e81509059a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9fdc7af-1597553784580.tgz","fileCount":8,"integrity":"sha512-N0o8iNbVNvGiirxWq89gDImR3O+1L8qAxdcJNF2qDyDklySdYjAP5XPvoiYs1Z/YRWgqSOVEBTUiZ8K8XnZH7Q==","signatures":[{"sig":"MEYCIQCNYnCwxDtC+TNJgLUrvPBVWIlSuyqCdZFrfRfgaV156QIhANiA0R09v05WDEpzoT3zXrAE7QXUPVHKgJFDy+JKvA8h","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOLykCRA9TVsSAnZWagAAD/oP/R/4riTCIFuY0uZLEff6\n4YFXVJ9edFV/2JhQ4ke+1lxNFypY6+EOZZkCXI3S+ukvlGtYZhJmXHII4Xb3\n8YbMDE9TZuj/2P8eRfae6P9kwOwgo6iI1YUwzvJYJrsD8PVPj2fUWb7hTZ9y\nVU6MuTTRpJKcMPNTIHZlPCbjegZkzxPJhambfolYxY9u8BnTpcZrLIyEhe++\nIQBvy5LImvEHWo7JSG/HoP6eZSWcjnnRuK3zzBd0OafHcx4iAb6jOBvKeP8W\n+STWvI2gOmHEnpPcz5ln7YlTNvqVvfnyldYYIMgfm4Z46x8d98imYIsoHgtN\nI6EpYMUvDmP5jeiN6Fp3484Bb5s/mYzWzEAz2EBOvFgGvV0mHVK2mfjxkjZa\ndVkJCsI3ZtbFwerJas97EdiZrx8BZIkBjD1ShnhQTJXnymFb9LWYwpNV9DCB\nsa8t0pzreYZG70XYtA0dPL1fM3/eRyTxVyYu1QA0tDoIvCxTymMeURhGOk7A\nRWeFuphKBhf+IXZSnqXQgaUuys4rZrY0oiszXSvO5IXjh2Wg73BiWsF9PTuD\nd0yPRPbuk+eX//9rbfLuY1MSxLuEbg2N1qA1lq3McPM/UQpgo4iMShCsQZ+f\ngfH38bw8lnlNdCG3nxstqI0vrJpNCwwBrTN2ZUPOAu/jkIRGdi8/HyLjorVf\nmrr0\r\n=ms4N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"17c84827fa13a56ab4c72638e11ba093f19d08e1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9fdc7af-1597553784580_1597553828250_0.6095275462234704","host":"s3://npm-registry-packages"}},"1.1.1-canary-2c57508-1597557839436":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2c57508-1597557839436","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2c57508-1597557839436","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"953c2934be7e650c2e7f2ac275d2ff7976e43747","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2c57508-1597557839436.tgz","fileCount":8,"integrity":"sha512-KhCHh2CXo0qltvowc1rCtCqm3lDn2rtVSiLEQpoJVTfrUeKQFp6/Ho7juAdmaWTQ4di+NLj2PXN2O5hvWJwY7g==","signatures":[{"sig":"MEUCIAz66yWTYp6VvOrzo7OcOLu2z6j9xGaDRbJboTI3iBsxAiEA2K6pZ5vs8ZK8YWo8eUeXL2qa8fL4cPRXJ+M+eSArvqE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOMyPCRA9TVsSAnZWagAA4E8P/1jDolCnu7zD7SMSpzF+\ndsQUuIA2GlBozGOkOlK4tcMlpbkgD+EGhwa9FvPHUXo93tVBwXWlhYDB3+vm\nW98ogOMCULUGv8/HWkRceYolJoxXYhw6zrnHbCQs6V7U+k6bhh51bq/XS3A1\nnUV8eSXTC9jzSzRxQhfFYXz63G1FtcOp5hDQILhnWJoGqrCaZrHUPPx35MQl\niIJRihYwk9qm/WZPVXBukDUi0nSQctpVNLfwDYE1cV8f8ogQGGZp54I4J6fk\nlZxEr3EdWlls/w1JDfHUq39smz2DITXSwfx6WBmd2WTLg/B4MWqMO8oxhFUT\njxu2IvWQPOo+7+Vz7E7mXf3IHUG7nrsNyQ5aKeGzuow4NBKvhlwv1lj2VxY5\nlY7oRqkiMw94s3YteNC3LNne5kAmb6VYpD8vzQPvhyyBNSANdSd/IobSaulR\nQ5J0yRRafTgLN8+cWzSuUs4y7AFt+VhKpP4gWiSRKQLifE/ZJuWXwMN3MDwU\n6CwOLqfv/f/nqH4RBqNpUz+CF4s/nsxgqaBMNLF51rifsfCRRZNqCKIwBQtx\nunRT00F4uAqkJu/BHFIkS9GO95O8wklRd1zQwsm6Cd5HOiygT1gdAK2uFCPC\nMTVHFv3Me/T87wSWVGuXjiUS4X6YBXZWPU1oHBS0N1S4fpLHGSwlaUuEU5l9\nRi8F\r\n=3SU8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b755cdce4e2c9cc252300e1c97ba16a3aa854efa","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2c57508-1597557839436_1597557902787_0.7192278325581094","host":"s3://npm-registry-packages"}},"1.1.1-canary-131940f-1597607682619":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-131940f-1597607682619","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-131940f-1597607682619","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b89779a3eb337cc5c879d6435c96bab7b05eee00","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-131940f-1597607682619.tgz","fileCount":8,"integrity":"sha512-l+Rnb41RQJNLlhd4I6l/VfItkL+NSS5MI+JFvwGpM8YRDIoXnqqfWQqPZmcwW/PwDsDQebRoDYLxJDkLAPdVmA==","signatures":[{"sig":"MEUCIQCLWiSRVbz/hDMQkVmdlsX7T2Q2jCvhN8z24L6AMH4B1wIgB0ktNqtDkx+2VEBW9Vyn6kku3UQHYgDSThNU+GcA0Eg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfOY81CRA9TVsSAnZWagAAN1IQAJ7QzSTzpEvca5hdvaxh\nsLJMfuHdouFuUYvwP24GcpkLuOKneW2c0e7Uks+CdxO7sP3BDspQawzkElR7\nLJp60XQxLbV/JIjUHmsmJ6r3iyx9TvcwG6Yk4NMCb5Q+aq7u+Kd+RlG54KEc\nV0F+X+2jWm3SLQ77dko5aq0SZGif0YywkRHtIgQp8a1o1xx8NgujHhml4/C8\nXN0kbZMCxkyK4TZZNkPaTaR7dKap60+1IugOMwexVNZaKOp5ia2XL6NhGnx4\nX9IL2sS8DbkjzUwKdDE7PsBBmYPFmeeEOPR1GVORJAFhujfgBjhURZ9Cef26\nu+mpJloYW7LcVYTi4qaLSmmgCnnILv7JhpGZuihk6kYK+BwGqXyN2gDzReWR\nSeBE6/jnH4e5LwcqOBJQgB4WSl0sijcdcLACsnZEAwPi6ldlvlYWMQSpC7+9\nZ1QnjjT2SFvLqIVvRpfoeoJnWFaTRAcFMNGrZerp0QJlYCTDZsOfj8QnvgNt\nOPkI38gevwU1aa6yfSiDFHaaGAMqMnMekuCPhowFS8Y0uu54K2u1SeUBU0eW\np8rM8Vt/F8oLD8PJd/Rxr+jm08le9xx/R2Lzug9PQHy7kU4UMPhnRRIaP1Dm\nnJHPIl6aVKpAJtHMVfu0KELccq8dbCNyRpF+LjoIfNnOfy0HNIe0zVRN91qq\n+M/V\r\n=7cAM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3254c286734574ea2e076be2101374e241a6c6b9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-131940f-1597607682619_1597607732793_0.39259772677662896","host":"s3://npm-registry-packages"}},"1.1.1-canary-beb9192-1598079882939":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-beb9192-1598079882939","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-beb9192-1598079882939","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d6176cd0ac990c54c0c361777489ce58c29201b6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-beb9192-1598079882939.tgz","fileCount":8,"integrity":"sha512-l8Tln0NjGv/ue5+hnsSaZzeMjFFYjfKhXV6w2v/HpkcjB7jqOLjnnvZCeweKwEj0UPepxK7cPJVVC1I8Pq8Qsg==","signatures":[{"sig":"MEYCIQDKv8kG7vVmar4iWNWOgrSsNHULedvPtOonWPhUFCsRSQIhAL3STfnioQVBV0mYNlR1jQff5o+bQ9J1KQKE0dWqduDu","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQMPECRA9TVsSAnZWagAAsFkQAJ2rwqImaZlAtB323Zbh\nwlOlmT0x8X5zVfi8tGy4d6GqNRY6QcGtrs5ODqWgOY/eiE6GJyvGLCOEI5tH\nbUufKn3rs43lhD37bgy4AGKf9xkb22nEuRdS8Awf3GZyavKCIuTxX3MT/5th\njCxpgnBLmuPAlzEkQlMiTrQx6EhbG0I4OIENM1ACnTRZem4n4GnVKpJ85dAb\nTcaqABc4W0YBbOCwOqwLh5qoq11LGNgcwmU7oQ954FEyS8NaNKCVs2uU8iCh\n4409gLUrL3ctGOAQbRkpdaQzc7ra1wtsJpf9fKMcOf7TF4ijuyk2HUry3CAx\ntbZugTvPFhKbPGFjMWqVHv7X/D0xQV/gpml60wKLZJpGm5L6dovGOhPGf2po\nKo0H4QKR0xsQE61MIRcgxR/WeEjKOeJkduqVhMc8XIkCiWXhEU1D+g69ay7E\nt1I9Ewo6kq4n/8hZ9km9/LZX43SG3BK8UI+zbHJGiYbUwGwA2QCFD37lmvE8\nULW4ME53o0VOEvzVSNHU45sUMD9mZkR4pk5mQ0MMjEuhd+PrMzwJPhu5McOj\nhcD9vJlgxoGnukrWfJITqozeTj6mVYyZ6Z7AVkbnrdDmOYP3svsktbY/fxFM\nksLgjZNUDZohw1Zmr2ORrXdY1IcxX0xwoyprwb6be83pAHrZU3i4JiSawBdH\njZhw\r\n=c28V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f6436015de1cdf34ee8a881710ebad78a31d14ac","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-beb9192-1598079882939_1598079940436_0.9541286148199473","host":"s3://npm-registry-packages"}},"1.1.1-canary-9cbd1e4-1598101965119":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9cbd1e4-1598101965119","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9cbd1e4-1598101965119","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"505a96d6bf697dc914f32a9e72db019479f5f983","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9cbd1e4-1598101965119.tgz","fileCount":8,"integrity":"sha512-8rj9qmzixIYe70ZWwqnOba0R19+3Y/nEcGO6yqohE7zymKWI2S8boiCPKXvdSwpWSZlzcph6wSqp6j+c26Nkig==","signatures":[{"sig":"MEUCIDDVNhICoKUGNRax2EFjYTSJQPG+lwJ2BckfYAC8n0zyAiEAvIg5UBrQ5MoQ2nzRXCfghDaZjCorHLvE76FzAjOsLhY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfQRoGCRA9TVsSAnZWagAA5REQAI5IjH+12+A8cI1qr9p5\npZwZ/UokhEtNSq5dEkUTREzuNgiD2lFcdGXK4d0CvdzLk4ZmEwZBPpJpCmuC\nHVwZQIWzSsCVzlVpAOfmYNlzRGMWFAsS4MO7DclHQs0nnr1euM9D8YQkUE+d\nMXTxqsB+t711P8zZa6v7RT1gxoMthUV2OfCCSPDEtL7sL3E+PBUgJozTe1Qw\np7Y5BImKFRNUwb2uDeqN+s7MdW8nDyXbnR1OBa41JsizXNwav3C8ICazydkR\nRx3sfoZkWgIKKXkBFvnpN7co0iFkS5mL1x+SeIqSHVAQ8atNs9yar2r5BY8V\nIIHv/K2zFq7HI0kAqB5fgNbDsYQCQzFh34dxSFq/mvioDx8sT4PWYpPtzGMh\n/nVpFIYEoDumI1/NdbDZQepsmuy6xram8gSOATAq5z+xE3aAsv11MdkVdM/N\nkjF1xrMbAxsVkRgITPLzQlBepoU1eC088DN7LfCZOtmeUIzSzC95XFsnRspE\nZLAnYXCit1uSh7bP6tYMpdjJJRUtpP5FDObDeldTd6ruJNYZYA7pytL6xGvg\n7gCm6UXZVFQ+j6unTLiTSgpOJhS4+62jn/dgbimOsEwtkDnCGpDKgwzQ6Lc7\nUvfzu6OLDuuojYqIs/TXmbM3QM+DpV2ZqYLBJAT1O6jAjrA6fXAD+znTq9uF\nD9iQ\r\n=mijJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c55f99c930dfc8500cbaffad67201d9181a8dc4f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9cbd1e4-1598101965119_1598102021796_0.7585591697236131","host":"s3://npm-registry-packages"}},"1.1.1-canary-d8b7da5-1598508090877":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d8b7da5-1598508090877","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d8b7da5-1598508090877","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7adace54e7604f029b80c884596b60d8dc8f93ae","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d8b7da5-1598508090877.tgz","fileCount":8,"integrity":"sha512-FMAokEww4RFyj3+ELZu1TTCJ1qnBdlwF+lhxLSS4bXC+UShcVkzx7L7HtStmBMUPGjG16dYECOzplQAXdrnMlQ==","signatures":[{"sig":"MEUCIQCw7TXDzmojVNtr6FbkctHgwXNpgyCmv1wS4y5NMRGUSAIgHPTga5QiQ1AGrRGXCd+fABHyUytJRdoPYF16KFaxX4k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR0xvCRA9TVsSAnZWagAAcD8P/0/c8K/eHc+Ci2JDidII\nCsv7RB0PQUIL1FkQRzHB/aRxhpTrb64AOsLcoj2PJB5wgCq1fBGJqzdj/gPn\ndCAqMQLmUeYVhWaQWK/WpfN76lSr1mQpPbaHLVqteDxdmAzk61tNWuHE/sAf\nrIzAau9iYy9Khspen2O3kyGuTNZS+bLLF/6AOkuFyKIrTuaRQ98jdOiqBMTj\n1VBsk9azw6iCKRy037im5gqNDdQVmBnxCKUkV92lhjCQ2wGk6+AJalsk98o8\nLFkLKxkGfplQsd5f1UwGJeJENkO9q7/oBpJaW06HQecv667WQqyawFOfIgTq\nL+tYxsW+4+ZtFdINy7cyUKTvH27vW4cgu8palFo99v6ncDBD0zjH/KEhsVxc\nxGo2TF+UsQCuq2g15O6740Fm86z7Q5dszE3L6eGaKbR0sHahmdTYRwPhqaYD\ntcHvi6z3B0uyTEOb1Wf984af/VHCLe4o1ggTcYv3KShwm4v1adpXDdO73y24\n0cH7FWDj2/IlvyOUeAgjNc0YEWHRqjftj/HjjbeP7zNxeZoyZrBKsJgsBMJH\nJaEYa6s6mmrLbQIE866wKbw7Ckruj3RgkOZpmSouojqGaz6ZmKCryeYRXqvc\nbiD4rxaWRFctW0/nhi/YGccrnKw9TbgNuVyDGL8/wQ2v9eJg4g5dWtlJglfV\nJXQ4\r\n=9mHW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"29992e59127cc3d2be95772bd8655df562c58bdf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d8b7da5-1598508090877_1598508142730_0.3724177652599161","host":"s3://npm-registry-packages"}},"1.1.1-canary-eab086a-1598510892902":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-eab086a-1598510892902","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-eab086a-1598510892902","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"89e0bfed18b7e5370cb9ceb8f500a1184c4867c1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-eab086a-1598510892902.tgz","fileCount":8,"integrity":"sha512-WrMU3s9kHq61h51cKmjRxQzNzdXmjRD+eQjhj6P3oslsnoXZjzBJae9bsCWnf4yHGN60pr+INwobFPM/+c/QsA==","signatures":[{"sig":"MEUCIF0dRBydbZG5JBF1KYF8WAYx3rIobVlMdSU0MB6eEDzlAiEAtFRELyZyW2964iIHaX56ZvUMCD5d9kj/KshtPTs83pE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfR1dqCRA9TVsSAnZWagAAXTMP+gOPCSBpq1xPGwcKrUTL\nnK8vU2c/tCPQv+uJLytjsZsh0DLPWhWkts2uxJFmnqAZgPH/SABoUTiu/B+B\ntTuSa8i5cMozJM9Ad+Z5SRDn3WN6PWRwhX8fZFXhKYKl5uP4Pp/jUzIqgZVa\njmWE0blLRwMTcZ/HKUZdqfQdoK/lvvtp1bY4JaXDAA9LxOEzWZoBO48nXtpn\nTzin+pU+c/Q07LR/Do361rfmRE+u1YJXud4dJJA9Rk81dg/wKYjSY2wLH4kH\npXItnm7lrYQz+47n43RppAiRPogvFpMSV0UOfFSINl7XC6Bs2shHJWbGyysx\nQuClq5/K5dLEX79Vd/U0aKE3uN1SYHO8CwCV/7fyq0r3KLPYumOeLNDKu0Fa\nqjTOx4nJklbFnehQm4HZraW+mBjEvqtrYWCS4KHny0cReSBO/OMijoAhqhPy\nOXjUUY7u2hkhakqHlvwrsWRrkdHNXk2sShfQWkyflImnGCFiT2RUF+7zzjag\nZxIotpdjgKxOvYy458CKuH0+5REENIe1s91ROot1ax3HTQ2FF2QuMidfftYX\nQRzTziXAEpYhSbiscIjexZBcmK4nx26lF0yzBsgnP0AJfGpP5y+KczBX8huA\njDi+JYdFBCAqhCl/2AMOTong8ga7ixpRUFQ2R2lLdE1Bj7yr/BLHiZ0OtyGw\n5cD8\r\n=Bg1h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3ad1fd6d970dac68a3cf5b1396e3a12cf8013170","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-eab086a-1598510892902_1598510954214_0.2387219911001326","host":"s3://npm-registry-packages"}},"1.1.1-canary-5ba4aa3-1598592636521":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-5ba4aa3-1598592636521","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-5ba4aa3-1598592636521","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d46267dcdf51d24e3dfc09f8a0ccd0e888bc5e6e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-5ba4aa3-1598592636521.tgz","fileCount":8,"integrity":"sha512-xbkCSpWzWUhjLP6Yrz99HyAPM/vfqdCpuvHzS0uFmcd5XYv6fEMZYg7avQtf4p5uyWpIviPehDdhcrJTNE77GQ==","signatures":[{"sig":"MEQCIAREiIvC5LokbpMi9Eks1zCpHSOHyfa1tYAFKfmppzHuAiAXsVYbnpPeJuVSWj7/XhyAmJnRXLywUtRPk84bJ99sgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSJa1CRA9TVsSAnZWagAARXQP+gMW/4VM3IvQLf6Wyr+h\nRuBr5+aK5MYG3W2HugkpHgxxNrmZRpvOLIs2lXd6PoX8eK25DlmhhsnHOmFV\ni17kda5Nc9Hk0p7IRS5ax5TG+L/qV7sjDH2eVFfWWT4tEkcYNfnpGvK2yvyv\nzZJglpMS+C3SoZzaiVtIf3TIv4Ny+l+jdJDjLLmdMnRRW/Gf8f5m/nKIioou\nF+86/IqjU5pS/CMRtu/oBcR4OfnEFQ2aW0CE6hpb32/sOBtkc7+nuPFnyveJ\nSNsvv/ApHAUgB9o2tJsy95kf60ukECTsaboPji3Tunsn+hm32GMUwRS0FAGT\nspS86KKIN4Nlr5+zMveiHRtf4C/sX6mVdU1NAPFtW9wFk7qZEbf57nRhKozx\nQWmpjay3tf3wMdwIhO6hdDP0T9/jWgNpj6+j+PhR5kPLNxnCAxQDREZzKxHe\n+P71Kg6k76u4Ooy8wd2/CdFIV1HwEMlEsYEHl2GEBW3BW1iElraI5kWx3Z7r\nSXGykIl4qEL+KqC8K9w74sikw8/Z6V/KxSOF7fjFvL7+ctcNvlwVFxMOeobm\nb0dchtUet49HAOK7ZmDBK4CzJIv+ri7MckIw94oKT4fBE4UgLwqd8lndCPiw\nu8mMkGzBzpAyeHzqjebXYBJ7hAIizOxGwXKLOvc3NRYeKEE851q8ETidcXyz\nGPB/\r\n=Qp1p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c9dde7abbd12285af75552c116f394c1ec607649","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-5ba4aa3-1598592636521_1598592693458_0.7022426201246585","host":"s3://npm-registry-packages"}},"1.1.1-canary-9f75988-1598708164906":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9f75988-1598708164906","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9f75988-1598708164906","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2c1048404971587eb93d79afd0146ada9ebb136c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9f75988-1598708164906.tgz","fileCount":8,"integrity":"sha512-OCW7nJTva9E/PKAgtMWEUiXVmSFiu7EXT0FMWgevpkCMwIM5Ss+WwQG5gT0e/dXpZi6Uxg08T4bwpf+9LTEeag==","signatures":[{"sig":"MEUCIQDqPH1zjiWhqnIh3Va1zzz4/k8TWeyzv/mhUAPT1OHecQIgEQox14D/nVi0VXyZCRLZCxFOy7PivNTmIywPi/9ABpI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSloGCRA9TVsSAnZWagAAF6gP/2cL/nibXmJuhZs+MiCO\nry+oSpdcTmdenpW5nHS9qL2TLtE9C8/9gZYByx5esMPOtpZToBXlJzLep3Tw\nuBZdXNxeKraBAjyUsFFmFcU+SnNjMM6bT9fp65s+6Wx214EZiw3VIzWrZHuK\n6OXOs9b4rcrq/eFYCNfcPm3pPG/koPMA+ZJTxY2nVErNlF/kXSlWOpRLDE22\nEFv3E7cIJGqs5w5ckzJ28xoj0YOeGKN8fmv0bScZVcS3VaUyaybwktVTodav\nN/psb9bwHgBuIoRISvMOvlWNh68UEeIziELlIILm4cyjpeh701BS9KShA8SW\nCIGfYHwcrYJKEvQwxMZpI2MapbpkxITsT23X0pAQyfr7NCUK72JTqgroVT6e\nZlHoQ7/qbKDX1Ni7BQ/3YnkSRsEt/DfEJgvIKJNHUtKd3uJJeNfgJ3GHojnl\nGefyD68+SUp2QTZm2EUbtq6XUO1ykcgh9ga2UA0GCYKOpuDjkYwRV3Iy/hck\nvMoYZcBMBsskfxlE86L9NSniV9B8WYx68d3CfQI/pimnmIXcW4euug37kaoq\n7KMbPnex0krqiXIbKWMDf3HVeCCccENy3eOCKz8zbfGxG0KSkMzlTN1hi9n6\nx4VapzPfXNWpDpfFdfZynJsbaCbxXtK1KCW1XtNhQ9JBIMvfRfmetMlqgJs/\ngO/W\r\n=5WrV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4981ad613e4d5f0169f78762a37aa8867c1e0579","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9f75988-1598708164906_1598708229787_0.9706502622847577","host":"s3://npm-registry-packages"}},"1.1.1-canary-2fd4c5d-1598710337660":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2fd4c5d-1598710337660","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2fd4c5d-1598710337660","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"87046843778dcbeec7f35df4ae6f65443825335d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2fd4c5d-1598710337660.tgz","fileCount":8,"integrity":"sha512-311ICTmtP90xOp6EQ1N1elob/j0QDZrtq6L+EAkFYKa3Zk+7/+rz+sWUj3NVD9pjUJzBzMDJ24IZVxkSKwN5ZQ==","signatures":[{"sig":"MEUCIQD67m5mEdEIKozU61yMs9eDLFSGvoVh3U+MUI32jmVXqAIgdOaDeEKNZQrNyPQ5K6DJpqEIk/dzsbVlxCeFGwARGaE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmJ7CRA9TVsSAnZWagAAkCgQAIv3Kng5aPCqKjU0Mp4M\njPgVT2oGr/M8Ha395S6vvV2NA8Ncvcxxi4HzrVelR6kuuXcM3pBOmI5XLOi9\n6v7qmfr5csn5Ojy4WS03Yus8YoEr0cT2RcbZXqb7alOxVJ/t2dNlB8HBiqX2\nl8O2btS+MY4wIkc7Y8Yh5/iFFP0LXE6SvbIg81tygBDGmhuGboDMk+XLvJv8\nihfj+A+Qq/kMUEeWQjUA68yUoouhX4gZJlO4ndk0vVg/NK7C0LCK2zKK+Nr/\n/fn2HYJE3GL1Rr7jB0FwQuLyVYQobq+bMbWv2QKUPNrwg850iIKiP2fpX2tS\nKmDJzksUx9w4JLFBBVlpeeRcwvxxoIUhqsVHA3w0rkUVqC7j5ML56xgR4OZA\nudiut67rzx1FFv/FWtmozh9zawyIy6MyLbJNKODGe+Hy+Mkb4YL49LFYHLYf\nb/ypHh2uj+yZqdL230Pt2mAZiH1UC/POQC7S4Vnl7mEeqZdss1XWsh40jtd6\nrJweqFoEK4cHKhtbsTRiv/Ww9BQ8zr1gkSF+ZSKDHVTj4CUDDjZPTdSA2yBg\nFIMBViNljRArK2Ux8zA5OZ2KGnilhUl8FPuHcEHVPNa6cMCOwj24pqXXH2I0\nYZfdYYPWJFHb6vnZOgJpy33/gD/vz0YjOtNgItnUu3T05qZk9oox6dhEZSxZ\nrz9/\r\n=I+OI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"260fe7f7ac24b25e09681de088fa18966103561e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2fd4c5d-1598710337660_1598710394801_0.27697839318774564","host":"s3://npm-registry-packages"}},"1.1.1-canary-a428f46-1598712094514":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a428f46-1598712094514","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a428f46-1598712094514","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"678f6b136dee90136577132ede5c3a83014cbaa4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a428f46-1598712094514.tgz","fileCount":8,"integrity":"sha512-oxCtYUNSgRDnCAJxU8Ihut911SAyf7AauraLVpv/jf3D0nSGipjILqhJTHKlZG4HZpJHm7wRaQpq9YyWF5utHw==","signatures":[{"sig":"MEUCIQDTB8Lht7SodeK5YVU+YystubvoH9yozE7ut2YWR3GppgIgI4KqTeO7olpCzElHpmFKpW1H28splWzaWhJGDbaKP6M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfSmlOCRA9TVsSAnZWagAA+goQAJ9+kLaQevSsH5DljUJz\n35A4VI3x+inIU2n6vqbKza9qu63UIG9WhaZC1pkMQjdjMQTuuhh/PvL/0TZx\nmPioXcEhztMSp0iFeQvnVfp6P5+N2HBtS39yIO7DzWICB6BozniDPMsN4YiL\ni0wQVRkWfk0uDLGlYo3lj/I6FW7ktGp0hL5J95nT1NClcc+EC7ixMQqWyT7C\nqZgVPchYnTWlkub4VSJEnuFBEDYA9iSt4NY5BnyAYjSIkPs1laD9JZmgGkYC\nq4RDyF1v/EZa9xlLrHsCSf0t/+4VEVnsJ9PVluroYXfqsTQd8SX8HB2KEZ82\nNg2WqoTTWyZGEgxEGnnqr1Sp8W/oKJ8XW236jdcBQ6R+YMC1HCetDuu9Cklj\n2cO3PFC9nCCCUXJqrdhYsATGUR0zbOzzu7h0cm/IvQNUC+C1EqfpITq/pxl5\nvkpf4TLVZnlcjGsWoU/Z3T8CaaSYuXSsND1OdJqx/BPzWDwnkOOkoLaXUsdb\n/Lf7iWagmVXTJ7AWSecQOttEfK+4cBXy32t20RVHmIFD/OKdDwIQZvBySA+l\nhnaGjJeFOyhXGqtdjr/4edUhcPm+vRs+LaHbyJ6GAcKLAIK923dIQOPFpCZn\nmEY0Y4xXg6/aqmbgzDJUJXRGpMGZpvWBrkMkfsRpV83st3RmOgNFpIjlXqQx\nzRzx\r\n=iKfW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2f8d46ef00d6e420bdf7870bb900dd9b7ec1273a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a428f46-1598712094514_1598712141597_0.5319815367337148","host":"s3://npm-registry-packages"}},"1.1.1-canary-4eed585-1598969492986":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4eed585-1598969492986","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4eed585-1598969492986","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"359fa13775db5b5c8ef37f0813cd91dcab072fc4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4eed585-1598969492986.tgz","fileCount":8,"integrity":"sha512-tR6VMr1F57OE7seTOJptve9e0PRzAC5TilSbMkXnMzNewhiw1RA8UPxPKX4leo/W7FL8WWdeMSAE6qlBsSYX4g==","signatures":[{"sig":"MEQCIECZcy4HV/Mc4K6sFX8YG8DWdx0k9iNO69yn1Dn6DWwuAiBwYwfcEhvXxC4J2GXbyGD60HHJO+VQ19O1l+C7PnTb9A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTlbRCRA9TVsSAnZWagAAsPgQAIZj1n/C7xfiUvCnhQs3\nfGQTO/NgGRJ0kX4r7OV8xAzSgPBLT305mW++kd/6e8zQ+WaLGyvn/GShdwe7\n1flzNJ9A6V/zCYSU9zxhABFzhQrTNYjUYjNb3GGzmwiMIoAD9iphDrVIrHhU\nyX3h60gmyiyO/HQHcKS3wLz69fNpbEi9Nu10e7VpLrGgLqNjGWUBUgSq2TLQ\n6gaF9H3ksjd1qYksYMRT0oy1qOYw2ErfiSbxE+CXSiVqfatBi9HogdK+TWXb\nuMY19MgAl9Mz38ZzkSW4TyOKYh5aMHDoczG0S/4JsuWI8iEY7xXSQCzcVD+4\nCGV3MeeMMhu5O08t3nbIjTMAR7gA+lSyn9SN+4abgSluvT0T0hDkAtW8EbPS\nUOVEkgrVdKxMu8qKX1WSAXapNrFMXHa7ENYnDEuOh+FLP9hL3ITJaJR/e3d7\nRdG0w6nexxpQG+UdZ/6mkr5pzDj08pPkoC1BC1oT9aEreoxn4V37HtdFSDpv\nErhZWF6jo+eZBa/2RTpXg/udH7OYYtOrV4uXGP5l8DnTT3APuKGxeVe1YOFP\nEyKFMIWW23i5Nzkyi2dMImB6ucFcY8P4ZF/0iMxKJa8ZkXmG1tT0w5NnLkvQ\nl17C4n6ZRUJGUu0/Kow3NUDdyfUnd5gLKBWadxhovwJMB1v9k+SJ5n4bXI5d\nL2GI\r\n=mYy2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"66c4a4127fe3435c56552214f5161c0cc7bd7a3e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4eed585-1598969492986_1598969552769_0.22931868677706935","host":"s3://npm-registry-packages"}},"1.1.1-canary-ffc7f1e-1598974390531":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-ffc7f1e-1598974390531","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-ffc7f1e-1598974390531","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0ffd402e23aec0d3e1e6ce3ee883893fb4650819","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-ffc7f1e-1598974390531.tgz","fileCount":8,"integrity":"sha512-w4vtNrbIEW4uaI0Uhk8d8fZCxdARDfuYP7if3NuOYgeiezMT7YAZOziYmoi6xQa9HxyyfwVV2bx66uDQprZUPw==","signatures":[{"sig":"MEYCIQDIL8G99nt+IbNS9pKgnBHP3EHEunXzFlugKcFYml/c3AIhAPH4ap6QloTUvEuJon3m0rTPakhJLlmDGJm4Mf9eqNGh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfTmn7CRA9TVsSAnZWagAApKQP/jEmGhhn5TSkxz6JBAsT\n3bMH84AXjMJyJTRg+pXeEqtkMpoG5UBzlmV5jvHfVVdNeFjS4IaiyUObV/Pz\nch6O8KzL82QaYDmKg2SACADYXdM5zlpY0wdmKpVC2foxu4ByGPFVlezphEdZ\nhjGS+x+RsgbyhxeAK/64HEQjx/nsEGHVunJglC73dvO/O51CsydtqHh+2BYg\n9YBPwg6b5w+0Pyjn+h1DKjMg5n/NEmKKOF/1DFDeRKGKmWAIpsRC7WgnARHh\n6cosTNwV7zGeqFu6lx07dMmg1ZtH6ajidw0z6+7GqtaDarxGsFwbx97O3/of\nSTsEXEeJLthTZmDbHDFn9AgxZ5JVlKlkzF1lX4XLOcLslH410Ol26zPJp0Mf\nWw2kA0ca0Xl6hsuHpsoR98ktZsUL0uggq6RrnkdsKpLElNCOTYXOA+LGiE8r\naObd8lVETxl698MWWebG7ZxEd7QVMsbymUY7+wf/OqdSIytejhJWrfQ2w2T8\ndNf4iqBoYa66muvImGxawlzQNSI06hQgL8Kopfb4LohvVpn/2UTnXUuOATb8\nxf6rZqZBFF+Hl+0eJmzsC0HDtSBxOmUibOHoCJFoiDyVLbQ7TCz7trPrOQcA\nS5b69VHJvK/7GXN3WxO+LVES7+APHmS3cAqMyirq4CAQQt4VDi7lqcnCQRQo\nprOk\r\n=ELxa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"41b562e369a6824121024a737b66f7781784f9ab","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-ffc7f1e-1598974390531_1598974459011_0.8550298430366576","host":"s3://npm-registry-packages"}},"1.1.1-canary-2652c98-1599031351178":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2652c98-1599031351178","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2652c98-1599031351178","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f8d9d72ab46a130a7cbaecbd4b267e602d0dc733","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2652c98-1599031351178.tgz","fileCount":8,"integrity":"sha512-XmXBN/BvZvrJL5rSpxUuB4HPHlguDHgPwrEVdVe7MjdfErHuMp6IGmk4eSl0QQG4cWQx5krdDWfgD5PpM+gywg==","signatures":[{"sig":"MEYCIQCGj0OiiSeDf2pZQ53z0hGUN6UoX6S4zr+A4f8blVmzJwIhALR0ITyzXE00HFTBSAvmhB87PZoCiZTFp21h2H9O3N84","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT0hsCRA9TVsSAnZWagAAcvkP/0ksfu4x9f2uFxq0R+RH\nzyd6Qu7wtUr00nxB1+psQCSoIt25ibFUGHCN2U8XT88j0hwDeZv10LrDjy2f\nUYCs8PtYAklw5ZRjNBmNueyCsGT52UwVeriCJvpng7drhSVLq++FBSre3Oye\ndQ6eyj1jRZNUb4mTBSo45BSAEZAiXJAVpadYYpdFKr8kJ0tOJksMSBfACHJQ\nShdpsQAZ7Ei1xlBnab0pTWh8/xR2JxxKX2T9g0pAUC6dctFXn+seT7x6nX9I\n52C7eoH5so/1bam9XPOHwdT/QmpdRBYVCibQXdwfEvorplKjtVZpJztKaWqg\nwd3SXblf1xiv/jx739pmlr6yz+p1SGsYa9MSedlZabOz3HSUQwgrSeB/EsT7\nh7doFjM5a7QYMxf/i+YNOvORnOchpaPD92wuqGJEYjusXfF550fhnfllCoc6\n8amJe6Oq71UuCyUlbR3Ch1oH8+pHiAnq2eKfnHbfX2yU90YCuiAyZgsvTPgU\nCOD5uZBJmqG4mxSbmKyaM16Da0VWllrviAaP6kunKu5BWEVLWP4iqjrDd5rr\n/VeQXTBN194nJ0iJhwp46nn+OjTP2m7YIPg2zxbXdX3/XwATAkhTrhMGm7wq\ncYaHOIVIzEhe6cJyGFgAfegQijBqqK3lw1k+QcPcx+GZvHXCNG31tsbtzfry\nPtY1\r\n=C+5D\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"da4de83634cca535504d84fd31b80e8e8e354433","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2652c98-1599031351178_1599031403399_0.5405932910016746","host":"s3://npm-registry-packages"}},"1.1.1-canary-2e25b95-1599067290644":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2e25b95-1599067290644","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2e25b95-1599067290644","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fa7ae8cdc81b0edb2b86915a3095fb247a299169","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2e25b95-1599067290644.tgz","fileCount":8,"integrity":"sha512-siWFE4wJSHODLwMZRhbLnBUXdztghB0u8KRwvxAy5GxNjkAmb8SGJVxklKu2rWxZ3XrN1VaXhfm58FsCS2VGbA==","signatures":[{"sig":"MEUCIAZheiDdX5S1OcCnZ77VwjPyFO5PJbAI5TITo2V4P7JjAiEAng5sURcAexcN6B1efMj/K9Ya8uELmq/qFXnNxbXumfg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfT9TMCRA9TVsSAnZWagAAznEP/2PpQfdj0UNEoWoTAJak\nk+ufvvmeE9ENCTMFIQAzkjOGqqKal5WlOEEK/l/ile03RofFZun/gvjHYOi6\nPF6ZTkKYMuPmVDmWAu/6OFz8+2MgAYy+vby0EEDrRlc+nbk91j67vWIKk9YB\nfolv3Wuwguv65pZ17H3Xg9uNkosBYx4lgHLYH20PggQHI+C17hy/h70KHEj/\naoH8L8wM6h/3ASTQw/wuqVhssnjUfAzhf9iMUN94XH9rVGEAVksucK3jyFWi\nPXqwdsHIERoLNH8HZqDsx5vPGdAoPmGtz7CpbK7VNpPohuVeLXunuR/hOQNz\nLDfOSASP/m7NfsfIa7OUz/ZltA5+LRkG+1Khj+qMb+P07M48J2tKt3FdnOjx\nFWFl0yEeYj5/3ovhPq9B65BFzsvAFDSZnqUu11durYqEXZKBeOTsth6AmvQd\nXHhIQezxTWFIBpuHGixqr1fu+m/9UtIC3WxIom7qdjoIC1gFFZXflf+TJq2g\nbyV47hfCiE31Zr4+t8FodTDWPK14GiqNjJBlBpg3pPRWZZvu2Fab+N6UmNwG\nhjyzno64mlS4fIajHskHv8E7gWkEH20cvoSAnH19AZ7dkVQbqlV9Ko2mXkf5\nZzmmaetlOJDRbNEEZKtJQUeJilF8WP9SpdgjqeCWd85Kr3nbuMR8dDY07Bez\nut6O\r\n=j3xg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1a8a3ae688ad1192735856e133f4f59c3928cebc","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2e25b95-1599067290644_1599067340207_0.8442098627486043","host":"s3://npm-registry-packages"}},"1.1.1-canary-719a459-1599145407024":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-719a459-1599145407024","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-719a459-1599145407024","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c9100b9c11eb53b94578087e4f021ebbf0dd4958","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-719a459-1599145407024.tgz","fileCount":8,"integrity":"sha512-5vE+XWoTuDusg+JzBqSMWKzGVX20EVY3KDouOF9xtE92uQ1Mi3ovuFdCvfraTev/RqhMSpCjrxvHaIvo5v31lg==","signatures":[{"sig":"MEUCIQDODANd5cGd50q4/2sSt8ilxXch6tJL5YncKk8wJOjxBAIgZu2Mm5HSjPUBZlt2W5YvzuNPJ8dx9VBp/TlqbfdnHdY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfUQX6CRA9TVsSAnZWagAAY0UP/iKDm+T+f7LALxJb5gQa\nYocHx/L808gTBTnUtona+dT3ylisnW++6dkrdJFjKc+nj+7Otp9tQ0rW6mNE\npru+32uJvY41IVnFQOAdLjAWPsBGGkqpNLO0jVMTxesBPxzujfoOgZRiI6An\nLmFO+X3tTxvTCo4FUOnFFNGzB8gdIBZasa90YxtNdx0+1hLyZPV0QYVf5XWg\nAEKR0urr1eJsxNPlWJ41X/bcDO7wDX9waNtuz9NUXGzSRAR/2VWf3kipdmdB\nFOuQymKvyZJaNV2aspdrKlnTW0JEc+c68MyIn7g/GynsR0yOH3Q/mM1cu2oD\nPn+LBvOhVO4UvUM1ih8758jk4uCYUD03as+imz2bZpgtw/Iw0psAqfax6zVU\nod26UEcFw+HqA1OiokXPSCF7/C6d81teaGcdrC2mNfulLFzXsDE9OTk409/m\nnlmIHtmlOWxi/p/qNSdNkXWBh562kDEvRqF/mvREYU9V95+egUnqECl5KJYb\noprAquI94jRomG/nEkOdYgGgycxEfzBaqNwES1a7lMQfpZSPilDNPIWYtDtl\n7ajNOfknV1JDeLsKPwKOh5plvT5DfY3FA2zTojpk/3BUmouDHwgTMAJE3WOn\nzXBWf4UgibKDXuGHb1PR29pmTSMSeU7Bj0MX2EFeL6wbB70vqT4Gu4ZS28VB\nCp43\r\n=XfwZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cc98a7dfaaea7bae32216de3e97b6f8564182e27","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-719a459-1599145407024_1599145465945_0.8528433652496255","host":"s3://npm-registry-packages"}},"1.1.1-canary-3f954b2-1599330115651":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3f954b2-1599330115651","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3f954b2-1599330115651","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"86275920b6e0717e2a604da66558a1dca673260a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3f954b2-1599330115651.tgz","fileCount":8,"integrity":"sha512-RlvFoJz0BZlfu0Hv4OqLsxCv369dc4+RV0Z9A1p1DR/K0oaLDr1OBK37cflB5PaXnkEHMAINY0CJu0thETlMhw==","signatures":[{"sig":"MEQCIFzlSZWNhMgJ4n1DEXj7sFwCX1UQ/UWFkq0RBQ4icsNAAiAH8wxfXJKG++WaHOOuBa2mD3n09cp/w7H+YL+kqqMZlg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU9d7CRA9TVsSAnZWagAA9eAP/2+20u1VVkpLL6msICs4\nuBoRlLYbubibDv/7UwnstxXC3l/gdpV5DmZaMunjm3iE5QORhjDKLbf1nlLU\n2sOnBYaLIGvU6/S7gac9801ABLWwLm4Zk1dEHbIkbsR06Nip2lkCXq3oY6p7\nHb7S1bUD3uudZ40fD1hnesiYlLe+YP7faxSGsutCOWaRSMRrpthpJx7FBeVK\nPDQRxOLBgwrZ/exHoFuDCIgdfUzvUTiP4f8zfZnjVvg3ek6z7nVMl/m8IMop\nMJZh3tmSzVr8w+JCGb4FNWIgygZJiYqHPJDR9BOuPNpsWxmakkAOBl4E/EOT\ncqARVV0m6Ed6FTkmh1KYSb+I+KpFcjnWbmjKeM/JJUpRpYolFSE3UPbPHzl5\nklzHLE9NyTfbK9y7EkP1ZtOWRKDrLY0ZLPsEZhHwA9bf16ikKIJls1iAfrPI\njecu3BI9A6gylPm+Xs0FLkT2fkVmyzfKv3Di0YUSuUeZXa36phIFCkOV9TF9\njW6nOe86UeOKnLXvppNOxfpWux4Z3zVSO9duZthI4L6EOEETsl7KZjW8Vz/o\nTFEIa4I1huJlgWxIv9nF5qgtFk3EkzFKD5R9Yo5itpqkiy6m9CVU0nW6FBpP\nLEafjcWnoq2ZCC0t9XBw+dIXZL0v2u3CMBC5kvOQePWMOMXoc4WCDyCGkgJg\nooZG\r\n=mhkY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"121193cbaadd6bb3be2fb29b903ab3b1d07339b7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3f954b2-1599330115651_1599330171170_0.7530717105660856","host":"s3://npm-registry-packages"}},"1.1.1-canary-344952a-1599339415860":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-344952a-1599339415860","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-344952a-1599339415860","maintainers":[{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"104efb2a3f9a9461e894f900c3ab197d67f6dd2b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-344952a-1599339415860.tgz","fileCount":8,"integrity":"sha512-uRP91lmRXaWymjP10ocB1BKK9p4sFG6/sOC5EH4fKNfJ8QDf+YdFnLLeLBgo1IsFwarI5ndICepo6Gm8ygHGmw==","signatures":[{"sig":"MEQCIFnQCQFbPxI/ILFTxfAn4R7TIpbU5Mn6hS621vS+2gaXAiAhIqYk88nOGd6aaeXWiIEEWmuZ6eywcfe5TmXiQz5Iwg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfU/vOCRA9TVsSAnZWagAAy3YQAJMOACDmZDPC8ha1Rhcs\nfzPIPxro7IobTm7hKrT7RtzGuSX0nLOwShXOJCUWfLvg21g2yeE42+wFnAAZ\neA6xsr0EjY7YQ1ggR9IWMiDkJHMjYzkKD2yVImue/0zsKEihFnfuA9ey8mz4\n24f4SrnRT0Itf2fLXt70Q9TupI1c9Z17IK1FVg865FyV9jsXF7RdvCZMzCxN\nmwgLTtQqOBMCbLQWZc9wGxWW8VveK3vqr+g5lMzZ+PzRP925jmvuk9ODWTTN\n4CX/LkKUuxG7Y4viJrtQDKSccJFEhWrtNlzVT9/BNLh7GDiZEj5KSsrufhQJ\nlGuZjpTswbGj2V/VOUnaUhqXKsX19t8IByWjsux7HdmLLIMxMroI6XSKra4l\nygX3ascv9ZEhvGr77LR2I1U32iV5uxRAMw/uslurYcQpVPB519g+zZDS6OZB\nDuNep/VwGMKBcOhaqhiH3ZRNbKu+fVaGydJfurCEMDV27GZCf8ExvVLNLm27\ndrxSh30PPJrQ7cq0APg1/l6HwiU42fseSQJOGfUC+pIJyBgHBjLT+Sh/8cjd\nxtV9md4au7HfDaxngvROWm8gUKqSUbKSYmF1z92a/3/FiQnUNZr1JJ0kY29Z\nyM1qi296B2DeQHs3JVQDC2OI2JSkUd+GJyQ5J9IofWwQmXqZa89QT6BmC/oY\niYn+\r\n=kmdW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dd3aa441e684a37e39a900322f7b7ccb9ef15c5a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-344952a-1599339415860_1599339470201_0.07159306540415589","host":"s3://npm-registry-packages"}},"1.1.1-canary-d2d2065-1599936663488":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d2d2065-1599936663488","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d2d2065-1599936663488","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a8ea6a070d976f1955605aed69dc3287d53676c2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d2d2065-1599936663488.tgz","fileCount":8,"integrity":"sha512-4Td0Y2wf5IofT0OkUxiMOMiJcMGH5wT+CHalw2q6y4rUYObJ0bXSWfKfz62TcgZWYInX08WYy0LRoZDWVkSkvQ==","signatures":[{"sig":"MEUCIQDxOWJt3M89qaSAX0tn6ovEsz5ADzWKmsudnkkCLOHkfgIgKqh/EU2yQLdv16cvGdTZdiGZH2cqDkNS0tSPp554tBs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfXRjMCRA9TVsSAnZWagAA5c0P/1oGjmtLfPu07BefxT2q\npDhoETAGkKaAi+q9R75sxfTrCaR0dvjdkUQ5AA6hP3WoyKD1SxgvmJk6b8RX\nxepldWEdPv+WXUfNqi5HsFku5NFwtvs1Mo5dzS1sdiAYMTIBFawWoRN5O/2R\nWUsjZAFNISmiwI0JnL36bkoWhw0au+P7Gk/202fNbwGRtZcplwBbWui7n6ZM\nSvuznsrib012fhnforN6ENPHvzFGVuWl7eE2IZRhMyrU2Af+zeh0DbwQlIiw\nwNXoC67QoxfG3xnbDhQn0cVETpgaCOATMvv2OKeOet9id0Rr8R7Pqf5oimHI\nqKtZGjvGKkNExcd9h3N0ejQD8Z77k+lJlkuLQ6upMxwqTBjap0MwtYthr6eW\nHXV3Gs2ajGZUT8fc5No4ZRmsnP9N/v79yR7em7mvYYIeLEYZ6/ilt/jn6KgQ\nRAfYzxpKyDJHfEx9N1hBoqh54zxXqw1u2Q6bjtw1KbviNAkteVzFBkmDrt3y\nV06A3fCTRAT/hbSBI2qiZY1aNtHb0bp2nJvGUtq3pw6eY9jQQbyNSU5SecNb\nooGEhx6dUuOqUta5iGcgo9YND3pHIGj2UA78ABwMx1VFj4JbBStxf+oR+iVY\ne1R13KCGE5fzesb9UYr8mJblhpTDFeHENc83PNOLwe3wc6woFKJ7sxWzZP2D\nYl3k\r\n=QI5k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b38e87b09d777e0aee5f559af9b20acf65f3eb91","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d2d2065-1599936663488_1599936716108_0.917890709315603","host":"s3://npm-registry-packages"}},"1.1.1-canary-5bc165f-1600350589390":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-5bc165f-1600350589390","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-5bc165f-1600350589390","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5f4d0c2859a8981dd54a90dba3d65c0a98583b8e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-5bc165f-1600350589390.tgz","fileCount":8,"integrity":"sha512-rlA7AaS6Ptpw1etrRqr8owyf490n7jF5oNleBsrtBZIHCLkXkm49+aoFpFbBa679R7vNsHQbWgxwMk4YooRBEQ==","signatures":[{"sig":"MEUCIQCYiHUoko/oJP0uNmqzMKMrYTHP9wAeX74H47DsWklJ2gIgeC150c1AbW/XLivJWfesYMFiwWggzYqqBehqrTVdg4g=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfY2nACRA9TVsSAnZWagAAIzcP/RdT643pzcXifAdj5MLA\nacjrRxl1Fsn+F5/6QtSE1xe7cniyTgomjg2c90pO0BrG7A+ciEQHWUPKdqUH\n+BgTbDFnOxewE8zDM01UBdHHIPPQxcButUBi8k9VHJ2Ot/EHI5XObvPyyvXY\nNeQ4eyows0KhIkeP/8rm41pGV2C8zG3cVN7Of7j3RYcr1PYBXdrax8HtrWv2\noUq9+sqTpPKCCYiHxmfzgfNbmBtrRux/scd37ZWOYhPCp9lHsQkyiiKeh+qw\n4gH8BiBtDlJLfWuE0VIkv77E/G6ReI6SZB/RggpEL4xeTw1nOsCWu5JYaEp9\n7uzMiWyxHpZbb5KLeJP/t8n5haRL5HeRlX/dFxtuQ8lrH6p/+lNsc0KMeH82\nrPpi/MpSSqUARITBjtq4uz2ZrJPZ06WB6xR3FmMmxqPGCHVJmXB+iHhbCCjt\nKBlr/nswBLxff/LJ8ASl5FrlhSvVKz+uDdo746GLQRpAPyodxY6J64M2HFiK\na+YQ4cOksLKPYRed87Rlqb5dRmvKvV7DXtaqPaxBCz68gSHxemqHpFhkqd3A\nLQnqwqEt/d5mXwx6NkYxYqj/vjhLVjU7Vay4j2Ithdvkr3a69D6IGkwzyJKE\nNYLuXY/OtPm9BsoU88Eyp0iCZnuIEqt2KU2q+S5LYY4TyHt0Ybftc9MJpDZ0\n+w7B\r\n=atWR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b376aa2a41216bdae7ef5da8bfb14db7f85d3323","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-5bc165f-1600350589390_1600350655707_0.9957243774110796","host":"s3://npm-registry-packages"}},"1.1.1-canary-c26570b-1600526192934":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c26570b-1600526192934","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c26570b-1600526192934","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6ab47cabbde2548ed11c50b69bd9b944bf3a4b04","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c26570b-1600526192934.tgz","fileCount":8,"integrity":"sha512-URqeGj1FN1m76JCY5ha97QSxedV2ecy8XdC28MCdX3KTev02PH89XVKxBXMaJiVuTYxP+1hNs/mDlfsUawfgYQ==","signatures":[{"sig":"MEYCIQCsbnENoiTAxqUHLkjkpQRwdccPY7Ht0aA8Db/eRBRvuwIhAPECWuw36hfrE3sZjSQjIFe+xacCXWvlHAPoa5dXrM/m","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZhenCRA9TVsSAnZWagAAhZIP/0T4EQ7d0R2IIQ9pivDw\nJtDsIQSdUeAOfnAYDlo8ZfXRbFIAG1IvdJxu/4UQOIbsuHNBK5Jr5fg/qBMh\n2o0VbzyfJLvHHSRBiYNMtoWzQ8ou46I1dVKqQ2Jf+DrufiKSeotNCXsruX9B\nT7B62zEh70p3A5MALMfQUH3q+KmwfD38o3QG+V55INz0u8wxwSPW8Oe2iGHi\nUHQooOC7xjmOkE4GiTQaHf7oybNeWqXjpN5TAkjkM8pN45WYf2EXrtzlF9A9\n3MJrio7FaAXNYz9wcGROo3Vbh1g2r7V5crmy9/BhOM1Lyhvz6eo5SkEVhkoE\na1iARpQff+uYtyYZsIQ+wD9Ul+bN35KZKB4Ee222Dn87LC+5kQjwO0Udbyp9\nwH1H0BBt8k+hnRtqDRXygfr30TKH5bHcb76d9eZo3HAqvZ8kD+y0GL3mG+VF\njcrNnBe/dPuHhngtR2tXM4G9OKkqvh1yIFBPTU96Wj93endJYSH9sTQFW6Tw\nS5nISCZ/NEEetz4f3kFSHuqQ28/kHC9K0LwxgF+YEIA3exyyYBPne04g8Y+w\ndo44Q/UO7O+5ZoUdJYTJqCu2as+W/gtmiSevnLXUNPFpALjOSmGn35wluS4k\n93Kuyr7M004DihbPG1iX6FvHSDlFOqXuynAdyKdXWqcrrxSwIzzHyCK3eema\nqc39\r\n=3cLd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ef02bb09a4ed10948fe6bd4696a8db01b2563567","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c26570b-1600526192934_1600526246807_0.8523222178978602","host":"s3://npm-registry-packages"}},"1.1.1-canary-a485ced-1600599378560":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a485ced-1600599378560","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a485ced-1600599378560","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ffad375dc2af821c3e3f6b868c9f0e23fc20cf15","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a485ced-1600599378560.tgz","fileCount":8,"integrity":"sha512-qATIgLyDhpZJxV5xr996TBLiNnseQr/VYn81xQoRXbkmLcyb6i1BJE3fB4C94ie/nPAdta4nn2RQNr8ue9WTmQ==","signatures":[{"sig":"MEQCICxibhKhsNZ4YdRxtQ1ZQHKHThUwaEB/FL88lkxxvSzcAiB3hEyUiqy1E92UrI8XWvie0J8GaFGjZxlvn4pwTCQYVQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfZzWHCRA9TVsSAnZWagAAYMQP/0flIp5xqnSAtogiRN91\n/zmLXlup9C1c3zAMY3QtJaTF+JBgWQ6ErskaezwqiQg4P33FhpIRZe0ZcelI\nDxIKp/hVCAiJuPu4V+XpfpncipTltHghbpgEuE/nYhfopd+qCd8BDdiQTMSV\nwsvtT1CKHmsVx+NZrca7ikscctcoKqDV1VArL7dDS0NGDICUDy2Jfym74mfG\nWGd5q0V65JyGxEJ/xrOvm2VjBJjBS8PRi62zOIucd/ADF7oq2Yi5M9HXuVEG\n7JEz4SnheaIH452fycT7p2MaJFpMjA/jSx7F/wDeADsQn3DkAhfGut95Z/Ik\nZ1RcX0BOa+gVKvssgp81bHCqQpyPKGZxCNpotjlKRHki8N/1H5dsO5DUNm4S\nWKegBfdaSZYbWEjNXIa/MYczAZKcUat/Godv7G7R4HmrYVnkLhG5skCJHt7R\nBAcQN2J692+9qq97k2oYfEKqlzi3X95a/cLXxhszfCuN8X2lb4lSOiJ/9axW\nFDrQbfeEyCf9ge/5+TbdGUcotfF4i80E3R2BitbpLbHEpz+aWcN4ycThACam\nWj0kMDdpd5lWx4VbnhfvYC52ngFFoIHrJssAXYIaxGwkN8Bgg/4talVS1CxV\ns8hwstVJ1TLx52qh6tPXW//c+hs0yAbBH1pMH0ZIjL7YoIgvJyc8dI5MzmnC\npCGB\r\n=4OBA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f1bceb73f20d8db6ca20b50f47193d676a4459d1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a485ced-1600599378560_1600599430888_0.5507547815020521","host":"s3://npm-registry-packages"}},"1.1.1-canary-581d2eb-1600653941457":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-581d2eb-1600653941457","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-581d2eb-1600653941457","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"77c9739b7ff2e24f3c8f3df077cba4567da65292","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-581d2eb-1600653941457.tgz","fileCount":8,"integrity":"sha512-INygXntbXMfoR23VNBa/nshgT0CVkKrx9cXGsGWTyUH4ic1AsQNQKM+Cr34Voqb7VHYTrcV21ock8/dtJufaew==","signatures":[{"sig":"MEQCIH0Kd+OZ7nQ0jf7quA1aI/j2kUo1rLH1NkFpIdXbarB2AiBNxyKIIfaTGOOWN21tkCvnW8A1PfyzcivXOx4oOGC3Uw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaAqnCRA9TVsSAnZWagAAng4QAI412mHUBMsrawURMNbE\nDY49QLIqE79ifjPJPcY41MWhOWELvUjP23XVi0O4CxoOMZvwt0nf0YXFq4L4\no3ZtRDCgi8wE+13kZQXh+07ww5TVuftLMa7VUYM6z7pJH/7DFPA8uApqCy/8\nWRe12bIGuAdpfyp8rhmYBN5f0TPS7E+dsoeNCYz69Y5mx+v2uOQjZ7S8iqpg\nN2hWFnyR0U3E7ohdoq4mkcuo2SZNr9n96ha9q7lbpx9d/T8VC1hv1utMFu6D\nvkKB3tONHZr97+4Qhyz5XzN3u8d4gxWG1bOKcIrjvwjHXg9tjytTenDcShpw\nNvryFg0xrfx5640Xl5e7l002Ge4sj8wQLlmC9SdqVxU0O5zhVf4pgAU3rsMR\nWEOBQ76ha1vjwR/c+DqLYcpdAffof5tuskyghoKCcWHB1HNNP3hQ5cEvIoP+\n3NW0O7O4yyoS04WY+sWxg70i/saMHfaLPMHLKbX4BM3pSKcitkiHrzMNNy6R\n8MHArRfBgol512zgeLakZTQJyStrRXYUVzc83pS+PK83EBofkSUSZIMLoZJn\nAk06Fbx9y54RRCYhl3DOnAXbA4UNq52oEFby7VgWbfoNyOdq0s3//SHhXY7+\nzoY0CnVBtdNO4MS2YrzskQnTFWHmkbDfAHNgQQlxkO7eFxmGpR8nM6XvFnI8\nS+W0\r\n=lbv6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5dd415c3230ff62ce99b16e396af58b92db7b867","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.0","_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-typescript2":"^0.27.2","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-581d2eb-1600653941457_1600653990934_0.7726335919147496","host":"s3://npm-registry-packages"}},"1.1.1-canary-463482c-1601096460246":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-463482c-1601096460246","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-463482c-1601096460246","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c1cd42520a1df4d72b8ce6bce3d81129b8efef31","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-463482c-1601096460246.tgz","fileCount":8,"integrity":"sha512-rAlID2lwRotQhYWJVLpzxUno6h8oG+J7/hDRsTzumF+M63yajIgiOqXWq7XO5M9r5ILkzStebQw+Wo32a0/1Gg==","signatures":[{"sig":"MEUCIQCnUNsbEzO96E8BEQ7SKRUbhYzNrO2LC6EUifz8MXTCPQIgEQKZAjNRGkJ3E5Mpyp8N+iJ9ReLFlQQxBHMg7yFqv4I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbstECRA9TVsSAnZWagAAvosP/1i5PaWM3fA6qkLMBlLw\nnI9FcoUp5XsrzbPQPUa6+ow+ji5pcGBjM2PkDDWgmsDiejtF7WDHksmPHFBm\njjsgP0kIYytD88NVAgvwSHB1ZhbNscH3kHORVvc6q95ssWGYPOno5QSApBS0\no1/LWBmvPxPIzZegAaFv3dXMt6T9nreL2dkzAfqNyzuEWqI3NeMNke6VUnYA\n03GBXY/iiCwMXzebVbpnI4i3LTNjsGUl61TRcOrxKqRGJ3eboH1QFE2hipBv\ncXb24IkoPs3hc8h1KICinEZUxo9Ux6sJ4F/xHLn9Qn/l5K0RmgEapOvsfpvg\nX+nuqV9csope4EJDDOErPDfplzoPfO2RaksTw2UqGz0uD8t/To/rMLgFEB5E\nR/Cx2cR4kYiIa8BSVlNkNUIbu3d7RWwUhk6JxQYvKm9o/zVP8eEaHDbmiB6J\nwHNSVeaYIiX68H2hb1B+l9JYPGHtQZjClEdcwQUl3718hu5/GWygRD9DDsDK\nWmqblFDZByCmWPdyCnsCHun4gUi/rMk9g8GFlBBXyiuhFz3byVlmJ6VYIVVd\npaJkJ0R3tlNmpWJb6HQm+eTIRwMdx2lTGl5UrypjxEGTLAsQnVtVAjnAXgfO\nHhDrFNuEjzDepwMWu06cZiPwfE2qn5wby3dv9J8SJCWr8RVUYX37fYUvuX4w\nwtnr\r\n=pV8I\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2b07d2e87b4bd502b43abcf06ddb3c76ecfb1897","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-463482c-1601096460246_1601096516209_0.8075435195998291","host":"s3://npm-registry-packages"}},"1.1.1-canary-367c1df-1601158677167":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-367c1df-1601158677167","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-367c1df-1601158677167","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"cc0d40988400570db4f74722e34b762042eee89a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-367c1df-1601158677167.tgz","fileCount":8,"integrity":"sha512-ik7BOcg4jqhNCov1d/kBQxbZKbgI/OwRnLsu4oEgSXyDX5BELrtxrLFCc+NbAmci6apjE/yg44noSYfoOc9iKA==","signatures":[{"sig":"MEUCIQDHldXP7t5+r/fM8Zax/nY6EOWWoPegoUenYVcMSPd1uQIgfsrVe5biKQdHJg/2m9pIP7MPuckSg7f/bkq6eADu1X4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfb75LCRA9TVsSAnZWagAAMB8P/Rr7sxxNoX5qCGg4gXu2\nOgT+BDUcZ8dslUZd3r95cEV8SpX+FszOhRRAgJ8JqW4dwH0tXSeV+3VKJWxE\nUUoqsXuf95Mx9u3tvlzqCkXvoH+QnEySu9jfdYYdkmMoVQB2GetqyumUkoms\nuEOveEMM3+UIpEE4mW/3hIHt6utXnFMEoqcUjmuonenJ78StHFiD2BKRAy1M\nD3GYkcIVFulkW8f+Imz2PQMaoZ50oekGwTOQbt10HAQaglK1LCYxTsb/aHDJ\nPN+0HaUAhe/uyMo2kjyIY2gah5QzGJMddq9malb1Z235l5JQNyFWQt9/JA3n\nLAky5LQ5ZTGcpV0rrSFkg+zOutNU4/q/hBT6VIxRU+66BmKnADxoltzssucK\nnb8oHIIxC7jSs2DO7mbaRrToVkIr87Eg/OINwqmY9hPtAJ7InTpaITpCUsyC\nWjVmW0NJI522ZlU4JhYwUJs1hWP8Nhoymvvjw0CTHJOctvlAGeOLKgxsZQoE\nimypEPOQY8Dhp5mCF2Z9hCNTekCc7ytZvAbXG37VoTiHjSohr0jLAblyBoF8\nd1bI0mP26Kb3uDd5AG9jRq5f1YS7Ky0gGDyx8dN4KMHwUbTpY1JIg7MM0w8c\njJ5pjFdheX7kt41ysZfWKICAiVrz4ilLkr20D4TuiYv/Wl0tR+BG+6jTAYe+\n8TA3\r\n=JOT/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d4910a57e6035418de06742591c951c22359f590","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-367c1df-1601158677167_1601158731106_0.8913519870100002","host":"s3://npm-registry-packages"}},"1.1.1-canary-72f737a-1601460787398":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-72f737a-1601460787398","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-72f737a-1601460787398","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f179e2401a18cef35cc6a9c60652dbdb59df5bcd","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-72f737a-1601460787398.tgz","fileCount":8,"integrity":"sha512-XoxoH4S7X9FNqc+l3CrVq1ARkxRdw/Thmc85P+28x+W2j9Od7kyva74SeRONsNX1w8OM+XWp/1emv2/n6icZyg==","signatures":[{"sig":"MEUCIQDn4ikYtbUkJ9rpTDToxz1qBd0RipkePUFIWGaPEsbqpgIgBTRv7nRIhgMR8VJR3peXOErOzz2wjMhZgiipPggRkwg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfdFpzCRA9TVsSAnZWagAAF2EP/jU9LechTZ5CIWwxbjPJ\n/CkPKwYqQobIOEjlTSmc+l0z8o8ZQ9xFjtsY2ieUZQp+0dHE0V3+cy+79URT\nAOw/M1qGqhPhReqHNoYFn28WA7VruhCeXAcDqHUD/bdHXA1tJ+pLTsB7kXFV\nMAOD6E88mngzst0A+IlqCTGFgHLO3gMBDzIbDQLS+AGi1oNIfl+iXk2j3BS8\n3CM60HAGIiwZFkk4qnSYQ1Umv7L65y6vF9H9IgIdc3Lx9KV1mz0IDqiUYA6S\nkqH85hpsFtWe9N4HM7c+yHJdj4tjAN0dFPtl1ke6gbk2ct02B+UAiwU1lC8n\nX3kW6qONqnSBR5kEEfcgdgeSHgQ25ZZcGEQOPIl3SynYexpWtTF2jvNVlxpg\nw2HHV6c0W+QzuuJP31LgPPEauVLiDNKcAvGWIJbTBK1q1HdOovjDPehf1/bs\nIvGtnppMjNhbrFTj7vkZAfbtYrpks09uIkU5xP2sonC+2wIZUeRJpmjJDa2l\nveo2xGOAENEkUR4yNBifA3pj/l7ODs8PgHKBx+HPRtT/FQ6DOJu3z9vd57Z3\nMiGzJKpbLMMJ/dDyFXlhV2RU7T1k1Yjt/BBom96TQnjDdIlGY3RaZaVP5z5c\nQHI6QKWYJZTkRsaZWwAJn/G2Hssq7IhioZPKzxqcdjIoIcGYteV6x3WOz+jU\ne1OE\r\n=pUJd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"49c3343d812a58ac7d1dcb6217b17126b54dbeac","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-72f737a-1601460787398_1601460851548_0.3300075931354771","host":"s3://npm-registry-packages"}},"1.1.1-canary-c2b6182-1601950934300":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c2b6182-1601950934300","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c2b6182-1601950934300","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7dfa04ac9f36bc2170574488f378c6241e47a71d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c2b6182-1601950934300.tgz","fileCount":8,"integrity":"sha512-VIZLGGUwSh2/37rQ/LsmUVfVvDS/ObBL1s5ZBivnkq3vj51Z94gZKMWTTHTvk0ZIkhoP973RAZANmSgHQz7Agw==","signatures":[{"sig":"MEUCIHTtPqwk9xfdLhn8lnotBbMfliwaKx7JQM91pXQRvsqYAiEA8cHRyjDZaUBpI0WGlbidUOQHIXYIFd5H5YhhhJV47z0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfe9UJCRA9TVsSAnZWagAAt3QP/2zvjTv17kcbv5bSkZ8Y\nYEco629EqUhBPqBI0ts2oy/zl227mxxT51RgeKTpUpv6LheybTfgJgBl/R7P\nYuEQZhwuazykWVH4tOZ3F3KKiVyt109OqyduKtmgiR20z7TUwr53YU5I+Agy\nSpTFO4iRfBCZTS5TE6yTM0Q9NjVj5mm1Rs7j/4sGil/k+JY+XWuORUoNHC99\n+hvT3WajEcPCdZQ/ELoR8SFzPbfovQ7hToCxT/1PO+mIIwrwWeDblAuXLXwz\nU6vCoedWfgy5g/uYRaLm+8aVm1D337POe49bWDnMtxEE1981k0UQvbKcrxIz\nNO7YpNuKbF2OyJCZAAUm/ywcVzOMmI2KN7Ag2BiELUeOiKPr6G8lBUKdNOi/\niCE2raHEgxJ5Fe/K/GqaXn8b5auu/2nplsRFB6Zi/UEjfIWZ37S96hiIfs+5\nI/wSKrSMfE7dZfPuKopy2B9Bbon4TdE6fTtlhkf+e2lvAuMnMib+Mip9HaqR\ndjHDPcrr6wCoS/ffanGTVy0VawkRZaz9IQX8/xlB9AEoyPSZzcI3Yv53r9fW\ni/OHnJ0puJy4YB2x4ivQLhJhEs9Z1k5f+TKA1K/OVYyvx3cP2Ht5T0ocGQKa\nnoBfoyKFcAxFcLII5xPfLNRAm1qLaphApuTskyKLhwmBm4oZnj1mA+kcDqDQ\nLIsD\r\n=txV6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f28049f70581d20fc7c3accfe6cdb5e69df5abd3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c2b6182-1601950934300_1601950984983_0.98581136584949","host":"s3://npm-registry-packages"}},"1.1.1-canary-717db69-1602085514502":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-717db69-1602085514502","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-717db69-1602085514502","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a0aa4cf19591815c08b09bba336ac6fbb8b130f1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-717db69-1602085514502.tgz","fileCount":8,"integrity":"sha512-jGcxLQandy6BDKmAMnTGZPxJSO3HcZAZkSh3x7LMpqYf09LR52SSI3BjDKHgdds2kXLiQZ/+kWqjgPQVaJ7Ufg==","signatures":[{"sig":"MEUCIQDEn9lcpoGRy2vg5y3eteSmpZF9OKPMiRny84TF7k5PZwIgUUQcQToaJgIKF0jMJYH2lmqAmmVQe8Mj5B+pW6MyYBk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffeLGCRA9TVsSAnZWagAAdgUQAJ5KsNg5f9kFfIsIx6m9\nz1CEh6ovkz3Id30YcDhX72DUtRPVrbLAiQ8Rlr31/uAneQyvgjP53M/33cxA\n/hR+5WfBdROpdnITvvkOqlVSoD1walwM5+01ct5BumSjSgrqXtu4CtkTuLcy\nK+cc7/enMQVkrroeTaXWUdKor/r1DLc6xK7UBGfbSA4OH88Hw/jlgpeN6BOt\nveznQaMxwChMFyiZ5RGe2ydLK3MA+NGIx2ct4WgVfbWzLr+v6EaqkSq4rn8u\nXnWX+rfvC+jZgxuxf6r9oDB5i7QIITjQZUvxGHLsF5Njqhx13/jKlO0PNFa0\nADJGY6BlHYHxdGJehmIJkX08wEA4g3Wo3mH6d0kLTL7zjW3GhfCZIjlKbiB8\nql4NHyNJzpk8boKFZ+3bqNs5YPuM79ICy+Wunn+aosHly3U5KSlkPg54+ivf\n6LYhSEavX4MvlSL382mf3OAyfgfZrUql+gIAqEodN/jhcO3CJslqkDTX8IXs\n/NKLNngNMkU5iKNB+kO7y4dzwEyEdaP1YdaUj86V0VifZcyHKzC/pwWNj1QP\n2ZfpKrQShJxRlivkZSXvxAptJBKEwxBpJHgmS4gTO21IwYaR8WNEhWd/zZ6Y\nqZWzts5T6LbDlcQ6n0WEpxsiH/+Zlfd8eB5e7YxiaKD3hRF+RBBtQrRlG/BP\nsFjD\r\n=mVFr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f6da5648acf809224230d876b490303d6309855c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-717db69-1602085514502_1602085573789_0.18458614713248034","host":"s3://npm-registry-packages"}},"1.1.1-canary-566bb76-1602101761936":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-566bb76-1602101761936","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-566bb76-1602101761936","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e4e38a8b2f2dc81a0c37d5c947f7ae3864e8a68e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-566bb76-1602101761936.tgz","fileCount":8,"integrity":"sha512-F28EZDqs+nFAD+7yh2NppPhNsweUnS9Du13BtgOZXMSWedybjd7XnlZVF0vkkbDV2SDZlffBdBMqVNIpfoeYUw==","signatures":[{"sig":"MEUCIQCZsaNmeIXzdmpA0ob8k60uGQOmoB/Gl2t4XJwkOpF/owIgdxmCO0gWbmZ/4X3UeMvu8pYCdGYw+GUb5lnhWShGapk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffiIzCRA9TVsSAnZWagAAh9wP/RRtIHQX8AMqnm4YETNt\n2Bjo/YTB/ADb0fKpAdBGZeDGzCQY2Y+5kLPTyLC4WUn5xA1tz94xVJdcfZL4\nwVMDHnP0+MBm7gkFNZlOmG595MKQIgwi1439WSo6VS6RlMxnpF5HlRCNabhg\njme/Q3au7jO9SBPtR4jIpJ/kDWPwWWn5JUhZiIR3t3c2fsjsDkHOMytp7h7U\n7aHjr3I7hgOpe39K5x7Q00rINHBnQXj07Ns2YwknHmzKv4mEaErOexlLn4MB\nseYaz2nyO+wueoo1fnpvMntDFke5ECjmTwiMCC9X+af6O9INkyvRlVGGKOT4\n5+4TzMBfU1mMqzE7jd4jRmizrGDByJehw6zf7ikr5uI2euEXEajvQXXBPTEQ\nVzp/BZ2kObvZRbFMGMw/X2SalYuilZhSh56LzISul2N1sBMcPEgvWwjrbFrW\nh+CPMO2j3kIJHaZyLQtFzaVER0S4zclU4zan4A8hxKRIjqdYUEhGv1goQdqu\na1x5j1NLVQT0G1BMDnwg33O3PwC88xSUbyfb9zaBhDRWsFXLwV0B/V2uaYbE\nkIJsudLbLY8logof+w0vsGteT5GnPwVJp2/rLxeKPE6XA6l6h2xVf+4QxQg4\nAhFg6eQ/H4h/HMIpfUQlWM40XDJaH1J1EsbIhqaOhw6nNIprzm5y5RdgDzHP\nhY9W\r\n=daj5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9cfe7e9fcc3cfafaf644b41bf94e7ec12a9c28be","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-566bb76-1602101761936_1602101811513_0.9473825848319404","host":"s3://npm-registry-packages"}},"1.1.1-canary-a1076f1-1602243255147":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a1076f1-1602243255147","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a1076f1-1602243255147","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2afedd24f5d0b4ca3f6a7126d059a5cadc050a90","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a1076f1-1602243255147.tgz","fileCount":8,"integrity":"sha512-qBlQ1nVQDtNUmizaUgPPeSwZKrAsPV/eRnOBP6F4kzyeRFNK675A6v6g6gNCPbgnjSWSlM1XZ0RQlLZUOWoi/Q==","signatures":[{"sig":"MEUCIBrlO52J+DYNcTeG/Eq9G8xegkj9H2rYq5P6XXqKElJLAiEAqgdsfqEGKUsF4xUnMbQR+WpiLps7dlxzCpCVqnQef+8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgEr4CRA9TVsSAnZWagAAh6kP/j0RwQ4Yjyef99PFqdYX\n5/iZhW/bysbcZLA/VorKZS0pqiifp8Akmx06asyEFHa/wvc+DKEdcbN7ih+E\nprny8V7ouB39CVxzSmxPOqi4qSkSqCr4k1FgZnxxU8sZgkmY9b5Vb5yOvECZ\ngB8q07VYYN6CX2UCzgRzVn16sqLGu84Hp4RapEmoYnS8H4iisI4J6xbM7dp8\nuFyDQlCkFLxZ19cFJekF3eMWCajyw7RwVDOcbIisTTfXLVgEK6qFtV+Z9Fzg\nZi3civZCa5cqBWSr4q/+Qf2V42+5tL5LO9DTQ8Bsd/qj3doRgRosGcnMEwMZ\n5fdqrxM9CnFM4++roMOJtIpdQ3UB7xYVmC/vN2TH64ZPcpc8JTc7Xilnab8L\nugDS1so1BvF++emGSHPUWYnd5cVt4JypekOg7N1jcd2vpoR0bXwdt72+jZG2\nv+ajWJKlAk4eIz137y+GFGUYUhgfq5zAFP8eF60wyD/0w10ZvO7uYsREY7P7\nCCsNoSekIZjSwlBCLNm65Pxy5d79rqQNBnQA+Vqs2zP06UgygDLYXZym1z90\n/1M8lGKnxGvRLAI/Kz2kSlZDPfMHCMASMqzXlgHT/2yhKoYRmkf8AmFqIwH3\n57HYckpJr1iGTl2Mnx4I0SqOFnGt8xa+htOPbXYnWzpKEFVpXZQRcbWtwR6+\nKYc5\r\n=V8Z8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2bdebc7f89dee1ec7644c7baca92380a6d3bc8d0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a1076f1-1602243255147_1602243320424_0.0727224776577704","host":"s3://npm-registry-packages"}},"1.1.1-canary-9a45251-1602417604212":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9a45251-1602417604212","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9a45251-1602417604212","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"475868577532d063e753a8e8d6777aa681564d50","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9a45251-1602417604212.tgz","fileCount":8,"integrity":"sha512-PbALMKb4u/PKNB0DOxJT41TqXP4bXG68pU2AcOrvO7dGTi2s5rfpGDxyxzmPdexAvlhNh7Ef/mnQ1TY5/d06HA==","signatures":[{"sig":"MEYCIQCzo9Iy2CFIFmw34kWse6F9sU04gYbI8NNcPkGyM6aLfgIhAL34+USIXBy4/j05AAu/yifGqiO0Sw+utJT4sHz9ibmc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgvQGCRA9TVsSAnZWagAA6JUP/RSTP1UE/9HSeOigrV82\naIM5sr4Ek+B0GU+4Psayp9YJTttvZX/caV2JlyB8erJjYNrlRW0rjdtkadTd\n0ZjJ5TwLGfsAd3KIUN48CjZt8qLf6A2Odj2RSTX9jXOzfm7dZr7kFoUBkXn7\nkMCb/PZMErE5VDa//HryGXl6ksLNyg1krTDiYa7/LyoCVK+OXe4mxL2+/NEH\nIC7KJlgCslBPsd2RDFMAZXQsbuuBfQu66ELxr4kXNrqIz98ib45C2YG62c5/\nBE8FECkoTGhutGu0g6569QNv7aaXtfAUtEIND6j4eCB0SXk8B9Epqg8oslsj\nA+j7eF2glAxMI52miSuwnI+s7O5wTGWUFcQs6Uro7KVncy0aHe1hxH+zACmb\n0Ig6l5GlGBTA7aZVH0YSrqRDTi6ZOEDUn+jhZFjoqNJqfg7pf7nwanOY3L0v\niyE0ZaeWMfINVZOSbT483Vx2Bs2cjHxKWu2rIm1JGol6ZVD0PIY4s47T7OI0\n2erVxYRQzUg7tJq23y43eOVwOkR5OZYhFVDNLYAoMSmX3DCbwTjUAOx4NSwI\nEvJPlGwaP35R4L8dq7+Nk4hesYa7MKy5Q3GC4t0HUr/LdA3sTcormwelBgkA\nIqiQ+LOHh4nZdXUavXGLtwnDXUtE/CsZTZniUIJ/vN2AwjtyQeasRaTzjBss\nwqey\r\n=CnoI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a153d8e6592791affc7d95ac05e62ad4e9fcfcfa","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9a45251-1602417604212_1602417669498_0.13239726831076282","host":"s3://npm-registry-packages"}},"1.1.1-canary-9bf30f9-1602424126921":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9bf30f9-1602424126921","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9bf30f9-1602424126921","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c3bc5ab8b194e0ff471a2574266724ad0c418ebc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9bf30f9-1602424126921.tgz","fileCount":8,"integrity":"sha512-+Zoh44HHzkRDowsz9WOsU/88ml/U0oNrGG0pxbZ62Qsra6k7iy6SZebSMr2zVgw+p2LGEy/f9q31bhdTuMWq9Q==","signatures":[{"sig":"MEUCIA88WuQA8jRoppCc5kN6aal1JeybtITpMkRV5JSrCK/VAiEA6WgCeSCxxwrJcpklUNuYb1W7CB8DeLTuAakdCeF+oYg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfgw16CRA9TVsSAnZWagAAR8IP/jJyHgk30jzi80KFga7R\nSlKCGfArhHNt1xwfBoixXrY+ctaaCjQ5854RXyhWxW8XHBWYHjdYuZTLNvec\ns/m1L77xkiqJEjUP4yWRcsjLGTDG+W2CAtokIuxtDezb072Wweh69BcECcsm\nCavd/huKJUPeHx4RTuvn6w1vRe50ecncUDePGsqgiLbflfG6aLwFd/LrSkyS\npI0cgbCMwP/nIe3vNcbG0ZsD7dqthGFG7S0S3mwhXsPJJn1Uf8Log9VWv4qt\nMJ04oxdeZpiUFWbx7K//4tOtFlgk3yQDPTeg8c9oJAcaiLO6x8qqzIZxZfky\nX5gwutrVO4t9r3wLzBjIruQQu+i/+DF2vbRj++lHEquSk83WKDwK/9w7x2Ao\nMpNnfv9nEF768h9O+0cjcEZRC5wQO95ypZRjGpwxRPS2r0X0PVUWfHISsxam\nqc0dCJhiPuYEtdbg3hFDPCvCR53mR7AODpTJ9GinBD8mf+HKuo4u9zbyAA0C\nzsuVAcLQXh8jBe0+dwAsT8DIwL81laZzpZjPt+SQxjyasVOB61+0z5r1r35o\nsNZjotXmTKJoRQfwNoiJfN0dhkt1j/JRcP9fARhw+17mub3hpaT8lBRjDPyN\nEjj48u5K4nGb6HxdWBY6zwPpt0i7bmfKNMAokccDixpbmLhLO6AaLFZr+Dl8\nunSd\r\n=+WT6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f5a1758c67b5ffd1955c6b22e6af65a67c9eb98d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9bf30f9-1602424126921_1602424185771_0.1350884259513252","host":"s3://npm-registry-packages"}},"1.1.1-canary-3e06e5c-1602439546186":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3e06e5c-1602439546186","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3e06e5c-1602439546186","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6693262827242d924447b4f3e1a65751c2cb3b06","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3e06e5c-1602439546186.tgz","fileCount":8,"integrity":"sha512-hX/nWLRYWLjzwx3Xkisj4kb/Uxlr8uK/XmXKdpo03mSeQv9zzZXlUAFBnos5RdzD8s2E4xwyL09cSZglKdiDQg==","signatures":[{"sig":"MEUCIQCzDx7ee+uxJkPHTMr8uUAs4sdt9PkpW+8mhTYQYKJ1FwIgGbN9GZ8aI8aNG7/3NeaMFmPq4Kt8OVQDLiSoOGqLRpc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfg0mxCRA9TVsSAnZWagAA4X8P/24FhNGJ3/4IxOXwPm3X\nqoY+tRN/i9ueZoaFtsgKj0o0FxcBlnUhlgEJAExrp7j5Aain+K4qfhFQGZ55\n8CSlO/brYkpfIeyonwqee7JHXqnv/gmTq7Hpg4/zhEvOeQ+eINT4nIn/OTc7\n7K3gTBnFqytkvGAX+v/YpxqHF5jh+gYEu2HO2rqzTSvYj0tXQ6YXHtrI0GXZ\naCwd7E7+VGB8d/fQQSjpeIpy/+x/bdB2JlqBY64BU3ze9C76aTPsVGeV7x4B\nzn7iv60Zsab9PFd1bECm73H8ZUHLwIFaLoJedWcO/q2+78YklJMpmHQ9tmsv\nJxPVCssmvkq2oV6hqHvV0p3YIaKYq5PW/4A2g7baSRDbAzjr2QhBXNT3J9Jd\nZBQWmK3NL39cu2c+9qKbjhgQJMCe+o6Ju5DoCOfb+7rdQWjSSrP+uJ6BYyfw\n6ueYJ934VtBrtXBMqVK5WVpf2gypMtXnLPMpg8uWiaZqV9j4PKIjitjHAwo3\n3KgNzmACMAUbepLpcg4OXhXrC6Q5GGF+A2MdoDjcctmLgn4s6e/sXs3nPrLN\nWvqWifYb5/Yf4n08QOQqYFVgXcm0nTQn3b4/bWiuBvykyUQ++YcG0cdh3kkt\nU1e2Ric9zvZlf8IAHhaq3aJUCZRXDOvQaeLh0sO+XrV1QK7PnJcdnxJYcI6u\nicKm\r\n=x+wh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5dc5b3e9b98b7882537c1e8671935d89fdd2eb6c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3e06e5c-1602439546186_1602439600981_0.15372936208692667","host":"s3://npm-registry-packages"}},"1.1.1-canary-0139810-1602694620675":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0139810-1602694620675","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0139810-1602694620675","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7f1c57d357941ea045a9e86f53d6cb8c414b544f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0139810-1602694620675.tgz","fileCount":8,"integrity":"sha512-P3b9aIxmPMeM9rkxhlG2K0p1mZuoDuTe1i+4y865OnZ/vgPCgEPzDh4mKMOOQy+c6xHYzuSk8w1Wj6b2tg+tyQ==","signatures":[{"sig":"MEYCIQCtpxzWKq/CqrIugCrwvAP9sBnTUv4zzxvva+Rm3phX1gIhAPjheDQ+rWUowmzwrYDJLD/7iaBAgJei8LSRlXsB36ED","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfhy4cCRA9TVsSAnZWagAABQMP/iu9DSwkyTHU4qSoAmgZ\nhdCrerMq+tQRjMueFZL59nB8VlejPiCWXh4/ind/GOHO8Tgjr0s7PWcIv++P\nAlZeSMj7iL1oqEJYiCGqNlrz60W6X7maBYPiL+/gzjKvuwq2M8m1yFO7B6L0\nA/fXHSfeskNkkCkQXaX7XTttrm8g7wa3IIIcDF11EgZA2VEOPtDwwPqlH3gU\nj47+Hk8SOUjEFvMJStW4ovZ+gXJ9rvOPEKWyW3JIOwDWmFL6/zkx8WZILVto\nDhu3dzJgyeunPtIgrsyCUErDrNA44UuWc/ZiGCij5d8+aDeuJr1ZzUKXBZ7l\n04Xgc4+Bdliduc6eacTdPw+HbeqKRFpAbY6KPMtJAf4plQCcIDlBlpac9DCV\nrJQnfdOuqzIbtTZ0MHSDeB9fu7vsZHrRwG4qJE3+aGPIs7pEbQYVkZkIpSbh\nNQ60aHAAm9LjWkpWdj2M89EhVfVRR10XQXzit/2JTvnP9AEHnynGcSbKB26S\nUDkfyQjKzUm43K+QdK5b57jTC0VeRdgu/pnpnruLFZMddUvNbyEZHhAGQ/ew\nsjGvCaS5Ezus8AYw5jCMlJmS1dQF58GBXcJrt0ZxuvyUBRwrdP+W/VJYNTDM\nkZQ1yMMD7RuovZHzLRHi9INwfmyRhF4YTq2NgFupRoL6wZyojFlG/c0WTbpI\nN4IM\r\n=HIB0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"df45f3bd081d97cffdc21364389cc91b278ca953","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.0.0","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0139810-1602694620675_1602694683682_0.6440555154353089","host":"s3://npm-registry-packages"}},"1.1.1-canary-775b394-1602796683028":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-775b394-1602796683028","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-775b394-1602796683028","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"db1f9ec0ee26d76c261397240d457d1e3e6d846e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-775b394-1602796683028.tgz","fileCount":8,"integrity":"sha512-yFC5aelIsVsc41YP3koXN+VWOvqBknn4ahojbBEbx9PxWuxgDBg3T7dvVJKHUn2t1yo8WzJuGu0sd2CSl2D3fA==","signatures":[{"sig":"MEUCIC9dXFJfMsFV57mBvpOj52+8JW00TNzknzsSscZULa4aAiEA2AUw9ZwD3YqmomeFRUJtq7nsqLT7K//SYD358+ypz5k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiLy+CRA9TVsSAnZWagAA9F4P/RR8QhIdv1IoxEkbafNE\no5/qtKnhkphyDFU4IMpWnPRHyS3Uyz709u6VryTzuoC74lEKFkvEsp0hnDsn\nFmlz0fSl0uwsbKrWccbDx/vCoQoVEJoIPstGFZRtK8Uz4OTL3r9rb2HCUMlB\n0bISBmzLuajp2mNI17LgsgGLPqkjP/OCX6UG+ZycXAR4Spl7/bITrabEy7NX\ntq2orPiTonEAh2Tgc6jfOXg41ebipmzXvSzOmzWerVXkX3r44do1HSrkdifn\n6oCKqYD2i5T3uIloSdSrfw58rjUy9sgGU94/2ur0JB8M/3KR/+H0StB3opTb\neAFBWZWIu4uJg6mfxHB0ygjKcJj0WScDb5+JTB8Qz43BAXEKDIRy2pgo9Q6D\ng0FlGenpk1LewjktB3TN0xYOYKt9nTQuM6QAb2LGXATgozb1xNj/DrPp8WYX\nyBeyDJuLupuYcyw7Dsx2HqjIUJODpe0DmUYfd+av/pDo7xLilbErL/psWPol\nxat4O6PwHuxjARQTXRlTKir77+xMPQQ53iCCoB4FmBh8SfQ+w18cBz6y5SJc\n/Qd1sbdkXsf7kFNrbOCWJSnkRa6Q9oFz476TKc/SKiAzdA2VYMHgXoH4dKtR\nsRNMzvED8YMIjqdJ5UgA1IgGY7OQvH0Ar2gIBkhmYE9DKRA7IwsV/ej/eeem\nHwNS\r\n=Z4el\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"acb301438f4a0ca1555dbe729068dbceae3655c8","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-775b394-1602796683028_1602796734201_0.3805152093377353","host":"s3://npm-registry-packages"}},"1.1.1-canary-3f79eea-1602798093608":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3f79eea-1602798093608","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3f79eea-1602798093608","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"295f9e81c3fbe305df6a1c2fe251240b55753bb3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3f79eea-1602798093608.tgz","fileCount":8,"integrity":"sha512-qzPNKFURJQigWxcgM72Zp2dMl3AfCh28EdcJn40Lce7OBnNEOp49i6gGMIUB4ExUxXuU21GschBxtDnrD77G3w==","signatures":[{"sig":"MEUCIGLl5WYp7a++gxJCj2gblAfrgZw1ahjTFGE9S6I5intIAiEAo9bcmLYb2dQxndlWkXwHnGdGI2gQ5TVtUf4+spcC4MY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfiMJGCRA9TVsSAnZWagAAUUwP/3nqK5WwtSWpbQ4cq3bO\nanNwM7LnNhvtsluodnjmIQDoguJ6z1e01dId14XoAIrnp1qAaxm8ob1Ypjxu\nTEbsm7Qr0YhsluDp4vxpuVWmCuFNCwGKG4p6AuAyNh8BDriS3vMgwyB4cE1n\nXn05f0r9kJXppns9RDVRIcv7R/opR+vR8BFDp+CsEXAXK817p7oZ4MuwmGxH\nyTaFW/QY553W/F863+JyU3lhCke+g3uJSwfUVTq+1t/frHUv3rKgSoIWqEl1\nrfKqYe5TAtu5ISJq/e1BYxucKs3gqbQxtnd2Cl/q3dVg096Sw+3naneScVLj\nTfRikwNPiDWVUFu+5o7RlwHYsnlntQ9YqWITihRFuwhjmf0Dmg+A+TzM2PAk\nLQPMZip41gQaCm6UBeEHwaDMLM+x8xrGaVzNYnlIPKPbE/oZcT2KeQQu5frZ\n4nz21PRGVLTTXnTyTcb8dMwW/xyQuE4e97LbZTQoDbsgg5RjwU6KGggca5p4\n6T0KkRh6pxY0/4aG2uh/uZwSNMqBEDoDP/h0fzjcJcJN385V85HrAUm1vEMY\nLpFZD89Qho7qixv1GZ2GIwVgCLCVyeHkglPWaJklpCUuoMpbmfX3NjtPIVKC\nf59C+wgQPnVNCCFaUhTvA/UQ2ahNEvgPgu37DTVejyh8gZuQILkXjAnVblgi\nM+KA\r\n=txpv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"931936d5c6a506f4f7852aa83083cf300eda7101","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3f79eea-1602798093608_1602798150406_0.23774362119396764","host":"s3://npm-registry-packages"}},"1.1.1-canary-9e16b46-1602916777734":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9e16b46-1602916777734","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9e16b46-1602916777734","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1bb8e155b788fe536076dd86952c4eb70ec8f428","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9e16b46-1602916777734.tgz","fileCount":8,"integrity":"sha512-2HMDSvpE83GRy6oBUWcRF7cUMyCErNKgoYeoP/8Um2/wxK/uy/XJzRBnqpJ/vFkadqq3DeA3z+Ozu0bQwlTKvg==","signatures":[{"sig":"MEQCIHI+NxCXbob3Kxo8V/vEAmn5no92XYYMZ9bQb4OQvEWsAiBTrnMM9EhpFgjABA3bRZje1h+ULge0scGG/Dml4OuPGg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfipHkCRA9TVsSAnZWagAAKFgP/1X5ftmw8dmLMNU7mTBB\nRLoOM6UavaFw3vqETmZg+WUOk/UeEdfhNQiz1tyC/mntqAGLK3rrLOOqm5Fq\n2MVEKEmOz6leKiHIemFbrTVx0Y2iErA4L/CON56flN5WaD+UhKG6NTqi0ZpF\n75JSZBt35A1XqZlyvkzRH+XqsOTS4Lm/n0QMZrTRyBpg3SSkEN8p1alBBAN2\n9RJY9wy0UFn09TS1/A9NqhA6GW0dCT3cUCULF+FmjSe93P0k7rdw73I9pj8Q\nH2P+UTTStlW70TiVTkMN+KSmQN1lmMhtiqia0s+TYKTRtMSnjVt2LXbQCebp\nUrY0SBA6cvJAcXMt0uILq57jSlQwlStnTJMXIx4XkwSWXKml7a8N5TM1iWW8\n86GejLwkO80ZO3HTtGYgN7Ht9z2ZR0rfAbhEsLXjr5qeyi+rhiL1us3+8zDd\nBQr6n8l3/ezxGEEqB7CumooV3nSTEoSdifPnYRH6GVjfePWnySQOXabAdPit\nQKzsvpPFMMvtn4549gOvJssTmn+PpFTh8OOZaYXbhWFSYWm23bvfOlvFT1M0\nlSrvsFrb8njMiEvngYaT07iQiyuLTrz5xtFbDTKVPOosOvyjgXU6R3fcI7nk\nH/hLLb9fjz4lO+ldm+BALB9h1GGMCrwtm/xF3rM+Q0tBJCdbE5jYJfr3JHV4\nvF3h\r\n=JzmV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8f2b1f32e1cf592536f967d617db1f8335cd1787","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.27.3","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9e16b46-1602916777734_1602916835852_0.6778363396224787","host":"s3://npm-registry-packages"}},"1.1.1-canary-552fedd-1603031024483":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-552fedd-1603031024483","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-552fedd-1603031024483","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"627e5f711ebbb95bc4e6d15b90a97970459df46d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-552fedd-1603031024483.tgz","fileCount":8,"integrity":"sha512-3qo2Ss3lhBx3lnGIBCZYFKWpUq49FZ5BNPklkG7WAkLQ0S6T5t7Gx7pzU4XhxJKfCOOJhR3WVHNMFxsByWK34w==","signatures":[{"sig":"MEQCICAq8CTnxGjCNibjJD94Lb9ZITN8fnVwIYW9llgzi/yuAiBOtCwZLB1joUiyOfLgzaA2Jh3pAQdstEUG0AhsoV8ahg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjFAgCRA9TVsSAnZWagAAi68P/jtlIzHR9isdXq8NcRzF\nwgczwbEhgPli7q2wMRjLk6Tr14gNyJ9aZpu42JcjBE4jHCJNUrx/lNRio9Yw\nk5MrGgasbqZ1c9ZM7GxCfBOML97N6GvrpahcHw/ov1pDNgfWVmsTNtrdIr01\noQRluRfTL+2YOiaKehsYL6hIPPdoltzN0fXeSevNE91I1tZJRUB8QXLGYCBl\n4ftjbh/yCxXBSYhSbN6jUv6uLAs5XWCNRnlbXz0wtX7z0pz0YtW8n34+tYA/\n6Rq4OLzHI+BqdlxmXpd+5IACUmrQ75LuVwLWM5pzldwCT8MDo69v3VLPAvTh\n9I57DIF1sN4U6A9KMcRCmfF8T6d+k+vMiR61qj0WmvwwQICEak/OUgRbrFb6\nEtA0bpVVRXrQLRJ4avTABlaMvc+Cv2By6TZ/w7mVa9Z3Ag514jQ5LZPhbcGV\nSUyyHGDAbrL86D8gqVasAwBw06UJIJuXWmbGXSsB8sTQaSjwkAaGlde6tzI9\n6Jw7AqzxScKq2bPV6em8KaklA5Z+7CGk6qv3MIV+t7q2IDdaBuB5sclTYPJE\nhK5HVphxMD6hIYtzgTj9VoTAkIZzXzJMj8xDxa9A4oB9ahByd0EpaqwvW3HQ\n+EH+qpq6OoAn1ApEGq5WBAXF36+pNViITi0zNxgJUu+jsboaBnlO1EZXfR2v\n0FOf\r\n=oG9q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b615f7a556c18d16d7c3e659a894bfd9c7e47cd5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-552fedd-1603031024483_1603031072398_0.7770392049788364","host":"s3://npm-registry-packages"}},"1.1.1-canary-1f85529-1603179184054":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1f85529-1603179184054","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1f85529-1603179184054","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f1322cc49b4719ef3d897806ee8956fce730931f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1f85529-1603179184054.tgz","fileCount":8,"integrity":"sha512-TGCGT6q/LvUiQC9+mUFBpGsdN2/u8rQddKk42Np6dtlCGmPF9JXgjUqoAxUJZeL3FKL460P2T1pxaFL+sJ038w==","signatures":[{"sig":"MEQCIFxyuQ1erd5tZFunfZdHZZG0uUiURfavxvezXh5+QikoAiANQe765nGorUZ7MnrtijrGOXDeFUKngEGdYV+3XTaGZg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfjpLnCRA9TVsSAnZWagAAf/kP+wTpBCcqLoSkh8bXL/y2\nP6Q+4xNuC4EPGqsRpirUXRk2WFAFPpa0PBIqkMoCnZoW2nDqKpGDRCGETabT\n4thW0ASsn60QbmUooZIVLllR+D4k9XaLLV19QLUhU4hWYq5Wlyg5Zp/OCnmm\nruLWmqOysimM1V9a77hih+8MG6IIxVDC4rA0LWzu2Tjg8nDYQ46muQ15Nhyx\nB2sFMpm7IrFNj5UJ7ALlkjU1vjrCsGO6tG/fyGUCzq1BUP8PLfZgGha45+my\nZLmWh0EYinj6NUNGF+mQBj/oW9OkILSEsDgbdutBSoJ/q8Q0mSQnf9CE8Q5u\n+45nC3OzLL2UjkOUlyvSvZhYZCAzrRLh20CXG4ior/zrVvZHZOKDfPNDbKoj\necVV5zZnS5RW+IzsMwKT2kDGV0A2hqYDJg0HoUmt2vJ+irGBoOSsDArKBl0c\nBes3Ecy3px6PjKONpJTAd917CGoc4Wax6g6BhGM81hu3oG2/ouEGxWeS5dxI\nynioDzlS+ezykNdmt8QmdkpkEJf8OT0ckjTWXgSxuOBp/DxKfNZ1vi2oe7Xd\njFTuuN6d7Hq64uv/m2DwZSVanlPmDXnHwXvbSJbWWzsz1f3ZGC/Hqx3f2VC8\nyA5t0oNC5WSFEwcVdQuwsRvhnw1CUj5uveucAOqlcznXIzVI0IJtbLDgNtwA\n+HAx\r\n=LuZv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6c3cefcd884914297048746f07662b0b5c3b6c52","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1f85529-1603179184054_1603179239436_0.8805209865621375","host":"s3://npm-registry-packages"}},"1.1.1-canary-58602c5-1603290660780":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-58602c5-1603290660780","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-58602c5-1603290660780","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"44795c30ef182ef22b79aa03339ca651e9629801","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-58602c5-1603290660780.tgz","fileCount":8,"integrity":"sha512-5k8GHzgz4bcE0v4LNpRzeXIAWAZ1g3HzrAm9+CddSx/LTK6rl+3wYGHCef3UMeSHq0n5wOFHuRtLxdtJR5ndew==","signatures":[{"sig":"MEUCIAMtQJ/Ka17j+Gs7mEvSBeo3IO5bH7/xYZ/MLOsWs1g3AiEAyhGMF4ae7zrVB87fcNuw0DVqgEH5cPF6tcWOuxv38H8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkEZ1CRA9TVsSAnZWagAAy20P/2vFSxdiNQuj2dlAC7T5\nh9nXGNaw/26BcNi9E1U6I6R8pAb6tzVVXiBDIskNemARRzD93UK6ugklarbI\niJBBI8bG2lJwYFhcKnxzyQDWbV89VXK4HV8rBD/J5jWNL1aB3PjG3Kx/U56H\nmaUIriWWqHvPMtDXwhMmj4Q9GtrQ1YR4yEv07rbcOo4sJUiWZOv8So2IvFGt\nK5Eej0qeH3i0oyDVRc5WkO8HUNz0fclGKy4TH9oFenXMC3bHzQlcEKJkS7Zz\nepK9RjJsuvaVOs3ZrpJ/uqwWoRU52+CxzQpaJWI1MUS81Sgu4e0q7Kner0bG\niaHIcvEybFbrE1xUlrp4fBxE8Ul7f4PKcCALMwNqwPONKXgZiFDgfLhw+SQ3\nhpcUH8yOVFE98FXLXPbgmMxOoad84gGL4RvfA8eIcn2+qMQNuc5SupU3hFXG\nYoJ4J47XMqOV8RegruvbOavOxosaLmn1ncUMa0iE0IFTQfnuxlRkcNON9XZX\nBmPC2MXX3QjbFh5aFVBkFDBhdZdNJqKEzakk3lU0clb4YpOoSmWFYUu/REDq\nZTZTFmPWvOEhZ2zJVaxMqNacIL897Zy/Oi3eQyUTCcCisHQ6XOZp/96J2tYe\nXuLGD+ZSgCCtBYtrFOBrs3QjhZ+5Y7VcsSOM0eLYN1idhYTSIv+1RWqV+EJL\nru8p\r\n=JSqd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f8aa54fe68b26401eec4f52812c93c3074f443eb","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-58602c5-1603290660780_1603290741327_0.42780945464360043","host":"s3://npm-registry-packages"}},"1.1.1-canary-4350e75-1603354976299":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4350e75-1603354976299","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4350e75-1603354976299","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e86d1084d5c9b675ad919e7362d7d0e9ff11d28f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4350e75-1603354976299.tgz","fileCount":8,"integrity":"sha512-wO8PXW2+ChFayiz9uG4CRSrL9YE5Rw8JlyUUiCKWqGU7Pm5B6k3u2+I9DI71XalTekj82Tnw11fRKvd50OwQYQ==","signatures":[{"sig":"MEQCIGSjXNE4nyP67lhWX1ersjJgJR8yMm24gpJ2Cu03Z4kDAiBbKL3SwpcRMz0yah4YlZNH2vedhVYkZl7WlLcLESHy8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfkUGmCRA9TVsSAnZWagAAbIYQAJ9lUdPz3b9bzSKZMmgj\nnXqUYy8uOoZwPBVrqoER2j2mpqI8pg43Kvyaj4KaA7DxCX99hdoHw+lMlFXA\n47d2bV5iG1LEgXzEEWWt/VzT/YWWF4HKj1To5OgPAWOOZsZBbAHzw5CbC/EX\n9CxQNiAmM+i7vgZR0Id2acAl919hnysxQPBpVNziFN885BzC3wGlfEVQh2sJ\nXoT1WIofKYEOAhNdPnieFZim0MyHK2ojaKUP/fKVNBIexGfh3IsSlquaSD8t\n/20BiPMA+VdcQ7uN0rNbcZ3uEK2ykAUxVsi0fMsC0+NZ0PkxOgiZcGn6ceDm\nHbeO2vFbp/hRe4sLZl3g58vZ5NaNgIcmeVurtti6z7Na0XIUPdZr69OHuLda\nNqz+eVqE959mE3GnQSm6KjX1OjVc1tA+nU+yraktfwUHNw9EpMGqa2wpyYo5\nzRAJHIjQF8akJa/5/YF8CYHttzl8nXXoTtseNFBt2APa1TVUwzqmnsUaSy6m\nezUeTu+CPzHkOKNvwj0fqHYp6MMHUc+gby1ufumJ6vEyEtCy404mu4XSd3vq\n6OX8SgwP+MQ31lvsmGac8ugVirwoWgly4taUrHpCdG/9KTqU/nudYktZno+4\neddipSVXzzJ5Q5/J2Vimkh7RnmBA1sjalphle82VmLx6pPnNBSCljEir4FkU\n6duQ\r\n=vrR6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2aca030562d426f014c79333368b663c9da2db64","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.1","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4350e75-1603354976299_1603355046474_0.014356132404617972","host":"s3://npm-registry-packages"}},"1.1.1-canary-500ea59-1603548577843":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-500ea59-1603548577843","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-500ea59-1603548577843","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"381413efa446234763626139f586b7a3d3be2762","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-500ea59-1603548577843.tgz","fileCount":8,"integrity":"sha512-TThZyYn0Zvf3mfIbyJiZHXNe37yRd8z0ijGVKQvk9n3SNJVmMMJFFpbleW5GPn4FuBWWi0vqmStlfwzwU/0eDA==","signatures":[{"sig":"MEUCIBrrPgILdpyCiOy/oEQb99ONbVQHHMSICYleZEMKz3WYAiEA4GsI3Olk0/1mJpEcvXpDhvyyCFR/+5i3QhTQUxy9K8s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflDXoCRA9TVsSAnZWagAAIkkQAIrFoQ2I7IuQS7cdiMa5\nyu6Xdbwe608f9DAXlVRemjnfJ+HFFjPcIZLO1tLp2bXc7O3mMJKIElPOpUkI\nLZiRJMHSHExz42iad1UuL+ZYrzCPuLeSg9NMnNitdPomMp1nkofmL+OXwA6A\nF/Z5TjP7GqgXZz3Nw2yctLvFK/fiyd/CVwUUunPfi5BK1CcgrZJ0ur6ou+gE\nT4dMRj6eR8eIjFPDjb9GItWLdw7pZJhzSWj8tZ8Xk/Xvj916od7N9yc9dRlV\ns+zdSG7HG2DXqv+ge1v222420/1MnRWpTmZfTumYGzqiGIDHWXSG9JUWNZ3d\ngB5Six6RQEFinNQJLyMgQ3fAuiPRMd4hjUzqp0y85Nzy8EQgGxy+5+Hv+FYM\nihEV0nDYW1QCnU1dKSWAvis2LQwTsLM/GADAMqhFtdJhKlap5/Ee0Dj8usnW\n0cEMjViT8dl0X3wOD6v6acY2wLOIxYJbm5xyzr/zsVyj/KWZiIFcCdIMMYwG\nbQCvwPHlUyqYdq0a1uvn+xsGB2jC2NQasb+6YzwbDsu0zDdgfdvQrQRgIQro\nL/HGTUznJGPZuzpNXbt8shTJL092PJ50CPlLBt0hIPfW+CcczacG3XHDhIrx\nPv0ObtIimdYPaRoi6EtP1gWR7Ct13IMcUSw+Z6/1+OZpcpq5W6pfO0VcnnuA\nxCYG\r\n=suwD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3e2829b34537d1f060b5a753abcbe47183104130","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-500ea59-1603548577843_1603548648430_0.43762265374805387","host":"s3://npm-registry-packages"}},"1.1.1-canary-4a84501-1603616456186":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4a84501-1603616456186","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4a84501-1603616456186","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5dcc54dc3fe4892957b9879e95ec882bd0716358","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4a84501-1603616456186.tgz","fileCount":8,"integrity":"sha512-ZndHDLDg5Yv9ACGxm/OE16G4dSHtt4uDOlLFDU3Df8bsGAeC6jfIL11c2cmtcW8662cnZt3lHV747d1A0gMazQ==","signatures":[{"sig":"MEQCIAsKpTmVa9JTXsG6PzR6azGyK+3n4CL2in6VUEC0FE/fAiBMT54r6LDhxHaj8/LLgXoG6XUpdBaWvmRkrUfahz3Blw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflT8LCRA9TVsSAnZWagAAh20P/3kvh4b1usTUctKpucdR\nh2mVP2wNuKfQplb01vT/mtPXrWrw3dAkQjbJKOO9gTaATrli4rQGfoM3E9sz\nXjkzZc3DcFLAYjtzhpJv38RgBhXFsicg0aBibXqlhAE6FIRpOX9pimhmjPZF\nlDUBwJMqwEB78kvWeB5RnwiswyuyXd/LtJZOROislyfRP6Z/cLN06ZNbiaHF\nOOjQkzEMy1Q8emnYmY5T3ZyqnDqxcmH+/kThTzWl1qByfDVhD6CX8LkSu33i\n/SNzDuTSJnv8FUJmCN8sjXqpJe4oJnP1UTGo4emc8qa2PqIWxCjxzCwWp0/K\n77qsrgp0y7drkAqy/bfLSvKGcO57xwYOybZZ7CC/GUzNCSl+h15r/jzBtwl2\nIaFHqtyNEhFvKCCbjOQ105yfyK+EdkmBGwOLbKSOU0dCJqXsH2giAkf8f+xC\nRA/C+wzQHUJ5VGA/LJ/U+oV35/KjPAIU7jyem8cqzCO3R4Ygp8yGmKnJzHbo\n3UZmbW6WbsJJgVd+A8CE6Ak6EKFTJP1kL17z6/qEjTvOzRn2yBrf+KTNBi6W\n5STPzXJLs2ciUHP6YEXyt+kovHm+uNiEbEEB8LzMn41QaO+iWZnM2Twz+S6Z\n+V/nUj8Hegwr+N9YTHEbiR4b3P93/xZ4e46HhND9q5x4qIubAVexiYlcXjWP\nLYIn\r\n=6aG9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d34ff0de818334004d5664cd0e6ee565d3cfc569","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4a84501-1603616456186_1603616522723_0.06949880975479128","host":"s3://npm-registry-packages"}},"1.1.1-canary-fc6ff88-1603633945478":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fc6ff88-1603633945478","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fc6ff88-1603633945478","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8fb96e425d9faf5dd1088b282e78bd30524e8602","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fc6ff88-1603633945478.tgz","fileCount":8,"integrity":"sha512-tDCOMmIbbZL/xeSb724k2wOi+rMNmmUDwHeD5IG8kFXYwM3lW08hd8EupxQeY6E44JcXn3CLsN/7wMq05pcMsQ==","signatures":[{"sig":"MEUCIBhCd91HxwnL3wdJZJP+2MM4VEcEcXNS4/93OPVaP1pPAiEAqKErj1YycRJK+OHIj8raDS6mNO86e7doA0zF8DXsVQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflYNKCRA9TVsSAnZWagAAirAQAIS/AD7Vadn/p83JWQzt\n7IgjIw0P5iGVvwwbQwReb0K9J0l2zvzqN7s5FOIDL6G9S5plDjdW2A5MbPQo\nfdIbbvX7duWsMPvN/7s/iN5aQDYwv2lzjiN/ZQCQ0CYWpi3yROx4mbd9oJmq\nvC8pjFOdo45t99+Ih9It+fcZgUKzcw5TFz82UwmJRWr5+UdDr9Fob0qXUzio\nkMf/M/vTjgnwa/S3BDmOhD7gxFnX5gdFUu6nKs1UAnyF63CaZUfcp6xUDBA4\nRXZmH/sFukWObSaZFURBhyN4JXYYG41zRlHmvPh8XW76bD1/PUsMVIBumm04\nod5yFJRXq42xqx4vol3LUiq5aqDM380UmZ4YaE2mv+W4R2U9gkFkkfmpsInK\nEP0drx05Ac+i68KC848Lrus471AAL75k9XgywTrzSVA8IkpSi5g1s8orqYS2\nz7EbXT23KCIGL9cCR5d0jG15etA3a0q4JZW6GfYg3Zes/VzFL2QzwCx2tfIW\nwjXa4JPfZh9NrCysl/tkd3z9mqF2zDSU0P9pMgGr2CzTk4R4VWy52kqJuFYq\nvwA2IIZLG1W6+7WhRT3/WnMigCB59KMS2lnCfGpbSMx2VCKz0GJTnAslTXMy\npS8arKeLNlBDQHFS0Lp7TndCnzT6KUCZI4m9Jk7N3ajLtxmKwNHTkJ8y11oh\nQiI/\r\n=4n9n\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c816066313fef36d7d5529dd0d1aa84d222e92ad","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fc6ff88-1603633945478_1603633994179_0.05372566915498833","host":"s3://npm-registry-packages"}},"1.1.1-canary-58148e8-1603650080917":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-58148e8-1603650080917","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-58148e8-1603650080917","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"367c49ef697c0071f1d3fe65f40fa5fb854ea31d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-58148e8-1603650080917.tgz","fileCount":8,"integrity":"sha512-s7IO5JMVoIgJF/zP0ktOxhc932cjSJLNpF1iA3JAemvwGHC+Ip4l8od4mk9sVchHDDiCl2gFs8UbCXPbpksA3A==","signatures":[{"sig":"MEUCIQDRWME0gXFiNnpX01BGVbnuNXcVX5iv0qlHAC9uovrqPQIgGgBzh4thNvD+YAJ0JAmh+BF2MvKJIaaKrNIP7BAQMws=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJflcJYCRA9TVsSAnZWagAAh7IP/RfY1QwHTfqY1XqmHCCU\n4SA3+RCN07jcNtCTqf1fedw/sRSEouQ1bDtbu6Z4VUhvRoOqsXzLuqD2V7tl\nApxNzYRPoElps6q8jn9Efl+3qrp1tJzlx73FxliUxl/DFF7LK4ndq/2hXE/x\nmi1oy8tb9wX3YHEc4csRnxwPAjdt8GmidX6oOj69DbdsIJRY326UVfkV5uTQ\nTTDiCaKSIb7I9dYudWJSIlr1yTd26ETjm5N8K+LL3BBiHo6YhIVpAmFLeb0T\nhBsBZg94ibe1NRCntMRs3v4IrCGy+eecxUG+hTU1aoxOr/Oh/wHjX7wmwtXW\nHZEYm6uIlv3s87LiONUgHC33C8PAeVoAbbY2uklS8HDG3IFHY7/dDN2Z0Q1y\nQWoZg5k1enBDqx0rBBS0pUZ/TJ5Z7xrnzzfI58vtGmjlBPohRywhRdPqQZSQ\nl/JwlPJwALVT3flveBK511B7+5uP5uIElHr1QQljbDGbQe4hqD/uPMFCsOm1\nfY2xVElqHl1l4LFUa+2FcCfBmg6DOQLvN9OMzME2eJwbko/BgPz/NGVlC9xk\nCeKEZdtko6f1Wg6SZ8y8DokueUm2o1tiG2Hi2RZqUwe7SiOXDZgOXzhfxHsV\nthCGuiqw96ThuZcPIy+u0J9CbCRsKohkwnXz/SxI9BYx9r00PdZkdAcPqEuK\nXYe/\r\n=UBy6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fe281f3d092173488760f5b79e2f64563a17d00d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-58148e8-1603650080917_1603650135986_0.24117526422026536","host":"s3://npm-registry-packages"}},"1.1.1-canary-3c0bbb2-1603830483772":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3c0bbb2-1603830483772","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3c0bbb2-1603830483772","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d3d6f4ef213d4c7f3ef55f22cb2ea6079dcb1581","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3c0bbb2-1603830483772.tgz","fileCount":8,"integrity":"sha512-9fJdCrmT3yUlQM/KboIgwY1U5iPcSe490xHEgGyamUyvPNNm/y350wxdP3eLzBVc0jMGQ7n9iKVPAb2LEa3eLQ==","signatures":[{"sig":"MEUCIBHvu71+3Jr4Xt3N3H+JNULJ6yhpNmSsmmyjEpsO6QGQAiEAmwy59teprHPJov7OKlSk3IAdtmHBOiTKlTH+DZAL630=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmIMLCRA9TVsSAnZWagAAIq8P/R3hw8+o5YHi56C5lEa/\n8nlvW9SjoVDZ0XvQ0izintIyhd6gpMIqmBzlvwYiy2oh/ofpW/5D2j8vA0EB\nMvajapD7kg2rcrtPwngM1+9lpZ9fB+iaIm98+ufHgwv0ejc43/k0VGT8TUME\ntaIFu9tkiCAFeMOn5tEErPFQf9OctedXHnPga/Pe6ESlY++ZJKPzg3n+tPBn\nZmHibmZ3ch1RMs+YpG1pNB3yDyrA7KtEc0kJpyV5hDPfqJA+XPO2U+ijyOb+\neHXeiS+xkalecwhLwX/+iKQYuM3GOY6d6U7HUuKwM9zpDzhg/uholaQVQmoi\nJcloz1YjgLi5LZOgX2VTp34gOhbAe00z9b/g+gI4aDqm1n2AoSlMf882rSlk\nQHbyS+ANALoVWaN5++Eb9f2moZzCVXNU3EslAWXQ2qWOaZv6GHM5Mj3PzaGK\ndMhKGbeYEaCgE/6ymzgWGSVnG6+v28+mCZ7ZjaNGGoe0+g03B794+/LgVrd/\nfguy9jimaoIS6t+K24OpPhn3O4X8gG63sWApZ/rri9eCDFK+PLix8BTSJ+YR\nYsgGZH9D5X8uBAkA9u5Q9BbTfmL9QOUgPsja8pNifFReOVQXHAtcnGa2/oNK\n0LnavaowOGMx7YBeF8R9fK/qUx2RNzISk0dETuG1pqmykrDAT6uyyV3WSm4h\n98JX\r\n=PVD/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6c4fe8f29cbf4286bbbbd9fbebc8761e259998c5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3c0bbb2-1603830483772_1603830538561_0.590047590292053","host":"s3://npm-registry-packages"}},"1.1.1-canary-4208134-1603838712674":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4208134-1603838712674","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4208134-1603838712674","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"23c6f10c73570c6816b5a6e2181bb4ea93e4e16d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4208134-1603838712674.tgz","fileCount":8,"integrity":"sha512-iiNlA/cLxVE5Lvde614KTtuCHAnA7Mr1buBv3wyzqo8aDfjgiviApfq7rtqx+NeucZGE8xwf+K6/iLya/aI6dg==","signatures":[{"sig":"MEQCID8naklrD2lmans3JN0jAi1Tfy4WjRi5WTlMHbib5bFVAiA09Aw1y1dGnAKpahDqD+sF/Mt6sSCwBKht7pu+xtlqcQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmKMxCRA9TVsSAnZWagAAuZQP/i4MwxwqfEEPzydZ81ul\nHNsb052e4ES1K1OfavQibe+ChT/Vr+EL3oPsZwvalEYd4fo7ypHtVyGFz9V6\n76vAAaC7NsY6rDulv6pZxING1nHytmXqGiGtV5CETWYew32jMCOmY6ec4jQ8\nChDoWjuqLMBiJMLi6yX8RLWvJlDNpZiCmDAvCy7aUn7hbDujfjBJLtIe12b9\nCedKk5NaIxe58OzV+P39A6fW1tLY7bZ+E1ccpQA4EwPuQPUHArcSXjNw0m1F\nl8rlgKJCf3Yv63cuvDEwvXMZN63OaFm6MY5ka5db2CJv7T4GW/AXCagkAuSw\nv6yzHARfrSdouZNVEluqcSz93xST+SyvhZNKJV1lB/2CPEs8bX0zkgsXnKIn\n+QbD3WtiCtS0g1EUad11jJ839jhRMGo9KQyFlY9QitBbNdAvjbAkO7fNMimT\n7ObeRSi7JKT0B75BC1DVqkFpU2tb6MUz2FRJ1ckR+oUKOSvfRqhwBbGbj2hD\nzcs6PvQmDE2DYSXgKJHpzA8KrYpiy82F0rexlX4nNM5jSuk50umzO0HykY+R\nOhGQvZ3Vl46khNQ1el8fz2bHaA96N6C1m1PIj8mBASUfyk9wQizsY4+F+Z/0\nzcRomI57qIlyzYstjiCTkGl8oE3sK506q8ByxREVkqSix4Mam0FOGxQxD6iZ\np2YM\r\n=Bidk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3d05ea594c5dad1c36e83c251f4125ac396bd7b5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4208134-1603838712674_1603838768996_0.15395034517948236","host":"s3://npm-registry-packages"}},"1.1.1-canary-fd85ee5-1603848458948":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fd85ee5-1603848458948","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fd85ee5-1603848458948","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d9c9de5c27c070fb1e96aa7b37aa6cc5f16921ee","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fd85ee5-1603848458948.tgz","fileCount":8,"integrity":"sha512-TmQZ5ztLnE49cMiZKJeM49FnyTFDUzMZ3x9k8BZLh/wGRsflK0YP2vDvZ+Wm/sh3g6im6+vzqKe3T1+8miXHow==","signatures":[{"sig":"MEUCIGfyWfROx6JHaPid3UqyX/OjgAfV0HgWRKmp6c3alnktAiEA/icj46eVhkQVpvTyEdcK2dbjFPPDEtBdpb6qB8dO1N4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfmMk8CRA9TVsSAnZWagAA/4sP/12yxvoRV1BWhRYiMN2N\ntuwfCe+4vNzd2Aj8U+j+xd9Z3o77UNCzJv9mAEtrH0mZIyITVRQUXuAaKZWx\n0WGtB4lu/wdQ5MV3aTRaKxY72emnYuNLMUEj4BUYTWmOFpcYrSsTfpX7QOaU\nV8DReKZK6ysnnQOj9aq15S70HU/Ox8UWnILEsFu5GAbZUhBLHCNi87XBqGHz\nob4bPpxx+hn/3fk2INSLQisdUgaznW0zs5OsJwqboMvCHuHxSMVShukkgixR\nf90hRZ+NKhfCC6mbhfBpVd/XpVbO8uWOL9GZoQOkqgScHf/+EXmt/sb1XN/7\nlC5MEjHKiUKG4+aYLB9Glcj3p36HAHM2oW+twayUj5IjNcjmZWPP+CAKz/FK\nDqGq9KK4GS2ZjFWv+t6Sp2NSHN4DLpegD3kQ+so+v2gnz5y8Gl1UvN0g5s4F\nYwoA5/dZLDzlrWCqhFjPqjQirPUwBdVQoc3LMTiAMKe/ihGvU6zITrvxjO6r\nvlpMZeyE9/6KRm5c/7JJ0xCX/O1E46jbQcOOHw/nGludEbRNxQTkjKwK7/Jw\no+CngRGGX0zX3Ni7sn01+9y94y95laAqREztQYWnOwbnpEAH1nSvaCYH/NG9\nuxUkoVstgp3BeUzH5OaqpU8D3tCZMWpTozGj0lBWZi1PI3igQXAVT89YCVOI\nmpT6\r\n=okpe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d902c17922f65f45f25d866b2901d3ed8946f275","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.28.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fd85ee5-1603848458948_1603848507576_0.8545369411599923","host":"s3://npm-registry-packages"}},"1.1.1-canary-2d316d4-1604107225974":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2d316d4-1604107225974","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2d316d4-1604107225974","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fbce8e496f4fbc2600878b2de639d64a704d97e6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2d316d4-1604107225974.tgz","fileCount":8,"integrity":"sha512-hO65gPvphzkqy3aP8JcboKlKd9JMbxCcEvZWwYY8APxHRMdgtG1oB/wqywyU5qp+ghOLxUak7vY2u+5V2CQXtw==","signatures":[{"sig":"MEQCICxjEV9X07/V8JLEdPpfnSrDs2NRIe/o6ez7W5t6SDIwAiAwO6K+ZxF9I57/iKCKkEsn8W/WVgJBynnfDso10valfw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnLwMCRA9TVsSAnZWagAAHdcP/jMfDMkLF+8UsKeTPklW\nJlY/EC0pvmu0w3MOt8RBC7S60q39LZ0YGpyWTffGX/pvocQdgBBCS2S8CqLB\nfYJ9TccIbQNobHQPK6jyx44Q/Tivse9jfRQtA5LP1by3uXdFM4TFRAgVbtjB\nHUBb3E/9+IWn555jidFgJ98lBoZBm8mLa7PC8kXvz0C/ZxXkh7ldFCQ7Ma8U\nPSY0bFwwRp/RH9/Y8uhs8GPHFRgkCxuUUKag46FHF3LG1G4s7s0lMV6HuEeX\nGlFQVQZf6xYHJLfDkCF3ajdk1yK1d5nh8TMDCkN5Zmr5p5zm5aQjnCUQg+lO\nUB246wNVG816CrulX+ESLzwudTjmwAHz2IUA5QLTCLjMZMGduC379gbTuOO5\nxZM8EsbGXZbwdLTf0zQTkEVB3XKY2EA+XnZsuk2GrsDknfylqYWwhxrJDrzY\n2Ac2d+7+rgeH+ztrxtvZRsFBj02iCdLgo842at+vwWAvVskQsU4XLbaOEI04\nBG8AtQPTYHoLYknKLPBpbQkad8BFtMQ0m3Zb7KeueGJbZm30h5q1V17FQeIM\nKp8CILE6dzJBDbfIld7hLAquvZow/berfqx2iG69Tw1kf6w26JjQS5Ub/Mlx\nr1Po9zGsHJCxm6gSkXgc8HnH7F2K3MNQmOh5lgbBgww7a7Btt1FOS3IiEnqk\nWFOG\r\n=3c1C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"23b541b5e801ba579b722ff5dd3614c40bf86c78","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2d316d4-1604107225974_1604107276428_0.3858608291919223","host":"s3://npm-registry-packages"}},"1.1.1-canary-fa5a7a0-1604213890306":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fa5a7a0-1604213890306","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fa5a7a0-1604213890306","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"74536459463c844cd7e80608399d0d90812f2e39","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fa5a7a0-1604213890306.tgz","fileCount":8,"integrity":"sha512-TkWIGTerKMJRry6edPPeV7g7XzfeKHPTqli3zL8YD8eXLQnPFPh/vMa3KIrnWM0tzwa5Tc72XFAwf88/HPi04Q==","signatures":[{"sig":"MEQCIFGYAo9KHV4153XtZChNzz+ti9e3EH1Hd8MRIheCxA56AiANdDTms4dqipVTClL3iQaNrdwtZRRPKETey4Hc7kqRqQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnlzBCRA9TVsSAnZWagAA96oP/15akivG8AlBQI4VlQ35\nRD9DSoGNNYSszS+4Y4q+lKF0oV38wpucwkOmjsIFRDruKBPKGgTFwYhytK8k\nFRiNkciy8yzQloxvGikhblP+LuZqv5Z6D77ejphmchnpWl7hQlnR7Eb9m64+\nPAnl4PoihcA30h1i7qN5j3Zvovt9BuJa0e2+SLViWgsp/0EaHBl0/JXpxaTH\naNWLdgDQURemykYA0rchYcw9T4JHVdeFQ5hnKmfCnrQdEVZEeJJX7z+FE8qF\nj73Dm3T+HRShu+V0kvcVguAancXhXLUqIpS0EYntpBaDMVvLG0t+EHycIFlj\nMuVqWTiZWRAt6KkrPM3pVJLlioz0AGFy9rkydhK/UafO5AiLdPWwIoA+qJ0I\nDORwEWgEbtg/jWc8mlpaTBzwvisDiwrJXuWtik8QtPwxcTowxdyBPv7tFG8L\n3vaJv5XODmOqQE0jbS7yhcgkb5EmfvhxG7eRipfY6/zbIZqQMBKk1Xu37Var\nu05P4SrNbdVG/6KI+jsIyKVfh1YSU6PLeJ6A3YqeNYPjRchr/UE7UDDXGElU\n03V/AKwCgS93VI5p45bXMDaY1PdrQg7tn69c8pDEyPvsBOOm0aYXxJ1nwgCs\n6s+Io3mQdoT0tgTxnWJ0zWRloZkyZJKjYC/GKLlkzWHgfhyCcBX7AjXjIQKw\ni2qw\r\n=HtOB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ba170e2e1d46163bdc0b9710073a109377fbbdd6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fa5a7a0-1604213890306_1604213953052_0.6347572519192617","host":"s3://npm-registry-packages"}},"1.1.1-canary-6f09247-1604273054807":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6f09247-1604273054807","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6f09247-1604273054807","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"34cd0953390f611ff804b07cff2d7cab17c0f2a2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6f09247-1604273054807.tgz","fileCount":8,"integrity":"sha512-gmSN3SjZ12RFTLREGX1SvEl9gTTTonEsDwM84jGusnmTRr8YXIkZY2SuyNUpznBdoC7uJE/l7FNq+0l7EL6J4A==","signatures":[{"sig":"MEUCIQD+umUFecsAcjQ5y/wTqadD2GAw3An7YMhNduoDyXvyngIgE0e24nN/liR7q0MOyXe9W/4U7snIzlv9Yts8T6JB3uc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn0PVCRA9TVsSAnZWagAA2ZgP/RwbNhB9WqDGHE3siMJ4\naEuhT+7GKhDZt2E8pLnuT3ahrz6d0z92Dr0oBG7fuKrCwncJGDDsuR2PLTXT\nLnM7KgrAc+0E5nvjsXbSUMXd4frh+Tk2JfrUYtP3kFTAV+U7CQbtfakVsNgj\n/AKbYV3Zxs3kMB6SOqihWoQEjVl3p44omwEPqGU4eQyYkmlJN70Q7SMSWG/y\nfaAJx0+zXr9nwrQwgK+hKFkb6vBpw99rKvIcgQg+BVgFLNL/fUHVb3IfUp+h\nZW52NMvNJ/l0rXerACtwYMx+qbOIFO3RZ9XN3584zBRNXAcUIbCBce0Dluk/\niGscgNqmfLK6EO5uu9Zmuxut/oi6MLr43b+I1BHm6BNrybFmAGfs6ZgR62ia\nXdOsv3GTtKJXzkzPuMwK+aE6KuEeJMvOfWwEio2ULYEKTQjPNrdhQVmBTs2d\nA+7LfobZw/FaIIHzD4puOil8OFWftRJaa3fMAFblx4J0IdQ0F0qRmmsqsxDJ\nORG/aFhEbSNMpSH9pu8yhdOnruIF6GVaVvHPhzANXSB0NMpL/jk1Uwh+FPCt\n7cS3WBiAMyN6UeKOBE+uZIucZvBuGVB1HzifW/t8VVWJUlvnt1/JzoCQ46lu\n+8/ZxsfkpbCSnBhgOjeDB1cd58fjfmUN1PXTdl+ShvACjNVMJn6jLiCHPOTS\ncEpI\r\n=q/bq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e701fac4553625059905459318c1f921ce4c2bf7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6f09247-1604273054807_1604273109361_0.21328915231155476","host":"s3://npm-registry-packages"}},"1.1.1-canary-c6cd4cc-1604309954011":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c6cd4cc-1604309954011","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c6cd4cc-1604309954011","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ab19440eacaa470072514cafadcd94f455605c90","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c6cd4cc-1604309954011.tgz","fileCount":8,"integrity":"sha512-6kMAcr6qSnS2eAMXLzctjCp+4rIG52HJDUdqJLG7r0rzLudsEz6nMjt8dz4RU3znhbqdtCWQy47c93EpF1k86Q==","signatures":[{"sig":"MEUCIG918j0AUddcx2cti86Sn8zjqB2MsiP/Iy7kpho+H5u/AiEAjGDMJHFlgiYw89p9zmY+LWB6jukyi7WwK+gMwNb4zAE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9P0CRA9TVsSAnZWagAANgsQAJf9Tchw4qSDnckh9Xe2\nEGUHKf/u9d8hVF19vX4LnF7ZCfsNmxU+YJqR1M1/RXOoskU46Wqn60bnlkRd\nOm+cBKFzgtaYtRWBo4IEv0eR6nOBnvzzyGQRKxLk3OS15qS4+Iim7JcSvtAp\ni/PYkJTcPCTykTvNS2vNG5JZnuMABge9H2yxfofNNrJxrxunbu+hj8pf7nCs\nxgag8Qln7emW5NoHn5RI8buqnPirlLYRxmbA6v5dr7itqLyJmS3eqMD7V6JX\nIpAguRi/8lmWNusVS0SlzxaHEp25YJoKqUSj1/OTgQV88UknGiV4P4yUUV/B\nopypP60U0xMXzJPa3QP8ZTcBna+65HqYeGVPrH2ZrtOFC0IJicxIG6U7SZ3X\nzmpU4W9y9mvieHmUsDOnZ1MXG8g1n7HbLof7TDpB+190juF5UhIbqhVfs1UJ\nRBXDvmFsFjltueMYysWy5r1vnKJxyOXBcpFBpWVOdk4oX68aaSLXO3DLPx4E\n+Nh/AhveD7Oipq4WoI5d9KQ+69ImuSKIXKumkKoNnbSFZA9Feq1GxJDy0f98\n5GT7lmq2p69d2gbThUpCKDM21fv/S7Yib39sg9nZ919ybu0TMhfRrJcAf1Jw\nOiqMKB11H8PNgY9Xgpl+npudtDD3WPmU8/LzMQ0w3Gc0yJILQFu6rNbBx7No\nZeIC\r\n=RqRz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cd3fe2f572aa60833988b222df3671d6155fb029","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c6cd4cc-1604309954011_1604310004074_0.15427076147434193","host":"s3://npm-registry-packages"}},"1.1.1-canary-48ad75f-1604310764637":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-48ad75f-1604310764637","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-48ad75f-1604310764637","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"782d2a284b1f4507aca371e58ba7ceb8f69bb000","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-48ad75f-1604310764637.tgz","fileCount":8,"integrity":"sha512-8jk3v1dDZtP/ugRXMGGvIge0xRDRbd6NH4hWEP3DZvpfnN7EiuhU2e5XMqE/dR8kdxRC8NygKhL+9u6mZB8X2w==","signatures":[{"sig":"MEUCIF07jfGmsJVGA2OBLAdHIK7D0oavrUz+LyT9rSzbrel/AiEArr7JYUKCdvD1tjCnmGHHDsbeUizzDkZSIGvBaWTDvyc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn9chCRA9TVsSAnZWagAADToQAJMRbGtudxyOYg7kw6fi\n1DYmmv0ciQlqNida+f6vEWuhJKvoLnEzaeNjR0YVkAZdxWY0LD5MluAAXAwK\nROcM+8dso/1gU5KS+8b8lNWzUE7GGC8cBukGMB77o+Dx8wkr/PWCSf91McJx\nq9Qz5xtaQBZah/Kx0GEeVHSMkk4FWLo7vkrBldqog/e0zPlc0/u31tKaLeQe\n46t6jdhw2VMOX35rp6+TAjxm4PHn2YwddwUefb7Ainefgu6sJvy93NAoNH6l\nJYuFZBdRW8XeQZjogKU5ZfXLvooa/WB7nzUq/Dfk0wg4NyPZI0YYlaolp6uH\nQs+jqVu39NVsDrZCeh6fi/MrGTAqzkfVulP6rMDLU5gGrnoO4frdJDbvULDU\n8ly1uf5nNUSNepkV+rNB4DAPdLGTCvUx+YBLYwJvw2rlVfq9GXtUfh08mlKJ\ni6rqfjUBNOOqvUlobYMungrNIL6WUO9njb4OIrtQDg+BesFU97+7R+s+NRY6\n+Bh73QbBg7R7PSP9l/A7lgOwV7Nqz6DYicMVULiuxnQ/TOXRLurYRvcysJLG\nvpp6lUX+rvVmC/phdyX5IV75Qz12DWLekBrKzTvXaVPiQTQyaLdV1Vw2OU5h\nPtHQII48T64VVbXBB7TasF3Nu267IE29bTKG/24t8BRJf1F4MQsWloq4ucaB\n+ZyM\r\n=Yu2M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8407282ae3216db6727b5215540d3a69a9e276db","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.2","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-48ad75f-1604310764637_1604310817102_0.9521675350862564","host":"s3://npm-registry-packages"}},"1.1.1-canary-32880a9-1604315402892":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-32880a9-1604315402892","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-32880a9-1604315402892","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"35320c1c4e9fac7e7984b8578fa1a486e04b6850","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-32880a9-1604315402892.tgz","fileCount":8,"integrity":"sha512-aWM+4FIuiM7F4n6ysslLdodtXfNIyhwbYK1dSvCBNhW/JcnTYVJnlXRB+klbdF3b7rS5yUK8jvIgsqYDIUGoDQ==","signatures":[{"sig":"MEQCIB5cMNO2TEc57yvjKpkR4KdvS7lSDoyux06ntYroGBZoAiAza7QXBiGxcikwERgjjzbYckM+1B2bfy9q4gakdy+p5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+k/CRA9TVsSAnZWagAALiAP/izpzcRf6Z8LmoxP+o0E\nHSVPXQ1a4iNSVW9sUJ4rKdULW7vBuKuuIVFNBFIXAbzfAYI5kssfyHpnex6H\n/OWVtpXNHogKWx3E72++2TdBJVIZfDWDgLxu10uNMt4i7av2zgL1ayKcauPk\nCKTWqVEZKXoJt7ivb3+xP8/8NyUyvDBhbYDtgn7H+x/m+5M2UktbUlzPbCBl\n/PBBz0GMaKQ8nyJC6sWco1ohULeLif044CsyWCtdRe9nJBG8VMmcINqiEjP+\nROMdEcEJJbSjDhFMS6tEfeF3eyWWCQXVdTLl2qvwK53XHCtkjJeucS30vAiy\nRwXKEPe6/omqLmSNaX3x7DwMyOcypTS5SaoEwU9X7dBg497YNtzjcwaGLGoh\n7YbTNugmo3hj1Hz0zOJ3TqS21iTCHCtIHiIR2uCLftzI2ABP7Q0yaNfC8W9Y\n/6BvLSvqbhu32dzZ+A5NvKuinhFxs5xEXwuDZUGNZCJIOnT8SfC60nTRjAHW\nGzvl7BeOdlPdpWPlWunjaQ2m5p1inx4uFgOzEO0/FUm5Xlv9lJUpxhIBAnwK\nA4ksOVWf0kdVYcjVlroeU1YRYRfK175/zU++yUbWaF6wCKU6TX6O5Jiza9sW\nFzslVt+wR0CthWm8IhlfkEvZw9Z6QjGb1/Tm+X1Seq3j7XVFbYLhs6sGpCRj\nPpJ0\r\n=Xd2r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f4d86de574b51b99414019c6ed3369f6808fc658","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-32880a9-1604315402892_1604315455456_0.5201063773953767","host":"s3://npm-registry-packages"}},"1.1.1-canary-cb5aa41-1604316908580":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-cb5aa41-1604316908580","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-cb5aa41-1604316908580","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6d63ec9afd030e6bc1230dfaa6a57765577ed819","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-cb5aa41-1604316908580.tgz","fileCount":8,"integrity":"sha512-eQpClawnmG37r2XVxHQJ3sojnrqwYLcwdtszS1DkFxWuZWI+8M2ndjYR5VnwJKSn7biD6Z931mgIWiR8xOwH6g==","signatures":[{"sig":"MEQCIGAEMJ+WhJpWqTI2cWHueT947sJqaXTZO9iaIdVCAbsTAiAu6YWtio4Dr155gBbZX+S285Z8WoFl9BlkIeCL9Mflpw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfn+8cCRA9TVsSAnZWagAAZ8IP/23ZL9V4bVCtOnnYiuSr\nlAv8T8fH8ZuxLiW6Uo0rqcYRCNiVq2ZQZ70U3nUuZegRCWbKnGd3pcyN8wce\nnNNHdFC1Y0458ksvqUfzO4LzaxGgsmqV6F8qhwXKtRGjwhaKwLlqy2ak/Vg4\ny1ELNs44yX2SX/q9Na+HbCTxfONdsah766oEAghJ2bzbT3sCzDKGum5+pA5+\npdSt4NyZfDHEC83MYIeWzlzfn0UHklWRr0YFpwF8mZHt3phCkCPocQqayFU+\ntjbQE7tZktWOe01ek9BOgxExZvgdQcMhAyRsHTZPVZq/9LcG0TwpSu141Fch\nMFl6m5cbgoHYZAycr9LzFDhUGRhMRBZO72t3WkNLF2ZlUgHDtbSM7TkPErtt\npG1OqSt7NZyUWqYrBoNArLQWmydY7gwjGvc37+6dFINEyVqeX4IMfU/gWsfo\n5yfqX6EIYp4FxpNWhOKq0vfHqq7Z6PGIEZQWH9r/+YFnzrR9zYMFKyLUQ7Nl\nYoLWKCo2APPymWE01F4otKFrvFbPEEDhPPgTTfIIY0VzSc07bA3Qc3ZhKoBi\nj1DS2V3ZkBy2QYrpzGVxkwDIf/xO+xmBTgL9o0PUxnSRzmp0DxWXjg6SjaWU\nl4KCImwSpOWtRS5FPfRYmuCvqs5mvWT32o/FS5DTcryd5oB3kXUUasnsKx94\nVrWY\r\n=IUxw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6159f018ed0871211053c26587d4dcfb6f6b4e1c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-cb5aa41-1604316908580_1604316955821_0.26113859807710127","host":"s3://npm-registry-packages"}},"1.1.1-canary-bbdf5c9-1604322483523":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-bbdf5c9-1604322483523","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-bbdf5c9-1604322483523","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"cb1480af238ee925d062c2270d8c2c9f3db8711b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-bbdf5c9-1604322483523.tgz","fileCount":8,"integrity":"sha512-mqh/pe2SNQop5xDl+m72Orv3ufhFuTu+z7ijjEyE86M02ljszszEC2GaqW1WJvjPdSPhRjUXxXKCzc4pMTZ0Uw==","signatures":[{"sig":"MEQCICVNxIP/QYyf4Wl0mW1U+4Qu+QLFU4iuQreMufDf9LVbAiAqwMRaqSoVjL5rJ7HRr3exhpRcHvDQbiipbdayVTTG5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfoAT5CRA9TVsSAnZWagAAWawP/3vlv/IDCRXPVfc05hf4\nBEp43eKlbRY+IDlwHUwvZj0niFD4k89vfFz2c6Oai77oUyRevFjcbEdv4AkM\ng1BLSo6naIkfOhLuK3YFg+x2v5+Fi39sslvJMoCzTxgaB3x0AjAO1UJQh3iM\nU9A+TPgW/FusVp1gpTeO9yDkQOpCRotQwRAMnpFkTdTAgnueifTb5sJog+N6\ndgKH7pWc+grpRVGBzvx2Wf+gZlIH+P46/U51tCWm/q604hrGZbc/3qlEscLQ\nZIIUmiNBKFbb1iO2zJg2Aa3ZgvUByNT/AvT2oKlVS3y0d5x9NPNPjUZPksgP\n7Rvuws5KowmIG8Sma3OA+F2lVA3tAwuqJYTIL7y713wJUrTll6MGaLmQEPrV\n6bVHzJCQ/LtFt2kU1yXUOgR51X1ZZzSvZ6IA8SmxOf0tTmWRtX83seyHu8iW\nMpQtNkx8UfQoXWA+ZZJLt0IJ+FStfiaA/qXZv00InjoGBJLMJO+s0nkkwp0q\nI2s1E1NyL4lvry/f+K95TYR+vbBwrPsh7grFVHuj5k+0wr1Px43NAsXKFK6B\nbkknX7y2i3fF5GDFgUQafgQQZV2hrI4CYzWO8G2IVs6AYhewc+ZPKcdJrttj\nxDx1lyhWpSXLJf8qBoPOvxUGrgJTaqF7YHRJR/SqIIlFIT8ty6xJ7ntBfdM6\nQD5U\r\n=E9Tt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"422aaadb0c0c2ce670456538e31d03eb7c78300b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-bbdf5c9-1604322483523_1604322553423_0.6942230266540088","host":"s3://npm-registry-packages"}},"1.1.1-canary-fd0081b-1604480585015":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fd0081b-1604480585015","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fd0081b-1604480585015","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"87e6fa47c25b50ac40a00c267893910fa678faef","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fd0081b-1604480585015.tgz","fileCount":8,"integrity":"sha512-hB9xN561Yk3g9SUtkMbT9jOBznycb80HdK3xQliwGZnum9pr77UENDKXNE1zDDTzuCgT95ODd5iqJY0lAc1quQ==","signatures":[{"sig":"MEUCIQCg6rG06zZj3k8xxmVVAAaQXnyMozoSLMq3famEbgtqkAIgM9QEYS/iMpgYiCk1DdYaq2ZTuSHXU0OFaMPXZ03mIwo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfom6LCRA9TVsSAnZWagAAnBQP/j0ACAzndQ9oDh8xNTLA\nwtQt5mqx0ABq6CV3u4Jd6tf2I4xOfVBNK1FoBjZ+QGI9i1lLg2c8c4h0l9q8\nPGFb+yTI8CK/1nSv62ncrHdPiJFDJ8UxCBJtSsuJ3xPkoXN+j2IB9v4ftIZv\nt6mzm5u0vPMU5elUImrYAtUUwmOS3XUqo2FIk3heI+djZtQCj5u4CQEs2kcu\n7pWo1QyjUaTpZqf5TM2RfKzl3rmoGTrHMSkL3aSNfQndxDG98ITbNeyQFP2Y\nvD4y676uig+sAXoxjHO1YdYG0MAXaVYbwNaWIjpmCEF+l7/HZZkaIjSJhCcB\n24KAvyCrfFG5zjBDcU22FyK1eXelMhXDYxkI4fM/FBaI91svhirGxJV6V2zG\nJz8A8gguKS+66U9i1sshmAXD+DWXdHmzfLwOKhQa1HUm4vNb3XzpfbiLhpnw\n0L1mAvqrJ/WEXe1FECwIkzarBuD4axrxLKIWOf3dDqxFrNu7uJnYFkkaNQb3\nF3PNjHRjr40FG1u/yFw2Ug0WbCHynv8vSs+hSzXi5uLBc2k91xD38CyXn5TP\nLSALZPZsaGkshthhiKIuEusC5DZ5TVbGjrMMZsCUQJ4Tx4O/SXMxuMh20OP3\n7AwEmHC6sj6gxOmj3MP6hIy90vp+bs9IA9U7EAfjOo9FIrsSPNwiKOpD3LSz\n4T7w\r\n=tP44\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7cac38f56f24c427f3928850a8923230c26510bf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.6","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.22.1","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fd0081b-1604480585015_1604480651014_0.10108678697577034","host":"s3://npm-registry-packages"}},"1.1.1-canary-b5953b6-1604714929475":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b5953b6-1604714929475","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b5953b6-1604714929475","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b9d5d67d42f6bf4e41ef0b08f93b7cd2a8b9d957","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b5953b6-1604714929475.tgz","fileCount":8,"integrity":"sha512-pOMK+yMY4qq1P0/jTyd0SykcoXD/vHAqkdjDp2rDOECZf46U2tD1lDFJrYIir3qBjaLdt6Rxw0sbgAH5RlTLpA==","signatures":[{"sig":"MEQCICHWrHc9xl4REqTyWxGOMCdFj2+FYoi3cfB7MG8Ns5RkAiBNRS1bBmMygQDuJqrCW5/QsalrGxw9TauCBh/v24bAgg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfpgHiCRA9TVsSAnZWagAAPbAP/R3zkHFCfzk0wqAVMD0O\nJDEYrzqmoMy/P9uSJ5FTLTxPsSidJB5QpyMiPJV0WSO+7AACw96ETWja2uRd\nr2DT5VaL+vjdXl4xWzTf1oJ+l0/es2/8IMt5W1toL4+nJaVXXgChVUnOe7xD\nS7BLsm6zn2bUJed3NjdgK3JZB/aQr1uSp35Q/kBP+VanXMOSsCdLmIk5uhox\ni2p2/YxjHVl0J6H8ffdNfy30wndJL+viLyEy7Mij0AQxKp5nVr/b4mKtQ4qx\n7TZRblYIZwUMG5ln1v2sXdV5xBfOv1MIjkcHv+SpZurWyn8pGOAZsImySIte\n5LoNhx3rS1Di6vrfJjfExC9CkcENTOM5OPLhxj6gFkMoyuoHREBoQipYwJsT\nroS2zfYjJVSWdomN+4it/P4j2bvuDG9F1CzBbjXP9+Hfiga5uG33WipKMFRb\nAqXR4XtFJcQ2QLYo4d9b/y7ehRVWYgQni6dlxcftIuAhMF7/lILBCL4lqIQL\nZB/cwRxxOGg9LwPyy8dP6RcntvZm1bGQDAPzFGPJp1gaS6i5IKspg347J81A\n8MXLyM3vRklLKq76+0waQAMPGBKwAlSFpI3tjAXFWaJJNMIGLoWzReOK3seG\nLS1QueyIdcAdxRv89onSP5ny+4twdR1pREjkfLBT37athJEYNUgnLnl5RoeP\n4tj7\r\n=o3BJ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5e705a3b49f02bb4fc482d95e9486a63f9805b9a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b5953b6-1604714929475_1604714978124_0.0010589348720559943","host":"s3://npm-registry-packages"}},"1.1.1-canary-eabb900-1604848093339":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-eabb900-1604848093339","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-eabb900-1604848093339","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"517adae7df2b3293cfd4ca2b23968fb3fa880c6e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-eabb900-1604848093339.tgz","fileCount":8,"integrity":"sha512-l673xMAaYSu8MxXFhT9+xIFzBs/Qfe+s6DtyA1vfVwbW7G0sHpsQZFMN1P3ShKGqbfUaMm3l/ynTdssLD1zTvg==","signatures":[{"sig":"MEUCICPllPTpqIIDfMVsDCEdqmU3wD20/2SV0/VsOND6OVdUAiEAiQL0K1DuvSdH2an1D7k7rKGqB6/r0I+7PEpn04bKfPQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfqAoZCRA9TVsSAnZWagAA69cQAJE8Zp4IWf5EmaD7DDaF\nDEO1cgqmUYpylX8ogyu8t0QpfcT/q2rKCWp6LMUHJGnUFv7AMsMItZvaNAcU\nHT66iYXjjvRXE4wRgpJNdv3/AeiGyXfCVn5cDll7FeG1Bt4Y5kQDcvfOGrHE\nubciutdHUtDLjU3BkTlQw44h1ZJr7dIfXCBXOY2q7jYsys3W357zL1Lm7iQ0\nB+QcsGDuu9llwN+8tx4N+kqj3kUKxbtpQhLLk08ZudpDRkc2hKIRuny9u12q\nfg8bPHJJWp8TvFInxtXOw+mhKGKjNgZWOR9Xf985ap1UoExm4PhCcCr3OUYH\nOLq6vcEJHziZ6un0BFcOfiZ5AJLcxQ0RUToTfJWWS2/rI9j4qKTaPea8SSrr\nSqUULwDgX1rWJmlSHXmgPaomGCSwV4CRSRQsSSBMKcVc6pSOR8EsD6tHZIoj\n8aftdowndJwtBFfPMaksyN+9VtwvtoJej6LCRHzPndZnzDQv6O77Qs4+BVzF\n2GIaI18C8T7spjls9iNz8xcNxaFgCV/b/c2IQCzHdjgVs+jKS8mLPEoQnt7o\nR+rA1JZgxuQaCFjeOgqQhuNXaOoq7NCnXB/fqSKcx7B8BlPxlSrlYeCqulbe\n9onNyiu1uex/fACvEVLhWXHB/XuZ1MW+jZpgOim3I3oSxPeJkWRmI0Ydd0Wc\ncDNv\r\n=4Oui\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ad63ed93260eee2f7287419080e4d5a1dcb35b37","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-eabb900-1604848093339_1604848152635_0.5923865217445288","host":"s3://npm-registry-packages"}},"1.1.1-canary-8f30d8c-1605363766533":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8f30d8c-1605363766533","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8f30d8c-1605363766533","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e8c4bd1782c6a281ab49c29a1fd75e85d78fb915","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8f30d8c-1605363766533.tgz","fileCount":8,"integrity":"sha512-eJd1uNHY0gfHHn3L3w2NUYI8q/BKRSLdbBJOHRL3FQofsBgiZ1+BCSbwcSQi0WHnfOU/qE3Zs4hsmDEVRu+mtg==","signatures":[{"sig":"MEYCIQDQHyh1lNpMS4d/Fu4YOCRp4T7BcNgG2QVDp6RK1o94fAIhANI+SMB/ZKYRkrmdSQp0cU776N42WxeH3pNrzjF0+meK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfr+h5CRA9TVsSAnZWagAAimwQAIYHcbMWx87BCXSg7ZQt\nm27L9Bv9dJyw1sqFYPPoRSu6sY5kk8mml1IsX6ec4rRXom57ZyN3/wRIou53\nkLwUxrWik+lbSs712rsFCczziWyc9DjKlEbYkiL/QMylR38iLjnqaEJ7019F\nyfNdAWs+TMuJ1zR0XT5Fa3eaMd8lyT5ilhU0hf5YlJb5FgABw/uGqGSMqxtf\n4H+sn/DywQ04gaNEWXO4MNj7U2B5EuWtM95pxBOeM8VGqd6FTXZwLEKJWhtZ\n5ekFuUahLcVtm++AkOoF0kxgNmz8gROwoPA427lypCEmbQJIRdprW+F0S+Et\n20G+V7bLEcOt5kB8buMQNqb9W7qg3otQU7c5S9gRthzuuLf+R1SpUOkRbktE\nbKu1HIqRfk72Av2mEGlqXEk2mop+Cf6Z9kDl1GGMUUtDenJKB1t9lWqSvype\nbpeW1LP9HcKXN2y2CscCadQtYq2q9ZE+T4x8IzB/K6WOfBDnf+Hy1CQ4+jrD\nYUkBWDu0wdYA35IuBiAa/u0zwg+F9gVWvvr8yLM5y3LsuyFvXevojCGcZmUt\nJhsKoyAEx3yl62vR0k0zQXEpofAwJ9+CA8NwgOxTvtIvHDWy1xfd+pB+hDcr\n6icowpB4GQdmxRL+JykhsrbGIjGPe8MOSLmBDMu0wKaNW27e61R5RogllG3A\nhwW+\r\n=zgXk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2f827826676abc8fc76898878298ca4fac03c86d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8f30d8c-1605363766533_1605363832584_0.6057567406699218","host":"s3://npm-registry-packages"}},"1.1.1-canary-4ac3da0-1605687302992":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4ac3da0-1605687302992","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4ac3da0-1605687302992","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0c48889f1085d8fe0bca1dbfc2d6acee36af8778","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4ac3da0-1605687302992.tgz","fileCount":8,"integrity":"sha512-KB7mNwCNl4/IAtyysFsllUnS8wSKwOm4KTG7HNssqy1fI5ZHZ8aZkP+AP91pn+cbelovqLbXXwuRVf2zsQWTow==","signatures":[{"sig":"MEQCIDsPKe/8uJsPDcEipEBQm7KBqs3j602FM4zNg13A6A6RAiBU5BCm9xnZsAa7S4890SeWuX6wrcQlY7+K9sfKl35wdg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJftNg/CRA9TVsSAnZWagAAfx4P/3yNiGffgHo4vVqdNXxk\nnfS5jdgLV4Qb3QICqKI64SeLiju3n8+VqrAoh31qCTQ8yp7/ndlR5Evm3iZq\nwl86ddpD/fzYeJu2DGEBIkU9RBruTvPGn++XtLimxqz6au9KjzLA/E6IBOHS\nXVPGlHFdRTppQgF8fGHZpWDOis2PiX4qbvuYEkc1oUX/fGFoNjQAWBcOa5jH\nF3eDmaM3cJtI/1E5NgmGQQ3P2N7OXWrQoEtkfGL9HGuOeM0IexfLf9omlB9y\nszIqH0nzJdR6EXwvj8yCmzXpHqKneEtjR67nz17e5+zbkEC5R1vnZYvB3zPg\nqoy0tx6ErmikImgWKY7pZWicjfpo5rEaJ44i/K2cnx5x88y/JWpX9vxBVbLW\n/W7z8dYGIXU9HcHLhrqEcZYZQ2RaKMAWHRCVA1S1p3HqK+WfD/GnMLOh35Pw\nzd9rTZwOSyqAOMzyE7XIa7gK1in32BAYhf1m5L2Rm1X8b1eL0r45PwT0eaTs\nXPeLyWoQxqbVixfoU3ZKFpVhwv9pTCNA2gj/tbuZ9kXVfzOBiRfpzZbO1h0B\nVb8f5TRMRN2R7+4nW2nwMvVuPDm6dymEia/+PEwTQGdh8gFyqno6BqKIyp/M\n8zjY5poYv8Yz4Jlj22bpppB1ryOyv/b4tOo7dvyJ+rj8+Cvs3pZIUUYuHpLo\ntl6y\r\n=ZimQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6fa8566726434ddfa2560678703030dd70661ea0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4ac3da0-1605687302992_1605687359372_0.4880291566217676","host":"s3://npm-registry-packages"}},"1.1.1-canary-d7ffeef-1605912871554":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d7ffeef-1605912871554","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d7ffeef-1605912871554","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d33b5dbe707d87bc5054a003962878ba56edcef2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d7ffeef-1605912871554.tgz","fileCount":8,"integrity":"sha512-HAaDra5cIVhAphSyTD3GKs2hLB1w8FdLVYZnqIuJS7Bbn7qKyCS26NXv443RnvVBUy7A3pHDKmtkat1FHo6ZbQ==","signatures":[{"sig":"MEYCIQCE4rqfHG0ltL//foJvLYKpd3TYCSDFPv0CE+JRlNdFpgIhAJh8owxgMRzRo+JMPmlrBBx9WMQyhsA3mVvb4QhG82AT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuElbCRA9TVsSAnZWagAA48wQAIoyXb8Box4Ap2sy50aE\nSpHSAl/Mnw8Y/uROVfRlmMGLsQo8LAkXzfWrMryStQTLjuc2vksHsGEsdjEq\nzaU9VvEIh81G6Vys7sitXRpRYogPa991p8LFq7Sp2yLk5aspSL7rdNDQh4t2\nPw8/pv5k0YyvSXtKbTvyDE4m5XQfk1FyrWrKMl21jO7QN96+JBEzcp8egfqp\n5l328nfnLi9p8g7N3XD5F9V+YsezDZR4Qw2xSaRBiZ5xVSVTvNyUsVY8RkVS\nl7JScU+6xqha4LjaS6tjP2P7AjOnefOiGBjC3lIFjeo2m9l4q4Y1de3/4qr2\naJhYCmtkYWOCr/459+EeKRIup5pv+4PYnlb0n5I2jD1ZfSvVTGaLuyNQoBUS\n5OKyj43ufDxm3tz0qyT165hAdbbX5XTXK8uQ4NdD3mf/QCpCzytEh+x20kQI\nFnClivQu0EjEFFz2rOAMmMb9Bp036xXQUpw8XlIsX+R4P1RzNXCzV2w6nUg+\ndzRClYs+j2e8VIgBNCxRGM5ErsIS4U5cI3RRSjg6aeh/3YjfeYILTqPbK89W\nMdl6NI2iaKS740uQ4qaV++o8Ha9X1a9hekZpA4rF/Ww9jj6n0bILxA2ONIg+\n5ziTuC+8ZixOQuFgtE7iLCGG7Da4uYQ0A5BgFb6TICFAYZLVFQgowjCxgW/I\nYy6a\r\n=WeAL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"347a6dd3ec01ea9927e8f65176056ca0aebd1f0d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d7ffeef-1605912871554_1605912923152_0.463218870402861","host":"s3://npm-registry-packages"}},"1.1.1-canary-5e05e71-1606630494127":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-5e05e71-1606630494127","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-5e05e71-1606630494127","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3ec55490cdcd84a916f745d5b611696187dcfaa9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-5e05e71-1606630494127.tgz","fileCount":8,"integrity":"sha512-zsxgKD2bUxDNfyOHsL0ikw7I31Dml3pM5Z//f373nBIInewHMq8TcjD6QAyM+n3OprYhU1OcZPXHB4HR9H8EZQ==","signatures":[{"sig":"MEQCIDJ9joiYSsYf6IqDioNiiJJpnMIBT4voFqxw7nvruv2aAiAhthnPEGRJ76vDh+uwr45a/CI6ZoQOtgxFm/7uD6cn+Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfwzyUCRA9TVsSAnZWagAAHJkP/jng1vBrr1KXVCzdN4kg\nG44/Pmx81W25CKY/ugcPJZUBqZk3/R+zhpWUQ3z3aMg+wVrOFnQo3K8gsfgx\n/3dddKc7NU/w0l1sqKk1YWchmWc/WotMuMaSwNoC8piIWyg9h3j5rMOd04Nv\nkWY+Qk260avLTauqItN1/yOXlnHRpsvJXGMsVS5g9sBHMD7ixSbND8d1KMgD\nWuN3uiYI5G93ErgnaP5tBTOdFpY6a1Vt7WjdqBvcW2F/qw3nQVac5OC8uzAD\niQrkyCFC9ZhRzDUXNbUdqjzerlIQq66UDQxHZ+AQ7EwDXp013H42+EatJqgt\nblUt84AUsxAfPKPWLJMQ7OcOw4OYWGlx0PEpu6omAOx7k4gH1v/Ic6DjBIle\nbb5GHeRARhXvWP82KTc13l7SiNpXL3NoUvGh/1PYLz6jO/2fBcSfG3j+5HE1\nzvDF8bvJEoFMoIEh0AMBGAx5DX8rL7xMsGTCJOo4xnpBh5PIKFTz15RrhyCp\nkjLwX8mJ4mjB3ERNR2EWkR6dSR9aTmyj39bqU+PPpbza1/0Aqsn1z1pXc2HE\n4s70V0CXL+C9THpgZGWbazVNeevVappslAung+ixPB57Yariawn6i6a6cWWy\nvQfmzwyoiuaILX6z5g+OnkeWjv15NprZZhGGRYv8p9d67+IhWSeOu6pAk1Lk\nO8+l\r\n=2RnD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ac9c7b3cffb4743158052399bd1ab28bcff74962","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-5e05e71-1606630494127_1606630548385_0.31265317902586953","host":"s3://npm-registry-packages"}},"1.1.1-canary-d5e13ca-1606854733107":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d5e13ca-1606854733107","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d5e13ca-1606854733107","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3b455723e66e4760b781ae450148907404ae2dbb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d5e13ca-1606854733107.tgz","fileCount":8,"integrity":"sha512-/6NbCc9q/eeFZBJBoqS/zXtyAa9+tW3RH+/z5YL0mi8Oi80lOt5spW32hTpmFDoAN+nVRBEtnMNqV4rBlVOKHw==","signatures":[{"sig":"MEQCIA+xZfprVxPn4+kPHkAQjNtJ/8TZVtTz8sh4u+Q5L7sxAiBflkVm989PyG0ygal8U6UAcKtr3poV0qDjWZT73tx/Mw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxrAYCRA9TVsSAnZWagAAFuYP/RxcVmfx6/Oo1O+AH6Il\ndDWMUdQbKSC/8t1ulptAjnaxRY7uBiBmnWx/cKX7u61X+nxJyn2yLX4Ykmc3\nDxcH4fHH2Pr8DcS5nUNb8DRsYA/BrVOC4j/mivOGjZdhKrjaqaE8UIOGJ1o0\nLuHipOllZGkMZD9IuGHqCfc8eY2JQhEOKMOGs0UE0nPbEuhtLeSybn52K185\nOugrQAQqralF7u3LrnIf8ixq5J9nuYbaZL/s2vNL3cWJlqRzCWXUb9S/IfpG\nYN7ol0gpAVGMEVSt0Ws9znuGHv+J8y4ti/6z+nLxmJGxxs93EU5Vv33KpRMr\nLsji/xExjvhtBDaZVaZonr1I7w0dfabcnQjzWGAJQfjOGbp7ncRuYlrd/ZX/\ntUkbRy0UXBCp0ASmbzBOLRZOoaj35SNHjrbzfa2P9DZ4B0VzYg8In/XH3jjt\nIP6b5xBpo7GWteFokDMhQyqCohWch/J1izpV6wgRdfHKqcnITWX8IhvphVIm\n0VypmFYYhGmZEGOfEQoeknpqMKmY63iuRHVxhHWA1ZjkKDonaGba6qn018w2\niAxPq9YhJfnUC3sNYFXudqngMb3TYSm80+gkJlPo0ilSmN1cG+78saibyu8o\nseJnJ2iuAkNX/qRaXu0psPk8R4Xf/7/8dCcShUDBOs/EUw8Te6WPJlWrt0WV\nmtOg\r\n=7wFT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b8011b268d0cf42ee9f41ea5502a9889574117b0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d5e13ca-1606854733107_1606856727837_0.4103382277872645","host":"s3://npm-registry-packages"}},"1.1.1-canary-4cfd792-1606983962877":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4cfd792-1606983962877","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4cfd792-1606983962877","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4ebe94c1807a791c6f8cb482dd2a719f24a0c5a8","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4cfd792-1606983962877.tgz","fileCount":8,"integrity":"sha512-BNPZXXYH1zhIoJcNXh+0UesoNJm3UNrELHZu+foIe7RuyNfq7Ft31JeHxHAXV4aXyWYL4gIjcwN7O21+AKirtw==","signatures":[{"sig":"MEQCIHvB0jwueUhqamf3z0ByhmyvcaP1UIZjkD/1q41aDIkFAiBNbsdGhYErktc4QWhbX1P1/ao1hJlV+loPEtjjrT6ewA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyKFQCRA9TVsSAnZWagAAl/MP/jT6IYCL3mdOF0TB2kIh\n0iMeBtBuMxBVpViqsMZ+Mv75w/5EIaYtRI9lEkifu7FZ5y1fA5Kr4BI3UG9G\n4t+3bAB48F3xu5WKPsRC1GD2UcIH5dhGo38+GzK/xrfXUxFh9io1xYd83gyM\nv622dzw1iyxLaG9UkyV4QHmkLLp9VfpxatdWE52BeKXq5WdHWj0ijeZHgrtL\nhbLw3l2Xd9DaH02bnT+J4IvN7fHp/yMPqU5uQv9oSWAlTCTSvdXEHYtSTXuY\nURFGPqND9Zs8Rp3XGqlGHtSdgDDqKYwfhrU16oR0YBZgezAXAAcILmJLEtcz\nL0w8Djxgiheo9lS7F3+V7e92odGdiCpfWFfmQxABppo2OfWcFhfYci29d9aK\nmjKDZV+FLpnQqzRkWqGuQsqZB0kxFZMfjawvaM+srgXL9LNEZghkYw1Ddyr5\nCPbJGjHW7ICS1bQqLP2kssYPcHbHXkInDqc5p9+owqK32LNTGRsLsxRDUzdc\nWB/FfXj0+YN/n16BXCW8tU6Hv38BPX/a+irFuBb8lA+13/+KElyPE58o0nXA\nsd+Lej17zUo9iBZe5zxMrSoogse72tuSlnJgEyBsOC0H2SdmVJX+OlNGXtA+\nm19wXlMPphlBWUWfKrkorzaL1xPP9lZ3OweDsdo2i1uouGX+8VmDfHijbbLW\nag/i\r\n=1HSg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4fb5d6e7aadc0b4f81640db175f4658c23f68529","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4cfd792-1606983962877_1606984015833_0.6648160952309268","host":"s3://npm-registry-packages"}},"1.1.1-canary-774e651-1606987469439":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-774e651-1606987469439","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-774e651-1606987469439","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"918fc7a01c118bc5a8df9faa4c1ef70c62525151","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-774e651-1606987469439.tgz","fileCount":8,"integrity":"sha512-8kU2MupPnHBEfTgb4gus47MpCrRnHu05AfFf+F/cXlOKnSvV5L+nYu4fZ1dNzLKOrkPTxrQsTlSM8Rt8h6RIBw==","signatures":[{"sig":"MEQCIBpQoTbCUHx7YQMlGPHJVMwaNvfydsOoDyBvaDFlNfXYAiA7qdzAROhKUGgoy1zFhcnSEaJPL84yaK6jMiAZLgUm5Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfyK8NCRA9TVsSAnZWagAAy80QAJ4IsfycGWwY4yYuj3gM\nN2njGCEc1DUWIpC3MQDsJT3UrWhyhyb/WiAUbgBRV9UrrDcg70Z48Mhp7bKb\ntJp8dXKbgQShHsNAXYBeGJahIrEnsKhbuCKvmSxr5LOcCYHMmJMfZCfG9C9d\ndLVxiwNc/dRv0Cyv165YLfkuFdU497b//no3/gONvzB5bjV5djIiytX1C0qJ\nwusLNuHyiarT0GkwE2HyQTQH8RKuzZNSdjrSuT2AQ5XoGosePZ5NpFx1jlR4\nTIKLnohezkog6oFAW3SjwzykzddKkVuiOt8Ugr90A6FEU8RxXRStshN8kIZW\nzcq0w/CYTRckFAZzL3Fqzf/GLQpUkni89AYQhY8BWIFpaNY0yTTg5Hox5lSl\nGu4NUwlKwLx2utglbM8VL/e/TTYp+6M0nxJJ0SeLidNwjr6AfQ/kpS+ChyI6\nWW0KuTZ/eUj5nemXn4fX5ewNhPqK+4zP/EW3nVUyZmOjA1istUPq97JjUFNN\njYcJON/0PffXI3St+CVirOQ7/heY9ylli+jnQEgZKTgJq+RkMiABVyyLVaNi\nQnEFHXJtm8xIqmfu0X2YKAanWOABXoIZ21PB82pwjIlExKqMgddceQEWu1C5\nTcRLMldYPm4MVrhUNbQ52kLgYv93TPVAKSoon0+3JmBW3ocecqPQfFwG/CP+\n9BAe\r\n=T6vX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"65940ff6e4a2c0477a3099e8f6fa1767ab3d0e35","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-774e651-1606987469439_1606987533009_0.8889703442400512","host":"s3://npm-registry-packages"}},"1.1.1-canary-ff08777-1607101017117":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-ff08777-1607101017117","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-ff08777-1607101017117","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"991c491763421fd03f4e37287d2d86aa54b099a5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-ff08777-1607101017117.tgz","fileCount":8,"integrity":"sha512-1qd1241Oe3T4cJVp2/SNJ3oZg5Da9nakB65ujIJyDGirKTJUMoKEHkBpaly4SdYyn5kp2oxitTwzXqnilvOhqA==","signatures":[{"sig":"MEUCIQCMUsUV8odISqdfS0YryJnQT71yuE/VfRFVcKThv18J/gIgNAeCkSbzXqsOmhPO4e1GN6ovIfMTAo+4DwonzMgU8gc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfymqKCRA9TVsSAnZWagAAx+oQAJAPhwO8AF9RuZpWcUkr\nZsKbHA3zwXWFrDbjorNdgTLblbIFekhl/v0/bYyzfImkmTOle9E8vdYx1eoW\nf9u/ZA/gDN/0kdKflCwpef18TMYymrQlVtdu7A+XpOniRrcqyXjS+LCBDStz\nnxyV+Asuzxpa/uXIOfLs2dwZ0OyRe1V9YSpgdAlsqdVnM0O2yLUo17gcWBxm\n6/jMFaRSZ8SkUT3Be7y0Q7627hedZnUHQ6785H8If1BQ+oB86GQuSDo/VIn/\nwHZmCkoecfwKcNZg+nMdohVUJMB4yka1S2/94uWcEgHzYYdJwzgovoSajOm/\nn8h0yFaJE0jQR+bboNbE4UyDOGcIK+LM+MdVGrq1imiWEvytp0iqHWehnOU/\nLgZopxxFpX7P1Ufbif8VUfHI1Osh6PrOWF8EAFBguUm4ijC8M609w8c5TmQs\nE3ufZ5QIe7xf8UQ39Pw0ZocDY1J3ymnpcfgj/q7xL6dRpIV2b6BnxbfijCht\nPM2R7akH9PANPoALhlzOI4ZEF2qnuifufJl4/0top5bJOyjLHTcNQJvZ+Pvd\n6Z2RJMsDnlb0gZcd7lV43y9qXUjptCxADC7d8+WPIZPLEJN9FEBw/Q07Zudc\nJwFO5/stnACeOvca5Q6rp32jvoyoyQsV8BQIDuOnbVnGtsPQo/7hsphZNadI\n1xkr\r\n=CC9k\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a75e8581530d686b1d69c0901490fce230bb95e0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-ff08777-1607101017117_1607101065801_0.35279809479887736","host":"s3://npm-registry-packages"}},"1.1.1-canary-7c136c2-1607110934970":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7c136c2-1607110934970","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7c136c2-1607110934970","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8b62fe33d94daceb11d026917b86594b247727b5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7c136c2-1607110934970.tgz","fileCount":8,"integrity":"sha512-uK3PwQKgnbMw5Hw6Htf2m1I4U1L4T/34iGYuMRUwIEfJckdN1RAcuLdi6g52356/rXXSZNw8JksbIyFxK1znqg==","signatures":[{"sig":"MEUCIEmClfq87YVipnN4Pa+5Oglee7/tDkmZlQOWb4lbCX2LAiEAriyZp2Q06+1o+bRYBEJ+YvydIOJG7htXnnBnW60tZcI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfypFJCRA9TVsSAnZWagAAOssP/2Rw7Hlrvbju56JdYZws\n5x7NrWJkmOac5zR0PN119wNZ/CiK3g8vMmJ3vA3r2OQgc7uQV/IBSEV00kEK\nObpcGMrFQYT0RCzKnbtgpoPqeXwKMXkZW75chHAPNwmQE9IcWkkG7PPg0ed1\n4z9bpxQmcAZU2GYr6xwpjEeY8le6RIpUty/Kmagi/WIRkwApSXNY8Ms8Jblm\nYov4rAU8ZwNshWhR1E/GZnMsdjGHqDqhcmwsnfQ6SLT8wGqUev5HIfBRTRnY\nALQFnsR7T5+JEGeqSPmgq4xHqKje/HKFcCbHoR8aJwiebfumsd6m5kwah0EH\nq7PpNCyviXpeq/vxAbBXNQ8l1Eo/fJlORwsvOkbS0Gwti1TAi4MVkrM1ByCF\ncPjbA+KMJnLncCqBQOi/Mj10/jyKlqbxhFFZX0jcqOWJDm5lCYCVWswBAAgp\nQs9dwklISBSVfztuKjxTr4+FowCKc4nhyEs2pA2gZiiPGqADL3DE515Kl3sm\nAEE7GKds0LBGIJT31aDzlDM15vNiPh/fhv5+R8vhNkDRD27BSUfm/9fH5Zx2\n2OvXCRY7q1oQojbeLmhlv545hXoNqs/7iGiUkwFwVBANKnwTYfYgeNDEEqGo\nI/GWDwUUqDPb+jja+v1XMbHgeOeP6pKygtFP1A5Yfn9db6FZ1Lek5aV0UC/J\niofB\r\n=j+do\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b791b4a1c2b25de5aa7a9b14e826ebd07a545cc0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7c136c2-1607110934970_1607110984483_0.6622426486096005","host":"s3://npm-registry-packages"}},"1.1.1-canary-8238b81-1607156225697":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8238b81-1607156225697","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8238b81-1607156225697","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5d50f6dc5c335b00fb3577d516b00b0504c4f6df","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8238b81-1607156225697.tgz","fileCount":8,"integrity":"sha512-9nX09n2EoNAyEXqDscEJq++MspZnV56QqW4zW7BYvUSOuysXO8+inGjOBSSl2ojPYb7rFpuqGLLqMZWW5Ra4Bg==","signatures":[{"sig":"MEUCIB47hmJipU0DWoXLgS6c5ZyCeyotTy8ZF1jg0yAnbW8sAiEAwqGYuIZYT9iXbEND70Ws6ZU1M5sYWnD5r3D+q24ex/0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfy0I/CRA9TVsSAnZWagAA1x8P/321kpxsYNc7Nw9AxOOP\nzMukG6t6mLn1V9dENkGm1mvZPHtYnfZPJ2KIdglmp/hgsGIdfOuqVPF3xdYe\nc6YspglahOK8wJC1nO9VpfzvCOFCBaybQtIVRc0oghzA6UWIfd+RwBHKpQCQ\nCthZ5B4leTUdFbuZKo7tOVPGqh05GmFyMCSkpjZA9Np9oGDRXFfJaNyCl+gI\nW4xetaDgOlCcHvvnNrF+whifgNYF55JaDzLknGfzWvdQfsRCYEihcseo9kll\nMQiiexYcY83Q39obAFbaBzkEs9wwtZQpT8oJpSe+Pv54UegY3s5YbaOXu3fB\nUItUPLmjSdnhtdxfLcZKg3EV5NSG6ZZlsRJw3oyX7tX5N3lWKLtl/hcNHqZ7\newNrSNAiH3732ijCp/4bQ34N6KFEpuEQeZRcEicaYKVk6m7U7L1FPqgY0G//\nNffDYQ4Vr6eYFj8nOY4CFvp5MWIC4aJjYkV3PwHY8NM4sDNqFKoY3TJdLglW\nN/FKdw2Dpod+o2hH7yGi+gG954oS6eoN+Yt9cI8ZWmeT+lLg3OGf8XpduCIc\nC+ZsChdooDrOAHDgfkHik0xgC+l/x0sa9LFs1LPLlESF+rTv7OMPHm5k+qaP\n7laZNESZFaF03udUoxem7yPp8T013sKdr0xzCusiZRzGw++XCSll2KlS9kE8\noXV5\r\n=whmt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f1808401fbdb2292e27ab825cfe3523ffd4c82d5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8238b81-1607156225697_1607156286758_0.5113458631483085","host":"s3://npm-registry-packages"}},"1.1.1-canary-22c6067-1607234650807":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-22c6067-1607234650807","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-22c6067-1607234650807","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1f0bf16264b9d6c74a6f452b44aed56fab43542f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-22c6067-1607234650807.tgz","fileCount":8,"integrity":"sha512-QtuCf2gq0aHJ5o8TBz6qDGARoqHx5Y6nMBQsZ8Znwsw5TttQ7Sb2Kjn3E7Gj4sC0GAt4ct2WzpG9b9wfWyR88w==","signatures":[{"sig":"MEQCIG6H157nEYf4SQtc4yR8qHWoP47psGW5ICSl4G26kTWZAiBueBy7wLwEm78U2qdqTr3CiAAN4xgC2Nm/YnM5BTEUjA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzHSNCRA9TVsSAnZWagAAv6wP/2+aKsYpmkPmB2Jgi8Lv\nnwnfmNiFRO3LRWvH4YjXXPph0DNo67SeCUxVVVHKzKo+Y70HW7p5VSVp9OTa\nBUVingellGFmsLfT7OApQ2zy0amDuQqtp2fy+YPF16V1c6bqlcllpKC2u3KL\nYnf2pBmTwDdOTLJjCE0eIAtJxbIHTArQ1/7UT6z+EHLUfaK6n4GNXIjydsv/\n+im+xsFQ9ZFCntm1843CCftGXH5udlbc6yiYH1RUgr4dJZli19wL7q/mQtA7\nknfowij9OKMjKvDupKTgwcHO5SlyE6tiPh7aFMtqrg2nCiGiURjegz9epAVr\nJkDAlfvc6vzhEFEPKKGjBJ3+u0bxxbTQq1L7Hx0f0RjXmH8aLxt3YARqiN1P\nLy3KjbelwePDwToL38favX5pgS/Ql1IsRjhiuq5s8BpfFORS+6A9EdLKG9wl\nAVgwxP8eXJHjy+MmC48uuEanktDjdGlGcIyBBG8dsTpAdNDYhJrq0x7LUc/J\ng6sXK6k32xcZRDNqworPhwRQslqDcsx5STL0FBPlafb8dPj0L/jey3OKFFc+\nh8eH/7Z3Z8PUL3kg6rWfO59hvJkB951Dz34VWJM5dCevaEaRf9atVXnlS4Bw\nxlD4t/HEECakshQ+DEQUhecCvMnwDv2YCRBnf+rXdpnEeZpbdQ1KlWNZA6Gi\nJBz4\r\n=UU7z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7ff5be60f646dd0d311bd85193fadae8593c9bba","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-22c6067-1607234650807_1607234701353_0.4049813947671972","host":"s3://npm-registry-packages"}},"1.1.1-canary-f83296a-1607405497156":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f83296a-1607405497156","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f83296a-1607405497156","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7266164c5958823e9c8f0fd993689ab6c2a6786b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f83296a-1607405497156.tgz","fileCount":8,"integrity":"sha512-U0xtCN0+V80QRN6bcUmyz3zyCtrxOUP15fbaqDYlEMWgwl/2qgD9OCc6OaasZ4N1glQA17onDfsRxjcxRBVzjw==","signatures":[{"sig":"MEUCIQD8Ej/tDmm645LGUtMeXFFvHTTDA6m7604kb4Y8cNX2NgIgUsvmlORp2jyCf3HLzAAKd6J3ewRIz3Hne7ZrbBu8p7E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzxAFCRA9TVsSAnZWagAAyEoP/3KGahrgzE9WMyHNhReK\nu+c20feKLEGsFe5nvSIBGGsBOkTu4cAk7zfk2krljt/t/qtIqUg0TLoMK19z\nbWnWMbJ9ZeM3ULD96twZU1wy0LOaSQI9Zzn2gLj6fY52qJgeC/ChhKALpyoi\ngR45Mrg1qEn4vE0lpdoHPFpv7RP3PD/2e4GQgsXvRgrDjtpgAMW09gJNGHpn\nBSIhS/owEhY+p05oJ7gLuC4Ox28Dv7xYtDpFsqEQNaFgyEOHR04jcvLrk9S7\nPQeupVNlctjSxS4u8bDdvHqSlM0J6aBW6JFZ/9IR8KftkKlJcrsVObxlyPor\nRxevWe48JsmPfTgH+F3EdCSoBYfwLaFAvGT7bMuXVwRXvMA81jzlWytl1L/c\n0mD5ZeZWzrMD1qVx6hglZQyhmSS/yYkhxYmlqZL41eEioAqsnvt5IJU6JWFd\nq+4BzvjpDsnWqvJhANmw6L6IgyKvaOLEnLGwNyOsOZO5G1Gn3/nrbSRi8/g+\nbCDPesG4HpZzqv7UZ/zF3b6/YyZaRs/qWkdjiO7s7CGA6w1uDOSgDtK4/+lF\nysu3tEx68pX9laeUmyNurfJ5EAHSKKAl+Q4GjeWkNtGK5IqEV1uscO+ZEEx8\neSrGLiifhbau3SZr+VETJ6EA8xGvJrvvsBjAUqMRfGVk5K2+CIuSzlsxxzw4\ndqQV\r\n=LQMM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"510a9b63222f016c368c3bf90a1a9cd73045599f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f83296a-1607405497156_1607405573353_0.9565778673565632","host":"s3://npm-registry-packages"}},"1.1.1-canary-7d44b6a-1607461201724":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7d44b6a-1607461201724","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7d44b6a-1607461201724","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"69fcf92026291ed2266344319550f97b95d2487b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7d44b6a-1607461201724.tgz","fileCount":8,"integrity":"sha512-CjCgWcCPaPt7SCSQY2njRMa1Zd0kHc0xMnWPEoFYD5I1BtIEBGP+adTNoZANkyHrF78+F3CAMTRLsixRuVOeTg==","signatures":[{"sig":"MEYCIQCWAN6KuoQTUdHrzy/IXMP5SC1ozwj7INSUZ2tb8mwWtwIhAIHMxbuqz4goN99ot40w8AMC+jKG8JPUfJnPvG+xbYn9","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfz+mGCRA9TVsSAnZWagAAqDwQAJdVLX9T7YOmnbPYuxvx\nto5PQohjlD30Vla34l6ShyaWg0MHAN/+gZaPhXAk08oq+kiTx4IfTiZ2PV6b\nun5HkkBHPxPrdCkD/9Kc5UddgevrHo4RyLPblfcpkpLjjDi82st5P9Jp5Bvs\nrsFLvUvkkcw+L1Ierjsk+yUjZHCm8tCy+P0efw8NRBo9mzJZoiB3D702oMfc\no5gDPJHIqT3HTchUTReKp0CaQIrq9h+B4/7gd9roxIFF/3r+Y1lElOOPkkmX\nVcssnUQ/69vQqJBac+n9JA/L+iN76K3efzfErtvvIa5+uhC6R1DiWq9pzH81\nV1b4tg2LrHX95DmBoGU5bAr9OTL68P2LtaQ1HHH8nOGX7kIXEYbO4TPO16Xb\nxFg9IYLfyPhwyaDpGrpkueYZ5eBpWxO5FL7DemNidmuakdM5G08vs+HFwwmA\netciPJrJipoKFj4in33vMOY3ySZG4VkdzCVTHecfbCtBgGX2iwCkKcEtW9Se\nLFtr6x24jcBhSGwy5Hs1z2sAA06bEJ5onSWIpYxm0KGZ0TW0LTOZy7hyvfIm\nynCS2YechyrdojnuIL8gyXy1Mr6SYZcDERW9f5QldAYnctHjz6JTY+TsMKsA\niHS/ZnvbL9KUkR6SCyThGvb88/owaDbAh2JDtWmpak5Xq6/oU52xXWVee3vy\nmV4F\r\n=DbAO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d10ac4a955e3870df700cfe72ba09f087e569b45","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7d44b6a-1607461201724_1607461254260_0.241948806792321","host":"s3://npm-registry-packages"}},"1.1.1-canary-3acb49a-1607621541645":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3acb49a-1607621541645","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3acb49a-1607621541645","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"553087a03a684cebb4cc4ff1407401c7b09168d6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3acb49a-1607621541645.tgz","fileCount":8,"integrity":"sha512-geOMcWmN7LU2ULqSyudIx+OQMmg+8jkkDWccH3taRvGXxTkF7zqjiFM2Elqui17c9lW7ockiC2eYLQRAyxOAwg==","signatures":[{"sig":"MEUCIQCQ05oMSMH5OnfnLDP8EMLMAWC1XEp6/+Dh74xMhLR1PAIgMWCF9RxH80iWDCausEmkVJikNTwEfLBTXcO9yF/O3vA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0lvVCRA9TVsSAnZWagAAToMQAIWiLE8T1QxBwzCygq1v\nl9hnrq0uJwewUf3nq0bNu/rLDiYvu+A6S7mkCha/0/6Dabac5PSap9znER8H\nAVJLXlxj9raZAQwac4Cpe813+geDXSaffZeN8rZ4zY1bZRkuWEIqWTOcEAvi\nwVjHv5U04cUw0MDt08CN/Ykl/sqZYxsHiVs2xHVKZvrH9OXUNFTHV07SzUnp\n6J3aLrdJDIYoaxs9z0m31z8388PzJRP+ozX5+crnBh65IONsvkC6gGTnVQJb\n3FZ2n7xf7Eh4ZZB2TLUG8DklwFAm47rvUQWGpwUTKsvrb1vdb+k2hqJKDI/4\nTH7Crc7q7Of6fD8OlH2r2BSUeE+NRwmYtzZV+AeoZVpGMykBsU7AMqAZxw4x\nSl/YoeARTDm9maWjgNCPO1ndfLGiVxAI0CStxkzDcj0IQK6nUyfhdlWFi16S\n6fbdqh4QB7aMtMNi3djXtffWM8sVxDSwEETlxOWgAR4W24U8JiRDu1mjXgG0\niXC+UJo2W7DPMv0nqqiRBuOECrWmPwEEFK8c3ZIDBY9D9INjpy424JrDGz89\n1+dwpX+Ju6130ToKJUfCpaQSpeKsHbWBLhXNblJhGl+ZkylgDdvcLryNT8Ke\nFMVRW2a1PjMe9334QACBQiWm9cEk4kMW24JhJk8SKgB86Wl3xm7LlNWh4Mdf\n/pdq\r\n=6YVB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e36062920feabe2f70fb540e09f3031866e7a117","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3acb49a-1607621541645_1607621589247_0.8485670337983608","host":"s3://npm-registry-packages"}},"1.1.1-canary-652729a-1607640204628":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-652729a-1607640204628","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-652729a-1607640204628","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/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"25b16fcd93f8a44bdac37b49e46cbb85eace2c52","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-652729a-1607640204628.tgz","fileCount":8,"integrity":"sha512-3ujf0q1qsR7QIJfPtdpk9d+RALM65gMIi3yKkftso3+UvAzYS4nefEJessFwyzCQMSn+bFpgrHhK78Rk+udqqQ==","signatures":[{"sig":"MEYCIQDHHmFag9zlaBd6F0ptHpkqmgYI8PvmsX42v3SnoH6fSAIhAPrVb8h/sOM1HqQlL1FPFCpNFMWY7M0oPN+S6XMIHjHU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0qTACRA9TVsSAnZWagAAXYgP/21HrSKvyshYOjGhCYV6\nlMovAqgmdrI5hZeHJf70+ZaBjOFrnGdZlfd10spwbOzBnFyT93f5/deEU9ts\nfaEI+rUpHoh737jLFN76FmgTCFfcGwsrH0kwIKswQQVHLBZ+9SRqLcINwR+K\noJSZEymABwcjTnicPCgsKIy0j0BbcCM7daOATsuKCqyajV81jdB3Xll7tntc\nJbqolXlPKirMGDq9yvZj2cQrlyPocKmvoSS5Iyv/qkTYRd1X1OPQSkJ+0WUQ\nnT0nna/rZaMz4ILB70R67CIp9SCCAaRYM1c1ypwrgBHkn280DbIH8ataWcmT\nhd+PbIqDjoKbO6ETR+6DbCZuONtNSjOLWKyIQdR2JCvqScElkRaao9mwoca7\nRKM8mM2AdIvHDE70j3s5d5mk61DeAG6EHO/Rya+9LV135wY7By1z2MomX8cS\n6UAQmKWsBDhGbk27FpYLpWIGJxWEFELtuIRmuIfFyFFUtHwIvg15sDr05hAX\nBueyZTLpTw7kj2WOiCpFUOelV/qGiris+UW7BKgGjR2spT27aJGWz84i/L8P\ndfmNHim65KF4Tnav3weq6MocvCeNZA6FDqf3O/m/XFtC+QXzKEcBj+UdktX7\nT5CegAmBkG1sk5rOozWHxKOiorZ6vgUM7+j0pVLRp8TbnCnoztPbhYiQIral\neN70\r\n=QyAA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"240827b81278d6dfb363681a067785a0ccc573da","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-652729a-1607640204628_1607640256116_0.507648399730827","host":"s3://npm-registry-packages"}},"1.1.1-canary-3e02efc-1607945336112":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3e02efc-1607945336112","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3e02efc-1607945336112","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"da0c32181a223d57689915c6c01fa4ee1ad52981","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3e02efc-1607945336112.tgz","fileCount":8,"integrity":"sha512-JoyRzpcLsGXh9tdJxzF3rXMmXkJP2oV9gdI7eA0vOkFrqvxpGtmF/5nzrXnp+f+3/QhMGdju7FZiKSIdCVJQOQ==","signatures":[{"sig":"MEQCICZ37ZtNm4knf2hPIkqsktUB+fMlh3GvOO2N4pwvDpCzAiAhu6qX6nUw3GjgLsV0NBMhFHA5A+Qh+WpWPpGOPajRHA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf10ywCRA9TVsSAnZWagAAHTUP/jQWVdeRAJFcN6ftKkoH\nh+zJi2g3h4jv7tjLiRcIrK15JSNu5VuWfQnJ13gMIvw1XI7qHEBnQsqiDNah\na9YdZJFnFrV/E3iiw4gtxfsHiFx2m3WtNxKp/9/kddENlTEtJ7p5VVWpcMNY\nqVQXqsEIxXCyRVQppl4FsSPfephoIn6EnQUuxJ60yRn1xZhieR+Uwv45WncB\nDJBcJa5BP57aL+MNmbnBUqdu9hCd1I0c6dUesOYeRhnaX5lET/jp/KzhHLza\njuSS1H2rCHi+EHIhXGRdH9DTQWe4vBXLFTulUhKVeMHSlpPZv8zCVNJNpOWG\nanvSotBOmNQfD1jiQ/Ffzy3+zDSYKQt09Nkzg++nYNIz3YFwQpUZAZzAbRxJ\nPUH/pq1rbWd6a0+St44mfE0KyY//MS47mxJ9e/FA/s1FwwIqFnOeVwPSeQ5F\noHcZhR8/30rFPq+9YjZuB+C9BYH3/XiZkFa9aat9HohpPJS1Y3h0RJDEbN+Z\n38goj9pKhLBCXa5fRgYvU7DGDKiJVd5uUId0dfRBnafXRlb1tR9fxpx0BR9+\nvZes96M3He31xS6C2wEnOxzJg3tQ6ogVWQFGWYCt3JhCqia5lxyYmCdAeGaA\n78dMPguhv1+EDLBJrG4hgfsRh2wa4u7/APGr3FrF7P3d219M4lnZ3FPQJrPX\n+UKt\r\n=i/5w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e8ec383143334d30b0b86e3cc855d790115e8ec5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3e02efc-1607945336112_1607945392248_0.5999700997560786","host":"s3://npm-registry-packages"}},"1.1.1-canary-79a8292-1607957934328":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-79a8292-1607957934328","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-79a8292-1607957934328","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"abdd4465d1e5aa8bc178be177ccb15c5c1b0c1bc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-79a8292-1607957934328.tgz","fileCount":8,"integrity":"sha512-ACnSf2uaF3RAelLA6tREgZ45PIsVtRH0n+9uZaiaJlDtdGpM1nB96TeS+RCW4FKoNiQeKy27yjlE5chSfFfGVA==","signatures":[{"sig":"MEYCIQCVQYpTtakzvknSS11PxjTqvilnEk5HIlZObOiLQdSbBgIhANjvqrKTFZdPFsPZpjM8FicbhkTchlSN1iRyKy5pTThk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf133iCRA9TVsSAnZWagAATLgP/0qWsdB2jYb8Ql4K/aW7\nO4B8ij9pMBOr27a54t2qhtmyjRxtUc6VCQ39qUqGWOwUrTentmUDBMq45XjG\noBWyBwgrHRnZ6JLqINcdtkQA+WwtX9y0dd9g1Cw3M2cl0a2xj/iDsZzOpH9B\nG2+fkHmLfo+t8NC4fMJ6fxMQZjjJAofURAqBHpYYfSp3LjSEXy6TPcamTuQf\nfZRPXDfI7L/V+vxhzK6GtI1Ftbj3z/KgAbte8+kNQoYUhWTmpGVxzpWh+NXw\n/s3qcNv2I4lwfpj8e9eOe6Lx4JwX9XxV250hqja7xUa/im661ascPB4bW/cP\nsKh9MfWkNRZnvu7faPFsUwaLpoLTibtX7hHkhK3ixgxHFJfBSPeoC+JqVcP/\nYr6EuC9FcgpGPOILG9s4YDBYlBmFdUHxcNfGf8Z6Pgy6MVCjSYzF+0Xv+PUf\nXnygfWhuHi7g6N70NqxDmUMZNoI1JDgh6SBoEHNKTw264UpTbHwn/rPPqMoI\n23iZQ1JHwraTWatp1JQ5XMXZK1nKJyu6jaq+axkfs0ygN/RTgdams1WoB+nw\n9NqmYOryROU8s2V/NPt4TXQ/TrgQjEId9+tdIg0itfJ9Kn5eO/64y6tATw8u\nmLXDgf/mFQksMxq3ygll9XbUkEusGJFbfCWeD+7c4Z1lt4cOwZObDri2dM6m\n+K8C\r\n=p9LP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1b2e28836c32ef6a280d81156f1cacb671eb8d9b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-79a8292-1607957934328_1607957986511_0.23450043097778894","host":"s3://npm-registry-packages"}},"1.1.1-canary-a4fd5dc-1608328910278":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a4fd5dc-1608328910278","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a4fd5dc-1608328910278","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3bed07a7f242014c98637d17a64d0297a2dc56d5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a4fd5dc-1608328910278.tgz","fileCount":8,"integrity":"sha512-JVIrgGEmeszX//0/zLTfFxDWfRI8yYMIvxruFdr/EyexcX00T5qj+1XpYufAs+5xIlVTWerAUaj7Rbo51IZvnw==","signatures":[{"sig":"MEYCIQCbjYHX1blLJIokPv+lPsj7z7UvChYN19/luX0JFV5pawIhAJiTbM1n0+g+g0D7IDV22dFsQKh1HVfG+p8vFKEXns4c","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3ScUCRA9TVsSAnZWagAAlDwQAJ7EDLuixjVeP1bwZv43\nIyn06+2iqMaupU9s7MbkGhGjieINs+7Sv7twUPA2UBLpCLvZZkD42h5LmEIZ\niAzxxx6IuT7ZELBFNCFUjr9u0KBmJZEMXByCuz0EZ02JKwnDh2hK4ZvV9MGY\n5dVfydPYChCvWwPnCFHiW9jgMPstLz7Qd50IX1MjMJs1ioSfdmrFezX1Djsw\n/1SVY4BpxL9iR5tSfsf8ccoLu8O8AeRnxEd9ftHLUsFdyA+DDSIyaV97DNfL\nX1PaID9mKZ8jZdDfJYqUnW/fxdqWOq1BnrpXnTVW9MArBLv61Zxv4NojV+Ge\ngD3YHb5BuaMiaBd09EOdJ4xhaEBX8klrLzCIgXtAObaMuYMnsIbkgfOHsbL1\nwpgDrnN8Z47y9XwMdV24t7TONqQ4py1X5zqKHuAUJNEFdkzXhGiiHUJ2GS48\ntBHhbJq1HHBf8Ponhdq7zROlN3NYM9JtLKpSdRV3hLou2Qu+eBt4T030g+C9\nBGsRRy7xj2Uyaz9TQ3KrEFUpWtKo3kjOQTYgSDKAK/pzG/95CTano1LXdYvM\np0OjrWmnaG5SQUO36NmuxBembzLS/s2Uvyu9vmqyiuuHfsE0se481XQ5slWP\nQzW56Eag9kCH3hHXwsTPgwo+jYLZUWfhpLVtQ5W1C9j6ngphrY5B1YXgzVVD\nIlk9\r\n=0wJu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c23055b20b40e53f5f0af1ba99aa494284848e8c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a4fd5dc-1608328910278_1608328979789_0.8289910950904325","host":"s3://npm-registry-packages"}},"1.1.1-canary-75fe0c1-1608570061628":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-75fe0c1-1608570061628","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-75fe0c1-1608570061628","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"118b2b418c8b0c3aa14b00345b2403aa9b5fea08","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-75fe0c1-1608570061628.tgz","fileCount":8,"integrity":"sha512-EINqDoTQSuMO04laMwg6dqPxrvxpAv0Rq+4hSe2u99iCVdZMZFWKIIYU7cOiTmuY0xP1uB3bj38noSA/R/cW5A==","signatures":[{"sig":"MEQCICqFS8vVDWAf8AsnQ2ohCUUY93ag8ggwlqEA0VkcbbnjAiAebc2q4F+9eLikQzWI76rbZ/MI4s2tinsqo2+ZVR/0SQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4NUCCRA9TVsSAnZWagAADbwP/2o4+3ctm0huE8b9jE0Y\nPmDijGCJNhI2f0v4INSRXkFcwpfnRhhYfFDrkZ53/ro3jGXVT6AwqHgd5pU5\ngYqcKdlGnMxk1I8eMGbT7A22aUryjf5HfpH5c9peyfu7FIeippjlSYSPyvxa\n7Y9Q4jbfbM0gqZDpMT/B6XC4siTezYXM69McH0/2gQrvrcGiqS43Wb4tdTci\nhEHyNu9VMcExMPs6BrqZVfFKz06N/ZaDk+YCZRSlNHC8zNiE3KGuBSAMhbRN\nBk0EFDSv6QlF+NWm5JG0UDsUcgQToMsMkjbfuSP5M5dski45+Ww3G6A3DvB6\ngtOO1mc+8NFmylZE1c53XG0yevduRIEMqPuaZJHqpDnnVPIOW9OSIfTEXM8A\np2xibiA2P897Y6/H4oowKtUamT1qu8FkqXQBzyYoDwlkt+M4mOX3+IRavaT8\nJ7tuW4sv9wPRJuiU3iLl6XioeDu41KkHz8H9t0JtDfGZLrJ3+cmhgp3G9xRE\ntMTcw5rY5Mft+L4zrYu8xBP5z8rT9nW+6A6/DgrjEcr6u4DesG5XFnoz/SVB\nuFoneeii+Sgqlu83wZsPX4NsoC1178Pp2sJN9ZVqaE3bmCoGOjn1XiRWefKW\nArclkJ1dif/kHd5AZxxTjeLhXq/75OxnrdneWhQHHWsytG9WJ23s3QS9khs5\neynY\r\n=IiQM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0c44d0cd1277c63c93e8452c1297c9bd415bebd7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-75fe0c1-1608570061628_1608570113907_0.3316231549755697","host":"s3://npm-registry-packages"}},"1.1.1-canary-2f89a18-1608640866496":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2f89a18-1608640866496","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2f89a18-1608640866496","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4c748b91ae0692b6bdb07bef4a97a6340d5a15bb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2f89a18-1608640866496.tgz","fileCount":8,"integrity":"sha512-r55bjY0EZBbEprZjn+sDgF6sz3OCVSl44ifbphs3AupXba8UuTeb/9pUbeTCZsHcSsU+t2mBGyEcwLav+xgNNQ==","signatures":[{"sig":"MEUCIQC7O6zkQkTtec5+HFIKDlrBzm90lANOqCTD87PbwaeCIgIgMECO+HnINQGxffsxBugQZsKw/DwMBJ2azLAGRW5xguI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4emTCRA9TVsSAnZWagAAY+sP/jVMEySEEmYugCguYYiZ\ny8G7/qD0e/DBXeIPpQkdu0L2KTfKP+D87c/OvucVSBypKXJGoVsBaDHTfP56\nWGbFLid2/scvC5hc/nJAfnk6D+m5N6cDwklKC5qVeAlgZcbksQiAxWrMgTvn\n3+cas9MM7V3gKNMgjmWRTGK+2DMcuPgMDFBaYox1asZnyRjMoKCP9xi/ZGY7\nDvZcYSHZnaLwFpGYakbcsYPIycdmhMZZR+9m1GjAugMQ3h5ftR9Uy3DE4c+u\ngvJUIXXPuHOwHKdrozwvuiIJPq9hUspmDdlPz46VM4/H8OQGMshDRxGADQqI\nhiGegoMA35XEsWS2k4yJ0PID/GwfGGTn195ie03kWepB152Z8gSks0EgyM84\nRukJJOkcOdX4G287KfyinSw93LwL1FDY6ZNEWmCevB2MNlgP5fB2lbJQj5/6\ncoqspJBeVhVXkR49oglYhVz2QVoJdLkhVwUzmWD5b6pH3B9n+NlWogXkdur9\n8zgsFi6k/qLCsN1U4chs4nmNH9t1VJAf6fCn5XNe268jRmfmcyaY8saTFZfq\nLSRIIwzWGPqQlGPtY8ySym1rIM1t/idkGgD9UdGviyVR/rWLppusH/8TxGpb\nRynS0cuG7wzOkjJPg3kF266SaYvZgjU7m/Xe4OD4smUL0giVXpvmSV+anUBg\noc2t\r\n=TW4p\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"930b0145666923aaff0b2a3cee73066a38b1a8df","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2f89a18-1608640866496_1608640915127_0.38981172085134985","host":"s3://npm-registry-packages"}},"1.1.1-canary-6b8a2d3-1609181466168":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6b8a2d3-1609181466168","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6b8a2d3-1609181466168","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7917fd3351f1af3897d06ad39c8ee95d3cd1a4e3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6b8a2d3-1609181466168.tgz","fileCount":8,"integrity":"sha512-ySgs+ZY1aaJrcDhZ8PzPLZ3YW3DN4GKkzieKWPO4AwDKX6TkV8pxSxfRzIKty57Pc1YWlPMAi7xWX0C3OXdeMQ==","signatures":[{"sig":"MEQCIC8pe/7+08j/V/eLCZtL0BT0t/arw149a00ajDep1XbBAiAs4dznT4gI9lYU73c9nTF7AaMKpg9jh6411rkeK/3t7g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6ilNCRA9TVsSAnZWagAA0asP/043rePJCrp+2hAtZ+96\nrYTzuG6pI57pgS8AkFId7rghxpkDsTtpwp4GKf7YXSMt5+NdC6b9+BGBNXfF\nDgN6/7vGqcsvaURCqovbZVidP5f0/FRbEtfj16ORUru+Y2ZKaW5qmtPF/fz6\n76DEauEKNb3H5QZu79fzPklIo05/0D1B0/7F77yW+z2OPwn0D1wuePVlJQgK\nt0GuD0qJRPNmi+YN0V+z4s8N4BLb6hOgkCi2LdUJacR5wW81R8mOULD1G0VH\nwgdg8z0cT+Hc5qdOTAJPWE1+/k8+FqNdRwjOQSlwVD6reLK935AS6Jc00hDP\npkCKb4YU5vAdnknT6KQxws1tUxw2bTzpEKmfDme7xILP0uqeA1ncFB/PJQKf\nmA6H6er1WWSu5NIPglOfH6I4w0Mj6P+O756qcNuLri9Yuu8SW/DHFKENYUzI\nKTQ7rRevTAGNy6lgFtEZr/lbmsNa4VgQbcFgpX8lkNThQDZmB0n6Jvr4eyhW\nJaYO3UV0IhnLDI+bzya94xWbmHMeiMz0LzCYLLDa2DQfjL4h3F8jEaA+Kb0T\nDMRgM6b92WLLqllqerCt9uwLXNob1hrzt8bkep68GilnihnFNnCJOMK89WVH\nzE8uQ6F+iudGT1zQOO7VSegU3w85vy2ApMxXb2yO34n7IT1IWnNC4J55kc7i\ns9zF\r\n=pMHK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ea29201537d3882e1076d2991d126c70a977c887","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6b8a2d3-1609181466168_1609181517457_0.6355362107330405","host":"s3://npm-registry-packages"}},"1.1.1-canary-a6e6695-1609219825812":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a6e6695-1609219825812","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a6e6695-1609219825812","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"85ec5dbc2c6b7537800d71a792bfc4f6e9910b8d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a6e6695-1609219825812.tgz","fileCount":8,"integrity":"sha512-WE9dI5P1Aidi9tLjrBE1RqDNhck6KLnAWgxVJg22UMKZIr+9bNoPDgFOkWP44R5DethmYJm4OTA23NQhB5qhEg==","signatures":[{"sig":"MEUCIQDZuXZIkTkzvJhKkvuq2VZ+Y2BvchUryIG0BXtnJCxXRQIgG6/Md06xRh/j58+YDYdoO6LkuQpSfayC3HpbpQ7rcXE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6r8lCRA9TVsSAnZWagAA07MQAI1TBstb/k8r6jWJ84YU\nnXi9xLdiOxzn4Zct5cNZG1MPfUf5SmbfUWY4S1xB7Z0eFME3twexmgG5c5Zc\nvm+6PTfzbcMGjJldrpN5b82a8n+tRTaRqEm/vbwSdKP4ekzXP2ZON/kuwC03\nbhItDfc9JzQiN4mQ2GaOzTLBsfyBG3j+Oimj9leJ1c628369sbjESbM7LEhh\nPeH3Xcru+o3xKS3+zp426H3XrTquDJVpoqwvu21JcyjboyWCrzew9guDXaVq\n1YkS+LxclpWrp3VBHn0kI+xhuI7WSQcYSYvKlpmAn20hDp/sOLtnzA+XX2E8\ntcoX0GDnTS+7GXDwoaHL0yknCgYMvjqSL0aqQ5EHKo2363/yG+kHICNliTSf\nJowyGfpIhWgn+QAxOUKs+ZSM/AdvTDzUBBAep9OvL9IKnw3X/rZwHoqvTI/J\nxM1e5zJfmB46RKB5CnceS86i5Prm5lfF6wPH+8VwvZk/FRx2vnqNRmUN1kTk\n2+Q2svtX5aBZOhotjnwCbvxtgqFuKFmocpTcDYPllwPKeZVG4p9QQMgKPV0D\nS8llwDXQtNQjRC/UQoYceRVdUsAHNhYOT6JwkSswMGfKgmiT+5cplKbfpXXe\nk15ildCC7yCEd5N/sLf9mTIYPXYnFjn9MqxhoHuyXsASAhZmJ0EUayG8BYAR\nkEQ0\r\n=gl+z\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3f0a5b844a59be91c7dbe273d26381b3f5efe5a3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a6e6695-1609219825812_1609219877292_0.8920102463547888","host":"s3://npm-registry-packages"}},"1.1.1-canary-51f8eb4-1609264766305":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-51f8eb4-1609264766305","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-51f8eb4-1609264766305","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e654abf684538f460bb099141af3b5c7aca2b01d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-51f8eb4-1609264766305.tgz","fileCount":8,"integrity":"sha512-tPMUy1z5m2TulUo+/c9TzlSSJA9Jw15sZF89tormKZUNeq0aWmEldOTDYcwnrjK/p14MhTrpS38UxUF6EX3xKg==","signatures":[{"sig":"MEUCIHJHFUNdmgBsw2xrtYQObNcmZp3N1Ip5gMgijfCPg4kPAiEAl2rURoE8m5CmoXQM5DXXR+v2uejIPbog25snPgn8qj8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf6262CRA9TVsSAnZWagAAqz8P+wTpgS3aDc9U/sy31xQX\njQKQQoqkHyLceXvUHU5SNrehBpyzDXxkgNxRtqR6fF6LGoLCch/1clMuc53A\nwB6yFjARJ3UqdejlQW9v8Jnq9h6Sp2yqv6FI7Wum+BfAFQeownyBybLBLxUj\nqVpI3wG3+Dry+rEuH02gTatKZKMOT7HSKKCEbuDN1YBw+wc/mGvUDL7WVnUM\nU97fwuE4itU+Eq7atUIR4bUbxs2Lcpj0ABG1dWU/UQ0jFNTLT7su8gWFc7/I\nGVcZ8RVnuRF+I79sAg/JjQB8M27zPDUUxWT9x6AwoH0/2yfT/pGpwc84bpmt\niJWZdE/W8bOe2fV91hyBpBrvvcXQWRdp/JCXwk6VwrLZ72B3Gb9tiZlVMCXx\nvkzh1+OceLZUPAcoRNOLEDbdAt+9jE8RVAf7e6aLIduR+XBbUkll65cRVg+3\n3Gac+0A7CUJqlGjpdcjELK8vaLOkzmM9yt37FtXvySc2jwR2Xr3pH1Y+sHtS\np/1xr5DE5BA0Eb6v0LAFI52CLNDkuFOXV9LHdexg0wixORunwlUyGhZK1Rpu\nwdaFt/qD3gOHg2rto8wrzqSvNF5F4wtp0NiAIaWGnoX3e0X3H5f7CUrbc01q\n0MyHQ8YbhH43dLmEBl2ZmYDrciGQl7A1feXRIpUI+815Qu1pa77m3X1LYveb\noe3X\r\n=RrD5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d3cfbbd000e74e7a5f84a760e0cabb36aea9207b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-51f8eb4-1609264766305_1609264821811_0.22187623270271217","host":"s3://npm-registry-packages"}},"1.1.1-canary-fba59a0-1609272409690":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fba59a0-1609272409690","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fba59a0-1609272409690","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"719aefba976b29c061676f5e3ea06e6866059147","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fba59a0-1609272409690.tgz","fileCount":8,"integrity":"sha512-Z0NWpulqUsoR64369U7TUnwhSG45UPGXZmuZDzXYW0DaBBecQgLAU0RdmApFefGH6JskVF77ddxjUOMeAusWpg==","signatures":[{"sig":"MEYCIQCc+roialAtuboASsffxxuaasmrsMFSDQB7YswpVcQkbAIhAOSiGuJg09jes31dRfbTRbnwQLSD8eyZy2OTMfBUEXFr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf64yQCRA9TVsSAnZWagAAEe0P/RzkjgoplQTNNW8E2iXn\nSwPvSSwrQ+6TppEtSbgSZry/Mh/7JH9r9HC/L4WODamw9sF9QFCtT+OTBFzZ\nnerW2ts+35dFd2ufcx6aEhLGRBiF8On1pCo6htPrwKaXOlOYwAihbvqLd72q\nRo6+NPYGCAc7b5cqJJ9AGZIPCopc1p9cMx4QCpD2t4B4OmEIbxNvsCmSM7+J\nw06tbA0scfj++61u8GbrtR/c8mmtMuQQqqndQOca5fZI/XBwOKXlAXdG9Wlv\nNXBpc/FyMRm0mlPoFj1rsruCtOJoCosLH74J6KlYDkX4IjuYVTkExJUZUpYk\ndkYPmpnaLGu6PRciihpK10TS0nae917wRjdzZoGHLhQV4zbe/NY5L/wtRVh7\nPUn9Ht5GmeG++N6148OY4D+rR7uCWUYrg/LSN7+3z0/q8H24y7lbSkPz1i+z\ngEXQGE1rzNqHzr3EM4O33DNicdlipvEgJVvmS+wuDkFzOX2J5aciWA8OG0UP\nsD+WtGUvDqFrWjs4sJw4FeUOwSJzNFl68/VF9UCPTKWGjXIqGFmtAVMtJCGP\nW4JVqDBt2H6ed3iUNC8Tc8t8EgnqyuCjxyF5A65zOIReIS9hzOYtF5cd0IuL\nkpYdWIjDKgFq6GGDx+OdaomZGtDw6sctgwxUnaL+F5SjMCe8nEM3ls/f771P\nBcEq\r\n=L3o+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1d347ae3d66e197b09a554489532229ab2e87f61","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fba59a0-1609272409690_1609272464334_0.2829935143005302","host":"s3://npm-registry-packages"}},"1.1.1-canary-a0004b7-1609286724879":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a0004b7-1609286724879","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a0004b7-1609286724879","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b895005bdc7359cbcf43cce52fcee52e8d7628d0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a0004b7-1609286724879.tgz","fileCount":8,"integrity":"sha512-CVTRf8RRcw5sf/TPwd61U2TH58duZnVX0m9s1qU1ShzrKbvkuFSoVqU77BwA5guX2r9I6ba8WPJ59X8feGm+4A==","signatures":[{"sig":"MEUCIGDN/3yvlnvJkkNYW13Lclh+MWHc19zRgk9fQy557K/dAiEAzd2n990idCLqmLqOtGVOn2g3xaXMZUPwXbrFU1IhbP4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf68R1CRA9TVsSAnZWagAADuoP/RXqKa9E09T9urvfsq9V\nC04h01W+wIanFER+coIWmm9LmUiScZhLuA2wcAH0Hs3WjaYWDYjlPT3f/f2J\nFb941FtbOMsTYWsWwXHLkKL4t+r5xh8gkUN0RjJFSouRrf7FXG7k7WFlnvfa\nzeLgfbVUzW0qS1GIEujHU7crqfoh1Lw3hPnGdetjm0sp5+BS5LFzsGK6pQAk\nnTztn9WpYclAL6mDw+5d/4UidmvMRs/TzAcIBmuat+b6z7ATzxiu0Ro1CBCS\nEq8DThV0zORXiNvJrWRo5vA2k4uyw6UJLS01uSmbRQkZJz+HJbHTFaXlG+UJ\neFPWgy7ZN7chf9TA1Wh421H/sQI4vpfIgXlDDi9+LgUtAsgqyxm/jBtRuR4g\nlVBObc60yXz9a3Wrs1KnQWl8HU+UBA2PesT8Q6lEywqp6STKFKjwLyFHESQ2\niF5GpRq+o9gYYrLx6SfoelAaKfIXCGJgVWnUw0gLxAkaYiZQqn/jki0tNBgm\nGK3jTYl6LUY3Vht461NtkqBsbRhNOYiWD77h/JANWaNQMmOgCfZfTgsqC7W3\n3q+vwrHj0bmOqSSs2sA4TQY8ahH/oca+MjLHmQSL82rfCndvY71z7zw51HJN\n+lZahH3PeXA7Y4FIsgP19WwYkrtsagj6ES3r30yzUKx2B/oo8Gi9MdMf/lp7\nYQ9i\r\n=OCWB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e0bdfdb6a40085c7be33f03de0a39012e0699578","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a0004b7-1609286724879_1609286773441_0.5617704405165642","host":"s3://npm-registry-packages"}},"1.1.1-canary-afe8853-1609363184528":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-afe8853-1609363184528","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-afe8853-1609363184528","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3876423147f678252045939b8ad8d02b448ae25d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-afe8853-1609363184528.tgz","fileCount":8,"integrity":"sha512-tzY9D495Sfd//s8jgdioS5zgOuR4bO4BTEPgNysJ6RSWrKq7yuXCjtg8/MQrQCVqGn/17+9eSm0yLigwEbdGXg==","signatures":[{"sig":"MEUCIGVCIF4AnPeU8zAqauyPNgjEY5oRLSs48kn+uFqBaSFPAiEA5BOGllD9EabCjGlzDD9iaUmm5reLXoIo5HvYrxIa6p4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7O8jCRA9TVsSAnZWagAAvc8QAIHTwBjZJ4vNML4S/yLw\nFHfLLPTnp+ypjcxW7l9cDtzccpMTTPl1YYCoIV8lmerINEsVlJcsWNFdqIkj\ng2APbtc2vZ4VPXS9yFbsGdVJ7cP6xR2Akj2721Xp7p07SFjDq21fMidFpRb4\nn8C2A+wITGC4ncP/fIguFFRM42jPFdG2YwuOId8MzQ+LGSFYQimyV8UKJ3VP\npcTwBMdqtUbliLE5T3op6kAWzW53EUziemcFjPZFROvsh5VORtyCq3R+u/dO\nd5AhnH5RaJV3R00f3/yCcWlk+wmqC3qF/dhcIO+Xm1o/ljnKmQTLgAtOR3ef\nYMT/b8HKk4C5MtctZoPffcLwGw27zArfB9rIUla9Za46al+EjudMFLjsgr9r\nQL0wypzuZZFTTuWwdvxFQBqTfcYNBZO4+OZzcXFQYY4zFuDMIQgxcxW6hwYi\npaQXRLVAgOtOZI2KsotI6yaWpkv1J5H4VariByDmOkLMpQa3M99fZU/JA5pk\nr7KZM74jjxPmLoo2NSXPatZ0zRAuFi31HpP9JKfK3zVOvLRCmIKo/CzkKdcJ\nDz1xffzmSimNv9RFVLyKzm5rdqZkcLhkq+bOfbddPCQw+qF9+3oZ87CUS8db\nV3M3WKXB6dP12c/Uko+M5ChTymdt6BIQwFDxwsmvZWpHhHW2wcRKKIHGOvR7\nO9ga\r\n=l2M6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"31ff066b10b06eb7f2073f3a2a17313ac3d129b6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-afe8853-1609363184528_1609363234640_0.27198797279357856","host":"s3://npm-registry-packages"}},"1.1.1-canary-8b153c0-1609465237167":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8b153c0-1609465237167","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8b153c0-1609465237167","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ba5f6bc32823651c31f0a47678868a50c83e2b72","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8b153c0-1609465237167.tgz","fileCount":8,"integrity":"sha512-4qdknGGH/N7m6UonBs+pF9burtxV9IZW3PmZhSsP5clwR68YX8OnHUecan5aMufDyIUybMdTMyCcNG63RuwaXQ==","signatures":[{"sig":"MEYCIQDNU/caEHivy2dZ0tQNUxUVEz70xbUdyGoPNvfpjlvfqAIhAJYXr1HQICdBTqrbUcTukzd+7bVHxWj/utlE8B/pxpza","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7n3LCRA9TVsSAnZWagAAEUcP/3G10WyhfwSAtOU0IRbM\nueXPGe9yt2kN6FwVYu332Dx1DRCrxKs2Ks/6URpRSwo4QF9Z02IvzDozaDhb\nHGJZ+y44NbjmU1WAlUE3nt7o/qjvhGQ9YIBAOMJFnekkDimJ1J5xwdSngHbz\nT+15SfYO0BOwm2BRganaFqWcYl8lauarpKt9J3RVzngVW2ZQsIPR3CDFsMVy\nB27Eh3dma98Ku8ZZw0NZJjliEtAdTQybvA9PxF0guRbX85SN1hc9QzcnXU0I\nVOrxIEPtMeoZ/9fIrWNFjvTFfgFgRT7J7Emn4HXKipUBfKSmwRUFmCD9dVla\nBe8RiE8s6lXkbSJ5q4nZaBPAKjHoKwoFbqLkDpVVZOTfiOil+ssVRws1aqe6\n9VJxU9sz8RY1RiyyZRo6fSRRs1V1w+MOAIHfw/i6p0mPsJLG2bgvC3Ftt4Do\noByCT8J8d2ELQIsZK9yHjKXq39bbOxatuKfYm1+GFYHJSnttmO10otM35Hzu\neS+/6RrhqPsEBJybXvBA95cul/olumGo4sBN7S9HeLKbq9Vhl+Rw5ipPwRKH\n5HrOGDZEvW52SqDDmEAwZ8U+z9wxxyXXziRfXFivJ3iSfYE7LGjWri00qEEH\nUywwyLFcnpvnDyIFpQEVfmrTTL+yFIMwlrjX6bp6jbW+bx/I5U6Dgq0d00XS\nBSr0\r\n=YA7v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"aee1143030442d08fb135f40645b1279f65d42a0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8b153c0-1609465237167_1609465290806_0.5817680035248154","host":"s3://npm-registry-packages"}},"1.1.1-canary-d47ed33-1609492725302":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d47ed33-1609492725302","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d47ed33-1609492725302","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6359c2fbd8efec5ccaf90b806dd70a1a08aea58c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d47ed33-1609492725302.tgz","fileCount":8,"integrity":"sha512-aGLgESnUri7vuZj4pOvvFYKu7k02YoR8rT/sUaCRzE7YKt3zzDeuz+psCVNoSfB+gXBZ1n0RzrHFE7XzAvz80g==","signatures":[{"sig":"MEUCIQDnraodIcVomtEou+5nNUYZDtSj6ikxyXTatOfgUs60UAIgJ6xsj7HzfAbpMgTP6qUjUihtcRSL+7NaSqzqzjuCdMQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7ukpCRA9TVsSAnZWagAA4A4P/iELtkuW1MSAY+jNl7E2\nkpLaQ8VKJHRAhsACaSMsTO/T46sFWZawnzdN0+ZIK3X1z3M3WWtwxvHvMS4X\nX7KQazQXcUze/1TXCr9tJzYQUmLHnDRvOOrZLGhpjGDrhXR9+tv7Fv0KFcjm\nqMhMDBUwU+Cf0uQ9BPx1SwaFhFFPcP7qBxNXenLNY5BJVE3Mv5dW61uJYd/u\noSg9A0fp/ikDKhoUlA5qC7dMIT0nnTMNX9K/1RRgWraM9M1SFy1Et8ezMpF9\nuK4YDQbIYfXJBqlTL10KVr/TGB3zlwfX0fpi75KWNy6YKQDFE0cp6mQ7Ou2D\nTNBIWxbhQcQqEAhxNmovIJpauiXt/3G4roinjpqt1UP8cQVa9YzZNzioSkzS\niRywuyy2EbN7VPtpjRDoA/hx/UsP+8CskEmMJ9A+HXKOHk8lH9ruHqeLU2gS\nI9Aj7PJlBjeBqtjdK4Dd9iwBZB0WWnJgZ6BDNTeunvgCcYTYmMnaI9k7T9jp\nFFM+6I+j/A9dfUb8y0SP5Kl8CN3bAWZBTB+mxHt9NXQCAfH6UWNpxxUmMgc9\nigzSBFCYIuNJ/3pJoPpkg3uNI6R+oDRBofbiFUP09Z8yP84dX24pHzZlu4+r\nGVmc46I9gd0k4Cv0M2GLDBqHjCYdEl5LR3CcxxReMkdwcRkGCdf3xwX5Doon\nGVXr\r\n=IeY2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0c9eaddedd4830d3877690157610f334b38bb37b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d47ed33-1609492725302_1609492776946_0.03747271412220621","host":"s3://npm-registry-packages"}},"1.1.1-canary-affe1f5-1609541251553":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-affe1f5-1609541251553","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-affe1f5-1609541251553","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"928dacd8d57b81defa0e17ec20368417eb5703fc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-affe1f5-1609541251553.tgz","fileCount":8,"integrity":"sha512-5YNSXloikRuJmJb4VPjqhOxeQd2PTXyWxwv0oQGa1lTftQa92eVIYZh0fjB89AUrplfRHDllvVUFuHSHiYnlhg==","signatures":[{"sig":"MEUCIQCWsq4FhzpGzar6zTNF1y33Kv6iOCvgGQHLLITmXcvwQQIgUenBn6nfAmmIwWy4AnrIo5k3toCWx9wECFAj6MxbN4o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf76axCRA9TVsSAnZWagAAr/oP/RK8N8oV/Ohp35i+9tIt\n2aQWOC4HtXl5+mABt9uPd0VfnB851SSpCOh/tJabzh9tfG3fNDokVXs+qshC\nm8Zupaq0P6+nNDau1p/G7IiIip1BB7J9vprQJc6mOLnXYpxO1qNoaVVBNpJP\nf7YhuG+OTelpihqDOOsuXi9/1YbA7d4zXpVmv4mCIp6IZYDv+7qrRxw47ijq\nvvPnIdeLZDS280kqlFsgcQ6gqFr3j+WEEQ/0Dllwkrk79qpkRvSIJRyn/Q8D\n/mfT9Hm7hCycZhqJpj/6ynaF1TgrS5xeA9p2QEQMcwejChn9l5t+vcCP339z\nH2CtWATjXwcdWTg4H6lUySb1Ou0FbaM538Vs99VnzpJI9EHYid6Ivz2/veSK\n2TR0wT4yCH9sJeb18RfOHkDQJf5acCIVJPZHYeQbGX7Zi05aIr1X/ZFAN9KK\nbNJbUOoANF5GqQAwO4Nz4Y2HJ6FhUc6ZPxS+39c09Npayz+Amw6OpJq7+ztF\nXyFyQdxceTurrPQH99Hu18MAIx5nO127/62WV9bJAkMWPcqpBJZ03bAwfU5f\ngZHzZOGVgawLkG2fjMPpAUOiLIQFrciJbyoWGCLcCLFk0oizfI7dBnAmTILy\nQcH7sDUkUuFYaOpXelonrXkq12zRNUZkj+xo2kZQIXPFVkUU/Shyzc9a/e55\nATFc\r\n=EkQb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f388ccde8437ce37b6c96367ab6f0e302b90768a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-affe1f5-1609541251553_1609541297059_0.26975719833759815","host":"s3://npm-registry-packages"}},"1.1.1-canary-a9dedf6-1609557112742":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a9dedf6-1609557112742","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a9dedf6-1609557112742","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"60cdbe04fae345bc6b5bb914042910826f80a840","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a9dedf6-1609557112742.tgz","fileCount":8,"integrity":"sha512-RWYJPN8uEipr8YmBgpIrBtr61sam1MTu8aSkClP8ELG9hl9Qgul7wjg9VK3SqOuD/Est/bVn8mjh5oQZm8254g==","signatures":[{"sig":"MEQCIGLUPYCTliaEpW7qB3ytUclst69ECUtiIKlL79ASQg4QAiBi+HTjz+0Cpigq1oWDFQd3njwHzZJyb7zjlbETWMV/WA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf7+StCRA9TVsSAnZWagAALBYP/jul6OQtqndovfdmQCiv\nnt63t7j3h7nwKSMZ7fn9dyekMpwXP4vzJDO0xJSM1msEJlMrlt38EKSibqD4\nFTcahKFsarDwfHP6G+yqnroZ2xl9KvCL04DNJ7ChD48Etcg5iBH6BDEuV1/R\nOsFV5V2/6tj9SXwneO2GsOikNNYLa3jJsrYf9Q6h7uFLCntayyuoFK5hp+fl\n5GbLlZb9K+PSxWcQUOyazSNumMjKwYhhRbrPOY3D72+bY0zMand2/qr9rq1E\n01RCpHwQfjLyScnEGDRtMLG8QNDC0Pkh9VRQx6vK+EN1/7Uxia4kMey+s4Wo\nDhSMGP86UufjbnU3Q7JGYVRgdXVO6TH7yzKzSggSORTvzO2hG/m2S8Pw+Klo\nf85OIwWYOkIfKnBQZIxXV+wBcTp1u9J0WSD0PDqtMSSIHIkZxGiowUtGpmu5\nOMqO/so1GwVQ4sl8C2avkIh2iFuF0I4O5JrK/KuTXdORHx/49wvock6Nbm8j\naI48oUv86jVDEQS2kOWMeLiW9TWxIp0OK++h/dXyl/thg1J+a8PMvfcGLixh\nVHxZUYgsv+2S4xUQ+Pa1qSGenXDvKmt8zzi36mhulR+fOQEoA6SluEGF3LH5\nAK77c6HedadyFgOV3CbR0TGX7cm+/Wo3Sw3k4ea7IrJPIWSys6Zd14vICsAJ\nPSgF\r\n=T6re\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bc8df68352e50d3e672b1439d968a77a02d784b2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a9dedf6-1609557112742_1609557164556_0.701831761658555","host":"s3://npm-registry-packages"}},"1.1.1-canary-dbc1218-1609564277611":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-dbc1218-1609564277611","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-dbc1218-1609564277611","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8287c01e2bce61e3b65f47abd108d6d1d5aa519c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-dbc1218-1609564277611.tgz","fileCount":8,"integrity":"sha512-0eu9Vw8LiWxOlYjvclraYqOONw/PH8vS5kf8i2t1o4QxzB9zJYpQyjT1FVPYxmmVWv9MlzgJyWm7vEvq+pfegg==","signatures":[{"sig":"MEYCIQCjuNlXWysNnUsaDdVB6lR6EPVe1yEiH7cly1EsdZKjMQIhAMnzNo9FpaiADv0aTYGyKt2gficPCWu0XrdfebS3RIED","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8ACnCRA9TVsSAnZWagAAt60P/0ESvqukL7Fq11aK2xiv\nSR3L0tuXK67oA4e4qqCPnDzG8NBUQXbf6kEvXIkC2ysnNn1R6C6nisAATxip\nx4hPBuqC9O0WGfgrsrQ+KxJidgKbq8z8kVnnA8CNcYlGCnIqrIYfRms40vA1\nqOaM+yFIOQgy/6EfVbALlMaKWWKvEJxX+Yed+3vjIsU6W6ZLVB7wOHHSNbDd\norpPfwXVehwBiMYTkSeouj3s3Yip9YjZjCrL4g+XNS7upuuJEdSeKivXE5ur\nyxXK2c0OKq5t/Qs4sAnyw/lot1W+DAsSkEJc84cLuo/ulz/WBSH/zLs2sygp\nQ3sAncUDSOKcZdENGjaFb2SC9Z7NN/LfX6EcgJfeRRvcSXraLdI1upa9GKoS\nEKqFnE8KmOsi1Mgb9aOrGp+k2aVZWXU4+/NBi3XoHXvOlglmWG79EJEAgBFd\neovqn101A9gZYP+qCE43eJJ1LesU61oXFKIZspv3msvlG03hkleyKGON59QW\nQK3I7j4ADi6bgNShzIu7rer957T2jWitB94lliVAD+QX8WwDRv6IMm81pei5\nwPR09ovv9unnk+Mn1f4n5hPF8GzXTfMA8V5qzQYgyURR1dcTHvWMVZ9daY3T\nfTBo316sEsxRcdxGbobhKDAKGSGxbIzyola56LHkI4v1DRAg0LwkxRFT0Pul\nXWdh\r\n=wlX3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8f72c20e9b9cce8582f756780c4e6f83546b19dc","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-dbc1218-1609564277611_1609564326943_0.3356317648980267","host":"s3://npm-registry-packages"}},"1.1.1-canary-a249b82-1609638840018":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a249b82-1609638840018","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a249b82-1609638840018","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b1fac56ce6f09c7998392212a110f63d9eacdb47","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a249b82-1609638840018.tgz","fileCount":8,"integrity":"sha512-Wgo4ZbEDdJ5/mPCUoK3aba/FSlUNFcrTBERgTRntBeGKwHdd0e9Nf3ULx8OJrQlrHhdROMGFTb4nU/tF0znybw==","signatures":[{"sig":"MEQCIF9gEz9s06aeL39e5BOgC0yfZylLtH3HrIDjYydraCHRAiBnA9kXK8P1peyHHejKdQNW0vepuBrWISQCp/q47SxsHw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8SPkCRA9TVsSAnZWagAAVaYP/AwvC4hEYOSWLtAChoKi\ngHE1dqkT5yvaPIL+achMI/KyWn6GPoTQ3+OmR7BRQDV5Xq2dTrQ/3g1RfmYk\nbRDiva4PrWlNAYfyskjEEjkTQJHjkLxab+JerDQ4MuwPNu5bpSK/EMlAI0+3\noi4Jpn7KvXHSTwMRdzk7L5T4XdpZJwqP9qGJu+Q2cWl6Z/PUpUYpIQc2gY+6\naX1D4GczZlfJfGPe1z1kwzoiVJW5YOw5cPY+HkMg3KpUrsyC3lQ4xm/aXkW7\nyz1hlwn2tAxuPFU+lKENONP96sOTPW4DLM4uTMlwUYeD+ZqIWZRJuZS1On6Q\n/5S+Wu9fYfrfyZPaUHhPkfNaV7JEz8vS0d7D/tAHdROgm522yZgBttrKBxmz\nL92+BrnMd4H1hxj71RUYJuupjnZqFbFDFvkEioY92SUl1koeBJSO7b2mN1Eo\n9xbwRBIMb7R8JFAoiq1zxvMfY07nZoYya97/1PfGIXrwZx6AGi/2ArjqB7ne\nq/Q6JLEuC1CCssv5hLt+bNzavz6ri1BGad8x6uVFrGKQYRsTsQdLoUM8XgUP\n3990tlRQAtl4msMR4zgkR9KP69OHPk/ZPHbzHsgFJ4U7HgGsuKAxzaP8YPxZ\nBsAqVQlTPXv46928oT4wTwqFaNI+vfK5atzHj7UDh1UOZ/1kDDgbhU2SuBaZ\nscD5\r\n=/zIB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"12efd887ceba4de41be528174eabc25a3d6f012b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a249b82-1609638840018_1609638883789_0.9229733633412951","host":"s3://npm-registry-packages"}},"1.1.1-canary-61ca8f3-1609791587354":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-61ca8f3-1609791587354","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-61ca8f3-1609791587354","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a76fcf93e75e23132b2050a64efbc329d5a154f9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-61ca8f3-1609791587354.tgz","fileCount":8,"integrity":"sha512-nsTXvggy/WUONy8nVMutugifIlYE4P9eduEN3uSG/WrjE8pbFITBle08BWMmfEogSOFAlOV2uUGF9mh3zC7/pA==","signatures":[{"sig":"MEQCIHm6IH7vXhWrEQrDnPmWaxRrmMcInzkRwvBjRjf7PS30AiAJnuBIUf1PI1+zqSFEKcQWeSNOtstMa4XvOQfJpNso5A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf83ibCRA9TVsSAnZWagAAmzoP/A7SRUX1Cn3OmwE+/CDk\nbjnpb7TDZrC4Yb1p4Zl/2JsbJUOFwxChCGAFoMdfNIhZagiRTvpHF9Mc0BAG\noEWTVbdAIyyXYuH3idAF3NgtdB0Yf0RMTzHHtfVbyKuqT4cJCAks95tpbW3z\noWdWMcK0B7goHZryGV8kL2CENnS/Mz8ZSVZlveMm8c6lAZsPoHge2chehlwy\nUQkIPgJrDcreCTsaCyTYbjCDU0KuwDpnFmI/k8Qdrf40IZRkXMt3eTSYGXF0\nn2vJlYgzeTX9VKovuPP17FtZQHZdiyZufJXJ+X61N0kWZVRvmsTRs7UlYNdY\nMxb1ZGCSqwtZI4BuFTGffTM7G12stB5MOoqXXLyFZ9kgzhe60RI4uJcqpz5r\nRDpSAOSIvol0s4kZ08Iyg+5xpZq8Fxn9rRIJeeYEcg4TxfR+uPuwtxiSUeUF\ngayRprFAtx45pMQzvMynpc2C8MVkZ9F7pBOuGeJvAnTPaWy8Tps0JyZ3qjJi\ngMsOrpzJT28ikCtrjqG5v1weo9bhrGg21cTrLqemRuGl0pvH3rvl7dCA30fJ\nj+32PJH0vBN0Z1BwZtqmVpXwDsSqqisQB6oG/5PW91+KA78zzxlNHYmreZO2\ni0Cq3M8+DrKc/CMjMsN46MxICO9seAMOKnteIwXaZSnGJ36iEvvlCg6jV7+p\nce92\r\n=aI3i\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7a43f9cf0f0d6115ab2288762500f1a1f6fc2e2b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-61ca8f3-1609791587354_1609791642585_0.9955864000229009","host":"s3://npm-registry-packages"}},"1.1.1-canary-d422dc1-1609806748199":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d422dc1-1609806748199","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d422dc1-1609806748199","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"840b4c5cef710a9ac96bdf1e02a7624d30bab9a3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d422dc1-1609806748199.tgz","fileCount":8,"integrity":"sha512-4KlxjNl8nFQGP9gcozoy9T2D1LEC736ptZv+XVEKi0hd8cQ1tiOa9UJZIyh+xCjLnbXBuC6nlx3CQpILfgv/sA==","signatures":[{"sig":"MEQCICOoH+kW4jG9qrSbp7k4zJNOtP0GRb0zE3Sx+5zU/XVyAiAT0t/WweLS4i+bDvlIbPtM3Vgu3RNrVRf31kiaGN1CSQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf87PJCRA9TVsSAnZWagAAlwMP/j1JN0bGaKrmc9f4TGbO\nnx6wrSwNAjodMY51mbp2ScIaK/l+7Fod1c0Pc+zCn2d2UMXRJ8HtokixppHa\nvMudYMLevsA1SzrLDV119Vwu+Ea63xaMRdJckjSyaLNre+mosLuyVt8eZtYR\nH0XLZsi9lHfc/kixSe1l09zEjc1Mhn7Dz51RQiU5Oq+btpJZX5JE0SAmEwMy\ntvnOSTV8w7SXl28vAqjd1ntGMwh/lhmg7b4qmiUuZtTSuENlwuh+qvFu7iER\nPbGRIAVpdZsb6Tynl1VNVdw/dTCvjV+alyJL6Yir3oFZqSooxFzX3hc244m4\nMlaxxSw0N3JEfV6bSRkBTB+Y0MfnkftTXEg2Tt/n/j5i16KjBzI65cbmMOLR\nYQfr0CRhrxea/5GksRYC7/6F9CxCRvhK3XqeUD1NhlDGU0MRznBq0ovFqg4M\nTns/tgeeINjYSU6BAYqQDr9aBepegEP6oeaCOFsuV5rtohZQ9kggABGx4xhE\nOBTWZ/WVe6BVjygOmX6wQDIX/cTM2oOioeU2YxlgUr3ky6a2IeExmV7oitm8\n825zewxu2AxNaX6mkBqjeWZsghn0+W5ijQFXHL5i9GHT32LcV5Pr3hP3Ahr+\nyKzdyjfHN4KemqvP4GxfgoYpPltHYbdeKFzw01eX+bAQ4AbHsMNGYUjbkxn5\nLu/N\r\n=PAqG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"de21069395e2fcbe3de4ec21ae425e357b0ff619","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d422dc1-1609806748199_1609806792665_0.2710876707975356","host":"s3://npm-registry-packages"}},"1.1.1-canary-b25f9b1-1609854132044":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b25f9b1-1609854132044","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b25f9b1-1609854132044","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0ca9306455efd7b245f0e6a22d56f31e47873171","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b25f9b1-1609854132044.tgz","fileCount":8,"integrity":"sha512-VjnnuePL6ru0LNZR2SUoyHZPHN3y7t8Ti35WI8uBj5z5MFgURJXoSUzy404oUQG+WV9za89PV1jlllH6he8PwQ==","signatures":[{"sig":"MEYCIQDUTwq/1XelIoEQ9932nlXTSz+/N58YJoshkFbMHOsGPAIhANLCHCjzeQDGuJWsdFhUvzlaEtt0traXkwrUiMnjEidO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9GzxCRA9TVsSAnZWagAAmskQAKRjFvGxKPo3AKnHUMIP\nQazgcQ6jXr0ZtnjV0nzE/1QIsYzZQrEFk8u4gI4CGVqQMPVHzZQjNiZmqc5L\nZ4WQVXPWihbFjwiPX4JeUk3Fi6sObyr537zcyioYGiZPb0j9/X+5cU7ANLse\nSXFMG2430T6W7U+0ZWSKmw9bb2ISSyQvvGDCeAffqF4aoM+s7Iz+/WIFMVtj\nZMytrRoQ3Fyr20ZcQi/WW0YlR5wozmd5Wjuqq5ifKS54sruty6uYu1zvgZgS\n+fppylEez2JI3YncL/u2G9IJITQaXTVbZOj94v/mwsw2q23VNBizvMJisBh9\nSDigN8uOBWAJx/BtBVrTqTWEVosmISevGDwCt7xY/gjbXuuqZBJ0WKp3io8J\nBBHGthTe2DBFLs2qoljRyyUj0dN/nkkM0eTpBGPxWK6kgdTdmhoz5w+wCw+w\nCEuDO6oB5I6boEAPbS3FundYZWVDfXxJLDhJHTMUstpqj1B5MBK9DxQgY10z\nbDNZPGYMHjXcaNaHJJRYHulW5JAoJJnckmlO4Bf5P99NwWxOzJabnMVEQJyH\nGx+Dt3mry6s1NQr+4Ic5crVtDpai9NtWFmLBjvi8WbW02K+t369JCotXrsNe\nU/LDcN0AAxQ0BZ/zQmcOZ7aihG/eSyuRGHPBzBD2Yo4mm5JYscqewA59vxAD\n7hkR\r\n=GD0h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c22a2ea6a269f0c0f508a2a743b93cd0769338f0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b25f9b1-1609854132044_1609854193056_0.6939976842932958","host":"s3://npm-registry-packages"}},"1.1.1-canary-6374da9-1609889788878":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6374da9-1609889788878","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6374da9-1609889788878","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fdb927d6862f52e6996fb371b8fc6242cbed109b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6374da9-1609889788878.tgz","fileCount":8,"integrity":"sha512-JxMMmjyvLI4vI9oF/5A30TFaoDk6otlL//530BcfFwKJtFf9zoV+tKlp+2IplTKbnpPwgjK+l30tIacWpngjxw==","signatures":[{"sig":"MEYCIQCoCysd0L2O6PL98hZLFQw/3/ewtOXNPyVXJrDRZtYUEAIhAKffVLV42ySuDo1M+pW8tdZphkUj/cRppQx3MbM6eX2b","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9PgrCRA9TVsSAnZWagAAhWkP/12RJ02hd+hlR/THIAmj\nEN3nproOqLn1y4r+nAFzXvvZFQWrxXB3UvXPnJBR/U/dLBJLZwwj0nSyCdHh\n18+fXkkLJ75e5QEMs7S/WVgUc4zHvzWmjteNaZ13mxvz6fD8/tT5raK/1pHP\neZwcCxGnTNGyXO2AH6gy9nCpESWyOID2JFwzUGFaFqmgOjI8Z4a/CWWNx1df\nSc0P4gwmZIROyiPX5VdB5MW/ZO8p/zS/AhEAprHqbgMdVyMeD9NHTdp0V0xD\nWqKxpKw+lruONgvR0XIN4N3FgEw8aFYlev/Xf0zJTp9CSoZ/0VKcX3Qqp7Hz\nwA6s7WiSDxPfcb9EOPXXB7D/fADDbEM5BrGWqy6y0Ze5iDXov165IK6IYdb+\nSjFgaUHSUjE7zYwWyKk77F4N1iYiGmR42Zzz9gwE+FHQr7mHlRde4/np/+Fw\nxN6JYW9ALBjgUztc0VF8p2FZObGNJe6ubnNEIlVd4jpdpmb5KT2FN9d4cOks\nsxHXnFS6mgflw5pGp/pwFaDHchYiRMsnePI8iFxF4JUA/AJKjWd836UBrnbu\nQAxs3H7T/a0fWQjOffTWYdtI0KzRpttpDZcZT7rSMtg1Lz1MxQq3j9YQk3Xj\nv8ldnRhAdq0/6XhFgHfRFjPpuAZrA+QR2Nxq7wOMongn9rPR39uGlhbyibzf\nwrcP\r\n=Wun5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"431ceda366fc1e8f128950514c3715f1fa973589","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6374da9-1609889788878_1609889834808_0.646560978277247","host":"s3://npm-registry-packages"}},"1.1.1-canary-f0df008-1609910674239":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f0df008-1609910674239","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f0df008-1609910674239","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e6a60f80c2f969bde5e011eb111b8f1eb4e82b39","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f0df008-1609910674239.tgz","fileCount":8,"integrity":"sha512-koiSkhHXG+mXTVDVRm7y0uki9+Et+JF67SfCEG4Kng8sq2YL3cx7QaugZ154RtU0YjQhz5yWZkvNZf3ElSEkHw==","signatures":[{"sig":"MEYCIQDU+LfsJKXZcfSB4NmEnlCX+O2ygfMZ1bTG2TThJBP/kAIhAKBPxhYj85756OWlrILdB9D+odA3sxabeDAmxLPD8gB8","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9UnCCRA9TVsSAnZWagAAMJ0P/AtcOBXeGOUa3X2TnGwL\ns+ZrW8uv8HyErHNlgcQrPlwOGx3Z42asrTx8Y0+AWniO3cAYs4qmj7PTjbn7\ne4aDMIWATRXDV6VqK6hRiy0cfO7Qb5y2ZeGOigFki60q6sNHjraTC7YbEW9H\nCnYm/8Ckxj6oJa6O2GjYxVFxUgpw6EaKziw4vzh5KhiaRAHj4Nvtt+ps9e1y\nsjzWdNk4otPSa/GOU/uC1PLDVMUj0ijhaWnHLVXEKJ4wQhBsmYVoj0FfJ14u\nKwFd1xTPLVElfkYI4+rCToGqFt1oXsYMr2rmDH3dndmP1Z2TUvRJ0DwzT8fV\n5edS0aMiYBG2Ryt4CwugtZFJObkOUeTB+34Fg/qobZAs2wbrkExZWna3vbtx\nKIQLDI2cLniUbY80Fe88KjLTHvleav9cD/r4YYMiQXRuP/q2LdFlllGdzXgU\nrZcfJnyhJBnS5XbSSXOEjZ2wFrhmHFjsZQXNlZovhLPfT88vylHRmqTsnosT\nytLe4ogyHHcmV+k/4U8PlgkyDzqQcvG8TOzJnLiFn9vU99aCfug4nvxGr/w6\ny4Mh2y5MLDa/udFPlyVxVWDVSdBAEaRVLnZeZxjim3eu899FUP/b1IvPeZIt\nN4TImtF8YPDhnd1MjgVyKclvLS35XdbDSIv8A6MzZBnJMbG5l/Xfsa8YIubE\nZZ6W\r\n=ZKkk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"768ee410f89519e90fc62fd4e0a6bb3be4f37732","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f0df008-1609910674239_1609910721738_0.8119495375836847","host":"s3://npm-registry-packages"}},"1.1.1-canary-fc1a98f-1609943997655":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fc1a98f-1609943997655","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fc1a98f-1609943997655","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"397f6b73a9c734548216a453c83bd09cc59b401f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fc1a98f-1609943997655.tgz","fileCount":8,"integrity":"sha512-uZYIJO5MEOY3xgBDI0izynE3LPY+LSVidaHZzwYNovsERx7kqVWZmf/7veVoTSsNkalfVFtiBzNWj90wxV24Jg==","signatures":[{"sig":"MEUCIQDDqGrcCc1P9KX8JhQ2lF0vteRkVxzEgoIrkUKumckukQIgFLP7J8PyRGaOFSlhI4KjsIuQ4LleypxFi5pfp5ejQFI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9cvwCRA9TVsSAnZWagAA6kYQAI0WtOYRDHehmKQyjgXv\nLw5/WEaYwysNreZ75LsQR9V6AulQUAO3TQS4/OtnSsWKw9UaICg1QEymsj9H\nP2tSCahsbmPwgGzWWRzdGRUH7O+QXM3oWR8m0c+XkdTfxpzwGI6khG0Om8Dz\nXEFaM7vS+UnDMbLfR5qWK232BaTtvHLLKDvdkguxeHyiHzTOozpiLRif3Awd\nbf7Y4edtFf6QSt2LWrXCeJO46WlOCGPds6AHk3rv/jCxXLqtda0dqyAIMP55\n955pOiWqb4TS/LMXwBoe1nyIQSlflQh5+OCa6TCCWvVniGfaQVjzNYmJV6Vq\n3Tz7+r8+fFg/KfdQcphFDLfrY45y5mzBWhkzhZ7tkG8+rcqbTK5NsvBMMhei\nz1A/B08ViUuFIzeANtA1TqB5iRsjDP1pdzWk6vnQci3rVWFw6qesLsOljgiM\nZKk2juEb6TbdXzUAyGfo4VkqVircqltTrZTPi/2B0FjwUU7S3/lQ+fKE65ug\nRSSe+aMaAb4TXRtrl7+22mFPphsPKrBBKnmEXa7r7gKRj2jPzP1MyHxtEyaA\nsRDQRxBq0NdFWltmDZ0OMDEPhP6FzPRAkPytmM/zbMl+Tb5iyeQfmlfT1wZb\nM0tclQglnXER01wpOszjyh6j+o3PIPaM+vgwd/yt8xdQ72LhLPTlCeGpTkxH\nQ+Xz\r\n=NE+w\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"462d9edbb7ae56e18c0af24c75f504230b390db2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fc1a98f-1609943997655_1609944047685_0.22672783535842456","host":"s3://npm-registry-packages"}},"1.1.1-canary-15f1e9b-1610012151794":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-15f1e9b-1610012151794","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-15f1e9b-1610012151794","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"21b5b9471e2642f6c054be6e10ba1aeeac1fbb8e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-15f1e9b-1610012151794.tgz","fileCount":8,"integrity":"sha512-LjiRf8wkBwf9ydgfu4srWypWR86AZ7UHK++IDWyUPdvfEORFiFVFtZxIKZIHiCTrI16JM1+C5IEcUt057IB66Q==","signatures":[{"sig":"MEUCIQDfLLoONtx0HdBEOcWo+65XJ448eEBMUTw5g0nTh4fFhAIgRbbeCDSphHusssAX/ZEykH1hwbmVrxFkAyAEu2Pa15I=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf9tYpCRA9TVsSAnZWagAA1cYP/imPvI3Po+9zqbLkjk9M\nzMHwVsQUFvS16R9T85svOIxeDHZVakLUvOpaljOFHBPI00fzxlP8/7s570W7\n9A8blaT8nN1SYPq6H0kP5uQ2qfXeeMWPLFTOAKI2EjCynCzPSpJTK1aEzEdt\n0NNI4mi1dvpu0rzRATN4GODUFkK5hypZE6xb3jlPLQq2J9R38T1jr1k6dPtm\ntYvBkuymt5zApHitW9peJ8gpPMG71uTIPRNbfNPVHqpdoe4tFhWGyxCiMYV/\nx8Z2miAUzyFu19iUAIAWXrVMkprKRl/mXnR0OePQIxHfV6IKLGOVxv1frkI4\nhb4IukTTOANFSwSRBb7TSloDoxGnNRwLTr/EY0ypA88bia+hJWZw9Jxv/C9x\nzD8ebLXUuunzVT2kLPcK+ZOQJzNkJkFnN5tTTKHKBvFNTe8UoqNptVQCwX2u\nfQUNmcE/RQ0W/7KtXBr+eycqdQgvGzIvX3oYsqsUZTCG1LkEnOtXfGU9hQ/Q\nOg8zXn1yENSa2il9v6qrVp30QkrnfXhwWPqXxVJRbr9XtvCausAkOQPBMEAG\nIOVYz8TfVG9C2ejiWRmO0aINt7kLmpRaZhLBIGWyAxL5cR52USHBNMJs4IB+\nML0OoPUDkVTGr4w085dfCRwjiIcgv8halHQJgstoMDoOl/lScA/xwJcZbyAg\nr2Yf\r\n=Oh5K\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"547a3ace8dc42ffcd89e9181c4a6efca4eba7e69","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-15f1e9b-1610012151794_1610012200556_0.6116241957732498","host":"s3://npm-registry-packages"}},"1.1.1-canary-acbb560-1610223837845":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-acbb560-1610223837845","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-acbb560-1610223837845","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6e5eef5a01f543b9bd74f6021ee5f44b8a04dc6b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-acbb560-1610223837845.tgz","fileCount":8,"integrity":"sha512-m3HOC7Vb+RjPnTxxc3LKOtR7yFxPSNeHXDHLHjaTOrxpmhlM1QrEgPcR8n0hmWvpS9uSwGnOhAWs18y7CmVXrA==","signatures":[{"sig":"MEQCIBltjDUvlw+e3g04fkTjFw+lHww9Uc/2/gamPYlfHlMwAiAWQJgWLK3OeFXmCZh00PIq2XCij01bJ5VTZKJxAdAGyg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf+hELCRA9TVsSAnZWagAAaHkP/A20KZrvkKjw+V5Sy1ui\nnqNlBnQfemK5r2jWi/R0i7iapLQ2HlHz5BunpsK3oXCCP0nBt9nHH8wnhklu\nVBg506wAQtd4OhLzGx3i1I/feGjWN8Fg5nnsKuaBtJH8vukr5wbpEUHqAqyk\n5z1hsx+7xw3O2wcTecFpM+GA2GVc7OYuX3wBmJKOHZy9iAYU0I/H8cZ1bPS7\nlEOjcpkTMuBX86/6YgxoN1XdfttNsJw5Mu6867S81doU/Asj+mF7VUYp/Pyr\noEvrR9OferTWUsDItsHm+doKF/nmTrd6nz2OZKetT7gqVB1HOjvTEgyEjQpX\n88P9XC0jpDBWBW7zkRrC/KcV5xw1fc+PAtU02YAynN5YDcYuTKqrdDPzoBkX\nZPOGJfIOTb/Ky0ahJ+Gsk8quMF/PiI/mvkdf8Uezcgkcm2FqubTynBcYZER2\nZlCFSCOvjahN16FK9nhAvt1ZRGQEGcFheauTQHTQwJ2HI2BYY5+ieEcAnfa1\nd90KaquEZnST4JCyNv7qGBT4gyORkVVRSohCoouzinrNw/1EsaA0k7uN9DIu\n5QKtWhFTzO5LDhWGFT2OMw+10VHxSDOZf59VaacGBJINkLOfS4lB24JprxAB\nK13vYufQJsztZnkkdecIKq0RgZOnd+5W1NjZbQCZKQHDS39bcKp1ciTG6iGu\ncWm3\r\n=Se32\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"36263c04a468639d9e610e1f199bcdff34fe9ab9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.0","_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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-acbb560-1610223837845_1610223883460_0.0952768801694499","host":"s3://npm-registry-packages"}},"1.1.1-canary-0686096-1610752507981":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0686096-1610752507981","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0686096-1610752507981","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c94437315156f33c7c441bf3629ea56194d1e299","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0686096-1610752507981.tgz","fileCount":8,"integrity":"sha512-X2t4Vz5J8kdZM2BHT3pVTDBajpgXHMC3r0dKn1WHWCVz9Z7uAf6cQ+eo+27mOKafN2kiBeXJ6EIf8tSpt5A6OQ==","signatures":[{"sig":"MEUCIAqFoQ5IfeHwduiblg5v00SCWW1Ee0knqPBo6hYH21AZAiEAxfn+WyCpy/rz3E5Y+Nk8Gmd9trSg+QJq7PDuAoWbCog=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAiIuCRA9TVsSAnZWagAAW4MP/j9fCxDEdtRecrxubWIi\no3HtG/FEbNss7nWWtc4fV07ioYkY/GN6PhCBuhYGSQRkvgUpML21IFCp8H87\nTZyFNuC7g34AlrsVMkrlDkDEuPKZ5bgvGDrPIgUSzXpMctWaV94I285KsUbp\nae9aOJPfiNqm7PeUBM9mxWPOazBwN+z0LLjGdXU+Fig0Ystw7fdDTdnXKJPI\nD4k3nG5DzauIlm/wulE32CkW1eaXhpxbNTNmY3JtXKN22aHcLiXj+G/zd6/j\nZ/v+ALbd+QvKNotME70ufckHiSsfXwbK3ierCxgNRU5TtaqXad18vwzzyB4+\nt7XSyPl/8cCA2yrl0q8e+Swiq+TGU9Yy/MGcQ8MNcqLIElqd4wNkqWqavTPh\nlIB8NqqwAvUAgrdbWxE+cltSYxZUuEOdHDy8Mq09qbWqwQIxrGoDLliXAQbn\nL8rq0ORHnPxOlSi4ZUnT6JN21oa7ccB6Gj+DjUHfBGedGjZ77tgVxKkmEarh\nCp/PJBwSae/6PfczTTruChct4ixNhyEFH2L0BW94Z761DNzM1QO0efSkMaAa\nn699vfoGfpqRsh4Ak5LyeabOyLpVKU7An7Az6J5c9PdowthRijh8/VgmPpxU\ngHaPqmbDHV6AT/Zy4CxiVhJZogPEXn3ugO2q8auT/+fbG5s6zIsLWEbf/1P6\n9eLK\r\n=CfVu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e0606faef8e34990bc658ec4f7950607ec1e0e96","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0686096-1610752507981_1610752557818_0.4081006510440708","host":"s3://npm-registry-packages"}},"1.1.1-canary-c8f8911-1610778862290":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c8f8911-1610778862290","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c8f8911-1610778862290","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9147b33147124cd1f9a6343df70ee9100f7931e5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c8f8911-1610778862290.tgz","fileCount":8,"integrity":"sha512-IaEsP1UotiJQF4fbOB97dD0VZ/WruIkt9ZHIFRsmw8/KdrUT9iF+q86UkZ6VvfbBIvRzN2APU51rio7SjFA/QQ==","signatures":[{"sig":"MEUCIBCCANbcvc+f4Q37+NXlWnwea6KgmWbvfgcQbl9PHdg1AiEAjwjgaTKmWXqAh88bK/7KhpelFgyiED7jUEwcb4LLpp0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAokhCRA9TVsSAnZWagAAgV8P/iSxHFdLD1TGobTziiLa\n4PXFlssacs2POTO+Xnt+TfCOK32XbDjAHyDx9PkrtuwsrzF0tCaQq59+oYIV\ns2g3/SgNq46Db9dAys3UQqFc2ujhmydbBlEeRZx6UsROU0KD6nlvozVtFLrz\nzM3Qh5HHNdwXJQdwemLbbxxd9WQe0dqbW+CMit5yIDkKkWVfOXrsc3Wp9N1w\nER5h8STnGU//nYZIdrUmpfneWXYBzFdvdxAQLmeDqiRhZ74fQAsVb1i7RmqO\nH/tCToU1L7KW2wKuRaYaqjPhAOBcoECc7PMtAa4MS3XLE8fx16WTluYlw8yj\n+vn2ctJH+IRpPyHouOUWQXJtDx/J9wGvsvfAJ0DKLV7kRb1uhBN0c4kSVmxS\n1Ycx/SR0616oKLK+Pi0F8JVGAiQbIwoqtTeaOanA2eZEX5SyNm4pDqtjrkje\n7KbdtUSS5x7yUP6zWYbSFXoIn0bzXS6qgpHZtHeaTOHInz/WSTxkYLVsqzvc\nSnzSHmFbjkX2gd/GAuejz49AnNjdyf82WIyIz0D+4s2SqGvVpW9Sqs8G9cZ2\nCuGvRgVnatMHFmR/bJ5jA+O2lDcFKpqupIFRh4Z3URxIsYaKjnJdWY3mVT94\nwssieSfnNw5gV3+lLxWooL8DD2nq4lcaFa/1Ig2OPB9r554VL6dscXvsUoHL\nHXnC\r\n=pgBF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"896f4c2858aeda88cda132de999c7d36e5b967e2","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c8f8911-1610778862290_1610778913074_0.44338907191646415","host":"s3://npm-registry-packages"}},"1.1.1-canary-73f3416-1610820725580":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-73f3416-1610820725580","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-73f3416-1610820725580","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d4f840d041fe0f8505bb6002386d744a12bd82f6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-73f3416-1610820725580.tgz","fileCount":8,"integrity":"sha512-lBdslL5uRO59w1RID9qUUCm0eOWxoIHSTjg2y5x1axLy95HtjstpIA5iMkjjF39/+qAha4rdfHBkfLXgTfRnfA==","signatures":[{"sig":"MEYCIQCWr8b/N9BmbUKzAoaVPCEsXEXoT0WLopNbDzR+abgkAAIhAI6sZ44ClnrcfOSihncq3iE5WBb/vGCVSbed8c6GHY4w","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgAyyoCRA9TVsSAnZWagAAhNIP/0E/0Wa6duUf4+Brflrm\nW/c8k1490bpsbbDdwxK+MW22VoAve9IaHLVxB0dWADI2BEYYKJmtQH9e8vYL\nV03GF8i4j+AyrhJMsLDAhraKSKaRLE0GiR7CzQXYB5qDaWQRsCB4ejnme/Nk\nKBSKUk+Jy7PquxiZwAOW98Muh+3ZEVK/WpcGHFWMci9pva0KuCnPNrcjDWYO\nNM77IwoySv1gJJqA17BvBzb9UBzsuGhjp6dIYpJGQ9Uv2w8WSq39UxipN4oo\nZWeoh6/sc7l7mPDEccYEyeJewONRbMzgLnThJjC2aoN2S5MMrPi/sgZgtBdt\nJiY22EwY61DMKkPc2AcvVR0q0NZnQ3NgeNUEcP96B2ROQTdh+FYJ67nwOyBB\ne+fckYMfpbeJaSfidJ1W2IEOTnzF+EHVHuIU3o169tCUzmh2GEA++jbPT5y4\nOwwKUjUCgf88eg6cOF505pEiWAJPXb92ZPGFSKqoMEJJ4M4XzvZOXh4FxYsL\n0Gb+oFIG58CLpGyIVeMOqD+Bkx5tGJnJxi7ppZ6bsTtFqhRIMqy4Kc9Agdw2\nCLhBkDtnAErtKM2R+W3FjJqTzmiGMMbiECsgceGiqQT9onyWw/Aq4vqhOl4y\nYGUw27mFynT1afrSzR1wDeSxm9PLwkIjom3/vrjanIL2z6ooGFOftcWsqxaE\nBAWg\r\n=Wc7C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b388875617ec250e1eaa752ce81ec63034def8ed","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-73f3416-1610820725580_1610820775986_0.912590715164513","host":"s3://npm-registry-packages"}},"1.1.1-canary-0309f44-1610851051898":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0309f44-1610851051898","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0309f44-1610851051898","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1b29f59e23153eddd0f2d5a054c65a11df299fb3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0309f44-1610851051898.tgz","fileCount":8,"integrity":"sha512-awR79GRw9AICSvB1Rrg649wIPeZSJjHWXDsYVXyxkMsBXOB+1dPWFiWeD/5sW43Jhr24P2xUzQRtBh5zWk+wiQ==","signatures":[{"sig":"MEUCIBnphttUWS29Z2gjiMvj3D9+I/vIkh3zjclDsvBIMe9yAiEA7mfgENCZUElFLEMY8qeWFM7RqZIOzD7thHUc2xDmV3M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgA6MzCRA9TVsSAnZWagAATG4P/0OamGy87AjPTVK+GloP\nlTulIU/ViamxV24eHOJpHbmy63bCgXCmmWCA3XG+HGJ10SnC2Ka2sn7IXLKz\nNen6qheFGVkOj/5Snt6DSAav6uveDh9GCa864tAo9N5SBCBi/wQ/oY+DkOEz\nKRgxjZ0gBR36aqcNL40Fbf4nq3HAFZxJwjrj/KlEtKWsiE0RHMYzWKGXJxt2\n8Kb5znuUC+a/hVEz/y+U6J+CuSuqZUapkrCkCynFiKsdIx0bIdL/Be3kL/xm\nWlv2MshVQ6vm1CD/kuoDg+NhwWx6hO9sqQrbLrzQgqIk/L9f33Uh20FqlZtn\nB6W4HlL18uGaD8dKlgXPfK3jo+HtWVZ8kc6Ql+Bz1hbibaoQuQQ2WqhAg1po\nvVI7DKs3n0Sg4SzEImFkSwML0YPPu6xcvRIHGEnWd5k4pyZXiOHVCy6oTAQ3\nvH3GA5mDjgnx75+U0rdHxchok8MpoO3ru4H+YCTzodBSWaU+8PJaVIOLSR2n\nXid5elUkN2M1W1sf6X+ULAzh+T6cYRT/UP8MrfScs8HqY9I8i+CYIUqqA8cm\nZUYwyqSULt5SkloUcpAMT6Dl5I/fVLAI27eROOv3pYsm+nz6F2CtOjrb669m\nqWanCsb9MWSyqtiNDfjTFwVRmXnyY1d3Y9kUDeBFv55NojMICyVr/74ZElCV\nor1g\r\n=Dp5a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9acad0008c6cc69292bb8ba8df86233c9207560a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0309f44-1610851051898_1610851122715_0.9587064926122775","host":"s3://npm-registry-packages"}},"1.1.1-canary-3256e81-1611046173496":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3256e81-1611046173496","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3256e81-1611046173496","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"178e3893bf8dc0dcb9e59d3228f08e5bbd121ed9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3256e81-1611046173496.tgz","fileCount":8,"integrity":"sha512-nFfYeFBCbS1oxbHcW/+26JYZnURspTEIgUY3OWoMw5ICABgJLYUEPnM18SgZlhBbApOhDAbU2M2EvZZS726JKw==","signatures":[{"sig":"MEQCIFmZ8fKBudPV9lplEPAiefSX+1Lsu46e68PX3z4YvEHdAiBW3suI0mVTCuDxw2PjIyaGzYaeAxBKD8JnIQH1bWAyzA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBp18CRA9TVsSAnZWagAAHawP/R7cXXvkx0g8YLM5EGIw\n1LrxDN82p2AGD0AP+yeGu+m6EcqtzfRFZXZOAuwOotwwHTqKBSn9+P632lYr\n3AfHd5vE0cnXikWY0/Ns9h6wZ7zWN5dyfw1AltYIlU0hBZNjeDHpr39sL+MO\ne0Mpkg6is0JitvGF8ZeEKe9mdKrv/I+PH4hjI/KrE8WLOXvUfV25FYoawMLp\nUUc0eQQujoNdo61hj8iBTT2b/eOQp3xonY1Iw+QUOPAx7Dl0Ros/h+ppTurh\nvAy2FkUbGgXonU8MaE6tF33QC7W/J3KAYnx6eeOaMsI9KWGA/IwCLnqyWPcW\nt4ZndkfZ4IKmrJqeyQnhbYUPhhcQxUoAnXmGIdHcykQAMrXlMvELn1QrLLF8\nJjooK3pFZ5GrpD06ozuMIRg6fB+kes/Hf8yPXR4VkkryTskU2dGqcjSIq6H/\nxY3toYbxPL4QFUximyMh/gPO3cQugC0cppK7g0LlUg2jYj3SMHGkreuUL8Wu\n68OfLDg9wRJ6QX2oSa7AP3wSThI6j4mwUQlJJjbzi1tGxgwz15eet0KoAjYJ\njgDF+kvffbYOoy2rZEOVIHiuid0iCA43y6PCuPK99AHZwJuCSrEfDQazrFpA\n6jEPEzKYCddu4lWpB+bIv4I1i+RakZ5nIW8AZBFlB6WVHwjndNDmasXitwpU\nvSzj\r\n=40RX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"40aa1f7479287d0d45b44f9e737fb80e4586beec","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3256e81-1611046173496_1611046268067_0.08852731052162288","host":"s3://npm-registry-packages"}},"1.1.1-canary-778e11d-1611145531555":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-778e11d-1611145531555","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-778e11d-1611145531555","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"351724d377a634e10237dc3e5986cf62b1a47f1a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-778e11d-1611145531555.tgz","fileCount":8,"integrity":"sha512-FrfBLsAhFGrUFRY1rgKvsOJLa93zsZ1ZMaWSYZjlkltKePySHJjMg6HrboDj11NEryPvrx+y6IuE6zIUroVDhg==","signatures":[{"sig":"MEQCICINqsWaqJpnpLu/htf2TLUqyA/xBr5xI7Zr9onKipUJAiBE6RpGkeJyJwVGShWbUtEf2t5mEca8XO8OMS5xpte8+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCCF0CRA9TVsSAnZWagAA2Z4P/3cXTsmjWb6uSORHVc6Z\n27HGdcNa6vSJXr3bsRvkDNGAKDvjpmmX/7TgUakk/vhdHsYl9fAxephSmYRH\nlipwKXLuGMKoN3tdGw6+n4n85xD7dadzHpR7Q8NeS+JgaSUjStfhXi6PmXCj\n4J/xuPoZtNx6wZ/MxBVFvDJpjj2ggYGh1BYouvMZp5FAFSxw9uwKCKm2dj9h\n68hadL+lRfAif2RoyafGjsI0HbzN609zecmdIAQejfT5pMe501hH5JdVrp3w\nSfs/kPuI87FUXgMWXhAGHW5JAbHo+B5XCe1knrgGa6ySENbigwuff35xOwEV\n/qlGD4z9H/r2BtmSAUceKxB4QsLbvYi5qAY17jwxEjlEFjgW+ldvblgLlhFb\nFcGhcoD0ttmjuJevztq2lQdRDN1vRGycZpx6StpIkvzmaO94kHTE0JKOpjp1\nvcL4lToiZpbrpur2tjLY7sOdIJqkracg5Q9xl0mz9TgJhj6NGjsREl3hMCWh\n5luU76zKZLJe4CtD5m32WlK+kyXtgMMHjM/dTwWXikE3c6Gob9ztQugoKezS\nm1IoXUzAL0/TOjUR9j48ofT77O/0x0YI4MK3PimC5stnoqstI2bsrRwrI/ht\nDOauOwdCCbAzJCL0X8ZUqZ2xo4A+0I6MmwQ8XZmftCPJno2DR7+RfOkspcUB\nrzWL\r\n=7EUt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"f0aa1d383258d6a75588ccdceed3a829a8b37859","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-778e11d-1611145531555_1611145588432_0.3207827402301817","host":"s3://npm-registry-packages"}},"1.1.1-canary-414eefc-1611333153071":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-414eefc-1611333153071","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-414eefc-1611333153071","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0aa4aba5e1b8e1157b89c549944e188e11b777a3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-414eefc-1611333153071.tgz","fileCount":8,"integrity":"sha512-ecibmz9zy26RcrJOol3jfyZqvy0G3cfMJQznsWx5G7xWa6+1+cSL95Tt/orM6H3w+MQs7F1yJsklDlr6ppaOnw==","signatures":[{"sig":"MEUCIAJJrMcjmjfDZ7YwxPsMLPNnjjlPqRbySdFHlDtXMNDKAiEAhwldkj/pAy/rIj0yjgYoYu/G0RXcMud+UjW2crxl8qY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv5ZCRA9TVsSAnZWagAAkN4P/RnoXIpN6hYRn44po3Lp\nQ6CkHqPCEanlgJQGL2FJusop4UP9jwAoqPUe/57S5FYphiVYjWJH9vbnitZ1\n8ouZfk2PQtvV2v1IS4VbTySoogavqIXznWTapBlfX1TFzVcHiEZiih1j6TJr\nk3LV9yb1SsrOHXn76+c7lMfx0IStxhxGsI8l+AwrQbH5Hz5ck5ZeATx6bsvK\n3Y+nseGmVLJ5cBm4tE9uXvEFrogCFvTg/unb6S7+EiVG8xsnPwBvDGbHSBvm\nwjDzuosZhaoXMg6eqr67gVMbZv3vUqfezy8WUOttBaSGackJxmbPSU9ZFW7o\nUNzVAkXelLMOiUm0j0RbJBEbtGigCx7JQnxuFC5jerid8L9Ma5hMIj1hnC3c\nKnKkTDbfuOHFTL1w55BSEL3dLJvILnpb/0JxjU08sYQPhXj9BlnSe1MoXcdz\nT2bVsE1vbLX1VhoQVKAiU/b2591FW9EtswoybibiwpEC6IteBuxa7B1PMkZU\nRx4bCkA3LCy64ADoASqb7egiGZGPhrtdv4+PyQEmxvIUmBkkpipgx5NGKRZk\n0bYmFyTq1wNmuz0wqKvADPIcfrlAWrTl+3HNw4ksWj7lXnvyo6CLlAgJpeQy\n2atVigOHsmKWSO2jHryQOBAEsNrio+4dPKM6Ouxbf2XqpAz19tYv4MDdpuRz\nM6/a\r\n=gQ9t\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3b60bd8aa846f1a8931fa45de3fdb0683ad754cd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-414eefc-1611333153071_1611333208635_0.7804110723389615","host":"s3://npm-registry-packages"}},"1.1.1-canary-cfa9ea5-1611433264189":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-cfa9ea5-1611433264189","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-cfa9ea5-1611433264189","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"25cc1cc58b2cfd9d45613e91da06e16787bddc93","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-cfa9ea5-1611433264189.tgz","fileCount":8,"integrity":"sha512-VqLKLU/Z5f8uN9FaIUmzxOQoGTk6sa4d57oMexAWtykH+ur6wBE7A0nEaTRbciQiC1m3ZP+rRfOTLEnbXoYm5w==","signatures":[{"sig":"MEQCIHNlcSVufV5GZK2OtAE8YIM+N+ekIB4+aNrChg0ynyPgAiAf4RKyx+oXhUsIHEFTgJGlPKXz5JlNAOO+0ednDWH+Cw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDIVhCRA9TVsSAnZWagAA+RUP/0S94NFeJSTHGJA8uPz6\n8uv+yLzfdM+q+vmuAQRgsst2AK/CHsoU2YTKr4w4NaAf94DPMkdRhd+VXyWT\nv7i4yGBDJZZURd5IMIGqndKF+lSEuauEnG1iaKeS7CBQd9wp5qwUV41hOeBN\nDQUE+XC2kPArm7ed5yWYIohVrukdtH6V5R8HRYYJpHY94pDX9Gp+5VJ2gqlS\nDKXir96NgMeC/lzcer01o16NSm0pwB1Wa5cwaytU04chcCNsxo/Xh9xCPIMZ\nIMY6L6+nJ5/tgndaXQ2J/1XOSQleI0rBcoKaMT1/vrtZYPMDQZ3ngddbFID7\nYr179L8RXPsvoPabw7EQzFFidNlfrMbYiz5wsAWP2Q7fpdw+SywWWH586YnL\nrgOe9+xtrNkThW+tfJl6xN/h6Gb/vEuiP9yMi571uQuIEoKvjfh/Jj6MDplg\nTNuWN+V52sTCeyKhcIyRS3f6QaoowTacLZUaNKq0dp10N9na0vHpXvOHmBkw\nzWd2qdTkwpiaUXlh0fydqCMkrs036/ysfQQRXOogppGGeOmlsCBKnovDMbXf\n+UlBxiUXB5o+ghxQZXMHS2rhK71BjeMieIAqvhD1s59Gy7yIx1bm/8NHBnvf\nClKcFy215QJAyGZLOJ7n2fIPKN4Z/DeOppC89vNCxxfR+KLMD/zCVLQfFRaz\n/UzI\r\n=yyXo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"58f7ed6bf7186ea2a069457757ee38fcb08cc687","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.20.17","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-cfa9ea5-1611433264189_1611433313558_0.8886182778322387","host":"s3://npm-registry-packages"}},"1.1.1-canary-9fed8de-1611517256217":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9fed8de-1611517256217","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9fed8de-1611517256217","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"aa3622039a5304718b1c5e7406bbface18fb73c2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9fed8de-1611517256217.tgz","fileCount":8,"integrity":"sha512-ZYwEK8R3nPTaEq2RPNgyERdMVk/lLIh0pKFFgi99TL99u0MMMXNBQsvq5N5euahYsMvMRfCnWOEZsh6gL/mmPA==","signatures":[{"sig":"MEQCIHfjLzYfVEEqqopuf+psJtKsF6u69n8wzaSOFi6Cz7r7AiAu0zTxcr5G0MiNvtpPMn18zKS9FmZCn5ukycEKaeFouA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDc2CCRA9TVsSAnZWagAA2sAP/1wwavIPewV60mhUlJIF\n2Xwhqxuh94cWaGKw3IfRBgUOIt+fWboh+X5n4PyE0gcZxwxBJTPNJNSNrwF3\nMY7ovdwA138RDi+I1eqlUHe/l/pljx9YMamjg5YxG/FQnoYYx+8gRIpQagev\nYeEva4Nc2Zl3KD+wIPaCHBGqS7Zk+nz8INaVYa8eHd4l5XWpsOO3CFK9ru87\nO+uubDtsPlM3eO8maW++KiGVhPRnrK8igkBwfQdvWZwahvZ7KJmrfL0vesKr\nV/iSZkX2vH+6DojZGDifASquCRK6xkEYoFJsw27zW5sc7vb4w7i8RkEy6hGc\nT/5V3e3sYQSe9vpfG2OnWRvSDySflipXZmX9PFKtyV1oPS8CaP7IlFpl8WKX\nSNqO7N92Il402n0gRcEfiRyz7/lUTj2kf6BBcygza+qyCQqWmJCUa5oc431A\nc5NioRaCOwqD0YNrEZGflz+rrC8FwcmJk5Cahn576INefS4MoqVrGJwVbAMn\nhhqy3+HTGBEosSgw0aYP7rkTWQe/WQSTvEI3WkE2i4ZZ5l3EpBe56Ag1HeQn\nHyw9ExCE1bp0+wYLeLFvbX/i8ImYQUEhfnwbdvRDb1gBACGQI7caZymYkfNu\nikIiaDN+0ecT2oIlUGbd5WHsX1igoTJO8ci4SiI2xoeX0dqQVikuzyP2DMq6\npjaO\r\n=RWDE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d78c0d61bc888febf06099f8f664866d87bc999a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.20.18","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9fed8de-1611517256217_1611517314520_0.600466854389645","host":"s3://npm-registry-packages"}},"1.1.1-canary-0304477-1611586331477":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0304477-1611586331477","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0304477-1611586331477","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e67a6f2f8b2d8383d11b9e726fcdcd608bb24559","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0304477-1611586331477.tgz","fileCount":8,"integrity":"sha512-Ug6zLt8sJFEiBW1APRAx4/7Bf3G/c3HZapGDG1OGSURuNrp6/0tcxBpWROQWu20E0IpArwlN3KobR1YPy4uerA==","signatures":[{"sig":"MEYCIQDJJpn6xi//5A1QBizxz7KbSVjc4Dc7sxeajxkmOj4p2wIhAK4vZ0aXp10Jh/uVuja8NEPInljAbpFF1VlJCtlslmmg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDttNCRA9TVsSAnZWagAAjpIQAJRdqrFNr6SXbkUPQ56R\nCFpENw/auIpXqxuPxl24DeiCMouUhsk5SXCpeHVrl4nXt+8dg2visqSEoGOz\nKqJvlr3hac9Z2HUBaOqK/KLt38Vm+/PDyGD/Bm/exC0WqG2nLjuiVWfYQuKM\nJ+cxfbgbs5ZYTg9yyv4YgFNWadiysYgH1oDylG3cUugd9ANx7XJpdPVGEBqC\nqrl4KF/KJ1J+7GD8dZ+7b4EnX3m//piZ5sJv+Ttftbk/tUgQi6oI0WIiy506\nrl8smtxf/vBqMbk8/GyV/ggzWTXqFM8iczVUI0q0Ml+fyi/xoOW1wCVN/991\nd49mckzSm4vRVtQ3GvYSQi9Y42ijCYWLotkjkqo/c7c5UrS49U7FIBAPiE5C\nKYuzD6kDFOFuzNvbLAzANF9hApIyDa2TCXNAiDNBZvbIKZvHoUA+IgARezlu\n5SM9aYuau0ugTbF7EsGY8xp4deZLArtneVMsT+CR540hVLrTpNKA2EAiuW9H\nPLshiFlf0l1avnxmMohwaStjcNnHvpdtzOkBK4Rf0NZUQXhS4yOKZf0Lthb5\nd7356y3fP3YfGU173M4RqAPNyDn+jHfSPAee3YtJjlVOdWac1XM3IPogEyCy\n2nvuPBV+DcU0/uVow+nDiWxSRvYzp20FX5nYvJJVCD0AN0j8qpCUrzNCAJ5e\nylNd\r\n=p2+M\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c79435dfd7cdcec57f6a026ad28aeb5442a5cc9f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.20.19","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.1.3","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0304477-1611586331477_1611586381318_0.6345351930869869","host":"s3://npm-registry-packages"}},"1.1.1-canary-a15c19c-1611591136534":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a15c19c-1611591136534","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a15c19c-1611591136534","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"59a5135549605a4c03bd2579fbe018a913466487","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a15c19c-1611591136534.tgz","fileCount":8,"integrity":"sha512-EJSGBDAFY0hIg3cn5vJvSjuJAS6e1P80/XXldcwZ14I6ot48Z8+OGGd0sjxU64+ptEOFm4ftpRQXilU0TWdbiA==","signatures":[{"sig":"MEQCIEvxB2k5y0RK8sj8ESgObCGpFrbU0rdFMDqgQiFro0aZAiAS+VVJXEHKeRezRlGQOcmTv8nLdMqYpA3KCSWVzx+1sw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDu4eCRA9TVsSAnZWagAA0E4P+wfiIduE32AzP2I0FLgG\nVwJvJpJNh1dh+/H+9IZpoBGrLBQFfacXdDBNF10THPpPOxks8CsZXOf7MQAn\nHPfv5FY+eR5u4ZX5ysVKmMg/Yfp/AWvdJbQoL3cttaVKLD/m1pJLytKOrbRU\ng5MiJkwL9+oJADm9COC5ZTZUlyenrcFHtMqP+Ry7zvkhbMIE8Jj4tS/e5emP\nR8cuMTm3l0SV2qMcr6n0ZsBOOGuEQj8QRfjK+o5Wfl/Dspnr79xccFctv0eJ\nxxq2CIbcr7fr0DJ4t+cNpfiXNtzbYRcecjv+v1GOJvQVHzipF+ttXQHQSk9M\nsg5BDuxdnRgvT8HRBAxW11w0EW4vs77Hk6TdzJeMMOF8zzfbSxMj1gIBxeQz\n0sUOHZp7R0ritS5W9ME0YQBrBW/UArf4RmLlB8s4Ev3CExXxjvIULA5mimDs\nj51MyTmqudsOkJFYwlZUYZDkZr4Z5U13BJV5ATpyuNSF1V6Oe+pxLh3vReIF\nFFMAGur8g5fJqD6TbgISd5e5ua6BGvJr5cBt+ZMzUo+5YjEuDVvpEZ1uLYA9\nYIgF4YnHjkSuWZ+maiaVGaTD0tYt3gbHrqqRSrQqTRgfwuzUjWrAWEK1/lZj\niTwtBWPEg9JAXrwO2AGl+/vscH85JyJTVjdsaWxzfZBcFJ7bL/ExZ13UKR7n\nH+xZ\r\n=wiPc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bcf5280e74ea2bf68e7e8675306aef27d516a874","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.8","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a15c19c-1611591136534_1611591197569_0.791331640180186","host":"s3://npm-registry-packages"}},"1.1.1-canary-3439db2-1611843817632":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3439db2-1611843817632","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3439db2-1611843817632","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"631ecf1597ff173f647087ba137220c868a5edb0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3439db2-1611843817632.tgz","fileCount":8,"integrity":"sha512-oBIPXyvfySXs5y+uf7TiNAlRVFd3YcIic7yl5zEmjsL/8oII0LJxi58EXUwzBY7cQDmxfW+iQrAPuK9r16ZLcA==","signatures":[{"sig":"MEQCIBrgRqlXNPGXkChQDaUMcFCMCM+cW5N9U0yWB7uliuMnAiBS/4W+iBnkgxkryhXR7HUYj05iixhsHZ8jADLZzVdHlA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgEsknCRA9TVsSAnZWagAAuIIP/02WwPbr1AqurKeu9V8e\nsoftZa9qeqxSdKQFwYTh/lPq+TLVeeGpvHjwAoZndLvcVXlhR46dRBQil/ZA\nT0LWEtMYmLwsWxUznaPp/pJuM9dL89tgDuiyoIRh92g6BXh1/2XLp75CoqPz\nKNYTzgFTyySCbQEuQaPs4eAsEPZQjzaQ4Cyt+xggw3PI7KGEvWbELNnnpaOH\nhHM61mx0WgrmrrroVZgFfiWLZWZzwKAw/oUQpcy4Uo0Bkla2VXk+DOibc4x+\n1Ve1MEIQgfbOKJDwjoSf6gu8Xf1FFQjh68QjV36mqS4Zzesxu4k72VThVYOm\nlzodoWKorahEDDxj1kn/e8VWkWDGL9FOHWTg7zIXnmoCLZ8sYrlmB3eY4SAQ\n3bcB2s42Dw7/KAP+5TtiQta6LB4FsyTRTpqWY1A80qhpoQziT5SoyuNzvQjl\n0uFXImdq7UqPrO0XoyikzXmU9iUyifR8TYfSNVe2O9bnP9lraLbZAOM5XDl5\nVzro/GNgg52Bg63hCtaDENG//L1oMpSQdtZg5g7u8lN6o0Eog1QIa8kxlHzu\nLQk7jmjlmK+tjqFw53ksEOUFsyiXjPOfl4gm7VGHh701AMuBnSwPsDf4Vt5z\n7ANn5avygM28tBhlNV9Vl38u5gVmD6SkdZTW57KJMkiPWrNitdqWoKOh773/\nTEzm\r\n=wLcl\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2e8a6ece53fe21d3b8a4b23846006111b287c751","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.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-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3439db2-1611843817632_1611843879123_0.33799395732770976","host":"s3://npm-registry-packages"}},"1.1.1-canary-d9183a0-1611928497358":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d9183a0-1611928497358","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d9183a0-1611928497358","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2b779597374bd96f94ed60e51bf1f2e3a334ddeb","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d9183a0-1611928497358.tgz","fileCount":8,"integrity":"sha512-SxGWRvZ1FETrhz7qDFVNzhLm0E8eXNsB2g4t7+24nTiwxnjJrzjGXDnJckJa2uM9IozMSzjMKk5G6zm2KVWI/Q==","signatures":[{"sig":"MEQCIGMTusK+DhlFq6pKXQfP8gL7yl8fLx64U6UEbB+v3fo6AiBgrrznhIKPQMsGlD7+Ai6u0tZUjP43vDj0YWMif2hhrg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFBPtCRA9TVsSAnZWagAA76IP/3JCaldw1nxI54Bd6mZF\nxoxJeGvOmGSTxNUcunUq9/murqLTyQ7RMwW4KIPY3WQimZr+oDdxEeZvbJhk\n7ZY7lQHzO7gbKyQoXJApGBqcpdnoj3o1LHJY3n4d+Y15o8NGW4ovxaI44Iut\nay64V6K3E96tFIGhStlYice9BdyqvaSOOgsHZxEHk3VNgQnYqBzVdKSRGsFA\n4ND0oJWDpEKTJclNilDNmmQUMUmjTA0bJnok4fUgq9gkHdigQS2P9lZuk2H+\n86Is+5g9F/Oz8feHdHXwiGBaLu38g3+EhfYpVUTBlb4miBhQ1StGxeOLdpKx\nCApJX4AaTva53yQ/8KMWwdRjAitTO50WJJaOY1jmPNiThYZ/HK+oNto/u/Vt\ngeL+rSBVYeIMkut0XnFgVBZKUQ/ZP1LlU5ICP6ppM0v4WM5ZZhvechjcdzmC\n1hAgYKUGODxTVHs8XUd9zOW+i0SGsyFF/UDkxPbVUc3ny3OxNsvfh7K1ff7Y\nsAphLyQdE5Q3Ek7Od77VJVjmPtLHSz1qMFTaUc4vxWTg19jYbYzcEx59Ifd1\nR1rXX2GVVb+zAuZwy1H688rPimijtjVLi0VaNXLBYUvHhHO0Tk2QEW2ShCqG\n1CLpINz0cIlA5AD/X7/ccTZaskODUsRfJWzZ57gGRxffrxVm+TAxqB1fET99\n6LtY\r\n=8lnq\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4c1c8cf59eb3faf723c7ead59d97fb8a5a8d7c01","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.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.1","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d9183a0-1611928497358_1611928556609_0.3007051764779467","host":"s3://npm-registry-packages"}},"1.1.1-canary-f9eb947-1612069309929":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f9eb947-1612069309929","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f9eb947-1612069309929","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7280c229260e3741b676f9992a63b825569b3b50","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f9eb947-1612069309929.tgz","fileCount":8,"integrity":"sha512-bWXU8PwYjnG7uJHa9fBf/iaSfr4tEYY3oMXk9Knad4Y0XS0I0Znj25qRxLA4ZNBx7QZf9atRKeR5kvxK0fnDcA==","signatures":[{"sig":"MEQCIGLqMtpldQakgpn8yo/60D0n7DA32sAwy67fbCxsH21PAiB+LsGVGhI9hIJqlXj3KNQ0uMnLnxlsK+OMTDM+11Jf0g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFjnrCRA9TVsSAnZWagAA/GgP/jXP0aXs+TlK2XV0qXvI\nEIdgWpROQA3LmAbehm7pDA4LJ4x2qyLYBQfy7xEpjvKk9USHfieMkrPAGPFy\nQ3M+qK694rCXhpp1Jc1XHr/1iv2mrz7Amu98WsqsBAhupWiJdEcl9F5/3+R8\nKEi43X4m+RnpzVF1pkYgiBdI2TFY8PHxyT12gpMDhLAEMLOOWU8CUROmmDKj\nz3Hsl7YJrUYQnCROCmUVB/oxt17X2a1+tWF8dU7FaNAdFxUMbvhceqAdaWE+\nFxTxfmcgmrT6rtZQ4ka4VNQn3wswRVGN3NgeLOPCXGgb6GsJ97WAHC6Y+mcP\nVeRi+Uu7y4d2Ku2/NPZx3FZmLRi4zIqaXbw4CQiSpnCDlatmq/CnaKZvDd17\nxC4nYaRzxfg2yIWhTWU76Du2+6S5fSt7sHc3QZtq8u9m/ZwryD/Tb0sFnvP9\n6rUX9ByP+8Da9aJ2wlfexVsRIfQSXV5PyXoW4PhW5nSpxAsa/dQFN1VtGJIC\n85+uwULDFhNs7o97tGtC8O1zSxYFQrP64+/eOoAprD55B7Bq5SVsJvgB7X38\nxn5mTwMVn2kXplCGHbxEtHMI1qVSCoY/ZH6qZFCcQhbV8cvbdj5PkgCzfLuO\n7XtG9cdhNmzjaoO7FvMgtW3lBbrsIsmCvGIOhIlQvo5ZZw2IrccyWRilcl92\n+4Kd\r\n=iJND\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"51de8666322625170a8a17c9c8a1a2c7927c0f60","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.1","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f9eb947-1612069309929_1612069355323_0.7953690165193419","host":"s3://npm-registry-packages"}},"1.1.1-canary-107b5bc-1612079718340":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-107b5bc-1612079718340","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-107b5bc-1612079718340","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f28791cd97ad8a947d068c69234bad3fd9663ff5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-107b5bc-1612079718340.tgz","fileCount":8,"integrity":"sha512-wUBfXBsj9xHuPOyQHpWp8S/uvu+HcSn84Zgaly6dmtre2aM0lXQkNic6C7OkPlMDZPbVcgDeFwb4CwoE4rfgpA==","signatures":[{"sig":"MEUCIQCtnc6NFT0VCarLwiAgsQJ5fDJTKqqn6nBgZ/ezoGv0aAIga+BRjq2ZQX3F61T17m2f2ZAImW0v6KEiaLVlvUbqb2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFmKiCRA9TVsSAnZWagAAKioP/1KdL1YPYZ5khaNMl6e/\n+YcYtSjIDet/XOxErnE1hUHcZMgE0NFxeLsFYk2TbtyfpgOtMWeJASXtXUbq\nOFH17qCraNMKwshvo3hSAXMhp9BAaQUjQzenC+uRUbeNJu4I1ohNT8VN+UHw\n5hP/bmmMTYkhR6Zso8e2zCIPVdPnh5ysvqmUruWP7fX5DT3aAnR32vXIQjXZ\ngjFxBMWPrnFvDHOO+b1wSSDVhziTJZWMoVjPbZi0myx9uEgJda9MOl/s+Ezj\nd5+3OnooEHSk1hjItDsz7RyR77BJNQF7o/R0mBzMZKtyRqEmr8sc6sVptI00\nDbBffsmyHnKzR6fbm3XjuiDllIPbVo4LD55liEH6TT1VJ22oYVrzOwqLXoua\nje7M4dcXP3k2d6o6bb4+ERyxO3CfvLf37rkqnH2QMKYqelDQVFoITJTw0LGN\nFRi/YXIrWG/T0CXQiZwIb17A21rSynQDZ8eX6kpDFd85kNHIVN9vOSi8sE5K\n6CQW4bc7dv1xgp0xFiAk/vwOHsSJIvQYc0DpwJyVlqoeWQq6EYWra6MBBdNO\nHvNyQzRyFkBUJAd9SPZdisB5Rw75Jx1Hpk4IeVHShwNX4bjb4dQloR5Jqjcm\n5Olh62KIFW+B40TkilLE0/E5CrgoY76wd/AaTEOzq1EVRF9thuvVQBzBYgV1\n5DRl\r\n=LV8g\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"aa83644a0fe7766bfc6fd72113c2052a2bb36316","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-107b5bc-1612079718340_1612079777405_0.19524088505135118","host":"s3://npm-registry-packages"}},"1.1.1-canary-c1d109b-1612125291569":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c1d109b-1612125291569","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c1d109b-1612125291569","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bd5b159372c60e1dc01a3cc84a1a65cf1950149b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c1d109b-1612125291569.tgz","fileCount":8,"integrity":"sha512-EOHmJ7grC/1n+PfYa8Xt4gZrB99m3p2eT4IVelDDIDyM0pA7EbILvdiGwc46v077SrVM3idmUovOWU9cdKdshQ==","signatures":[{"sig":"MEUCIB+afx8vjuanhhe47ScwbZi8MnDXmFEotYge7xwmzQiFAiEAyCLX5VneuGrSrsDH6UrFePEPR3VlCnK5q66LHKXJnzY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgFxSeCRA9TVsSAnZWagAABzUQAKJI/KZ1cGzssm4AMzK1\nLBinGAYbr0PetVcrksfhrMlPAMHIaYHje4KdZ0i/8kwl9D3+VDeGIWMr9iNm\n+Ck3WxwQ4Dov1GYs0tqFEvTy3cXwOMrPDEiQpdRnQcWlMotts+A2qGkVETpM\nE+VsuRyGyUGv/i3oUb2evTYF4dg6tOU0/flt+udFyoGVfRCVFwUwukxe3bTJ\n92+J/JIK5IbkCMcWJAqsykcCYnivARv/q4JRmF3ghfF3H0duCEC4aEVwPzRa\nbFjFkMQQ6w3bZWWtGntjxUGmnR5+zDuMoV+Zm1dHuzetvn+JdZTBNZS8ZlYU\nTOMdvnWWYk9U5okZn1Mbyf4E2AdNKYIZcsfulRUeeWyEE/UGQU0amwGfQ7Co\nifEt91EypMmE3du1TRk7W1qtx3UR8eq8OzAh9D+esmpP4C6rshOb+Ixqhi/j\nC8e1MiVTJJ4wiEzuVtp+8HNxZUOSch+WIcoSLLLzcraOQQ8JvPraivS8PhIl\ndqi7bAAJKu4ZWWJJLI00xPZg+7XEJl9ev2poJ0TSSQP67U7GdhOG5rDtLoAj\nxpqsM5eLtGoug3caDRUlvkFAre49akPe1yLXp334DfRvf8Jmadx1C7E7J9LO\nfGWOkQl+j4PLVdo6/LEjyBW6PGmvUc2J/VgeZA24Xf6NmkMK3oDF594ePIrG\nGs/q\r\n=Tlnm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b5d7bbbff2b1b37bff2d755ccfd6019a61d7ec30","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.2","ts-jest":"^26.5.0","typedoc":"^0.20.20","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c1d109b-1612125291569_1612125342461_0.6126160094947726","host":"s3://npm-registry-packages"}},"1.1.1-canary-8cd500e-1612178933536":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8cd500e-1612178933536","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8cd500e-1612178933536","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5437d64fd3448f5bae504dc8bd27081b766ef198","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8cd500e-1612178933536.tgz","fileCount":8,"integrity":"sha512-nfwe+NnnaQSBC8pdmbdeE+ukXhAVgSCw2QmY6U8Fv97uhDzd9eGa4gYY8lMS63B4+06rjx7f1uMZ2P7Fn/WtoA==","signatures":[{"sig":"MEYCIQDICBvB91NVmfBB9k5oQd5Iw4dbDgpcQues9KtZVezGDwIhAJJGSGugblYvPOvACLP2IzTKtGPyLl5zHOPuGal7nnMk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgF+YnCRA9TVsSAnZWagAAkUYP/ivyR+nauaDL71z1akYA\ni26ycUfxwr9QksroohLZL6UabZ+D5IRGOZCHFiLMRcPxJB+T7JWMMTStGiHX\n8PTEMm6GrdWtZq30L5py0Pt02D5Utbr1qrCNpk+E6zyvt2zJBR3G9gwCG5Qt\nZSKZs0JzP5RS24ti23AMNqeaN6cj/Nf9rgP2TmxgBaZzoSyZYxjHHhFD/5fO\n3asYMJOG7lOG+W7acKJNCP0xnvzx8bgoI0zDOFURzGRueZcArgvo0S5C1+82\nacx9fR8Smp/Em7aRytvZO0Te6l3DOmhIaRCEmN8fSJ/P5ztS60uOwS3SzBPF\n3dbDqabZWMN8Z2EixMFFDfFZZBmY9rryIIDFgzXnsX4O5/ptG8kUaopMDR6B\npduksH5JVP+AEldlDyS8bZPBLCMNPdPnj62hKM9H8mbXtVIAxMiPe7rjRRd/\n6noSbhf4mNGP2jf9uRJm7cxxAGFksVcdQ+hAwhUzlH/qCVVlOcPK2MopQb1u\nCT8N7i96xGaet2yw8RK/O8+b8lod0yYexHru7Fa0/tDydFgiCuxBKg4fodOy\nq+QdXhinEcEKosax32081C4Trb/9RZ58/iOz8Cb128UNjcs1z3R3apJP9Wk1\ncYyK+gjgkmqU8eP6FEhYzp9qSh2lEcSpxFU0+ObyLnuCLk2BcXThTPmFpIa3\n/17l\r\n=3pf1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"679f98977a2a29963e43b80846518d82967c52cb","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.3","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8cd500e-1612178933536_1612178983302_0.04834259328949497","host":"s3://npm-registry-packages"}},"1.1.1-canary-0e76662-1612253867131":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0e76662-1612253867131","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0e76662-1612253867131","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"af97e5f2733379966b203ef12e340578927c4cca","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0e76662-1612253867131.tgz","fileCount":8,"integrity":"sha512-Z3l0KaUM0rMKFoGVzb/bWSPw/17RaDY4RYToUKQvzpFuVf0WTazo+E2lxrdXQseLANDvw+pXhEY7o3SDbLifLw==","signatures":[{"sig":"MEYCIQD9CVaNkJZFmhBK2QBMbM4N1+IO+UNWnF9At7pUEtSsXQIhALZcA0QGL2kNgI/hDz9Mj9ROP5/dG3lzy/vkat0pqd+d","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgGQrpCRA9TVsSAnZWagAAbFUQAIpcDGwtX9dq3Yep0FoU\nBmR6Cfvb/e+Td6bJAFd0ke+c4Plf6nLTMYB6goRFMd0UT0nlIWyAnZVxkyd3\no9A1FdQs67H2bZGOmsvZJLDQSaQ6y/cEtyC5d7zVvK0ZnNzH2e00TXfXmyWm\nquuXAahWdfA9X3TkC4meBam3keU30cfPTHTFOr4t7AreC0Q/hp0XaAYr1Poc\nd0Tc8qr8Iu62bsvgnhhEM5KnKStqjIKq5qtXkE//65qnxaWI8ABVsQuGRhmY\nIxESuSc0HX/BkJ/KLaKSmf6FV2v33mA1/1FbJKJ9T1HLZZuq77QUvwoUULGa\nU+2H7o9KkCYff2IDxVd+aqMYkQp4ECQMWNB3fXZ1oqycOmYJUo9r8W6xIk9h\nyQmTTX5mk8E2aX/m9pZWWIUT1kijDeseB9f7cmEpwUfqm85r2N2oInOwypYt\nX/moOh1IVfbixyRc/Sg3HSw6PRTrfoIm2QiVHl9YvMaDmMvZZI6/mkUm++h2\nGtq1F1QNDIAL+EsbyHi0oKSOUK29sj9P08yry6iZHDBhDDA/eFWhlVcHvOcN\nSuQDwsMtRFkcYGOK/taODCytdVWXmktzAWP3BsxmwHAEZ4GIg4qKnCi9Y0/h\n/gOwGvr+WfboQsQw40Nhy/kLsXwjInLmmI1pxiqFG0+d+vOCKrHkKHh21SjS\nEi+q\r\n=JHj1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d5d64e40a80a3f27bf14dd12383d59996bae3577","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.4","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0e76662-1612253867131_1612253928935_0.2660044746665349","host":"s3://npm-registry-packages"}},"1.1.1-canary-4b2e5cc-1612515107644":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4b2e5cc-1612515107644","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4b2e5cc-1612515107644","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f1b2922e9ce335fc01379127706a9f4d10c6a5e4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4b2e5cc-1612515107644.tgz","fileCount":8,"integrity":"sha512-rXDzqqsUYv9iGoq7tMNUqCxq9zPtTuSSeazsu/fPeju7xAdGlU74dhtplNPRg8mJ1QeutY2u4S3ka0fmtitkMw==","signatures":[{"sig":"MEQCIGVuHQu1Skye2k4mAgG2qG/Z9hP8v/IeTUTJEA8OFwRwAiABc6EyFszqOL2SAJv5b8tE7m1fBClOC15srd67yBdGEQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHQdUCRA9TVsSAnZWagAAnwoP/i8sgKd6mURuwmy5feDa\n837WRAECwiFqD8ykqMndcdQKV4wtt/YECf+oONhI5t4vkvdKuKHI4Vq+r//P\nle9ZjK97HNbN/bDnZydNZH3/+t+wuqh5IzJ3jyJkHIjm0LUKKNMw+bvANXkT\nBahBzQurfHTnjbx/nr5QSYYXQu7u1Z1cZCFZSRhjAIEnKGknEm3rJMiej8Db\nLMnUfCRuAAVZqK13aWxvmOtfJaeyopE2UdmvOa9IMjBVSIS44a8rVzsr938W\n5xNQWEF3e0n6r6dmcdWEh6d43GKF16SAE0z2SCj/p9qq2pwaunag2pDWwyt2\nfix2D3CD8q1Fpsm+hc3byIvSvgqkh91anzkAVo36PuF/MhDIhaKZNLaVZ3us\nPQ7gHpY9rMZpnNMXi5fQaDFvRYvTb7EetASdRTli/32bJ1cUbGGc2Nr4a8Ce\nc+3Cre+C3486qbF0/VxJqWUzq8G+qg3PIXe1ZtVLbAZ392Wh2AUnNZovcCr9\nqr8h+pg4rgHQJLIEbXN2zTj84XPBd0fBVGXH2xB0WqRp0B0nZdH++H6VETna\nJUu3FStgA1UEO1Wf+IryoeANqH+oxDdtvL3YMMn4fb9KExe4gvJvI63WowoC\nDOR5bk9Qlh6lEkOupFsqdQ7GyIL5F9ZiZhzsKFASvY8cRj9WB8s5ZaqBrhFV\nrtsV\r\n=SJAO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"15f27331e5abe9ee80772a4defa384c8f5ff84a9","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4b2e5cc-1612515107644_1612515156532_0.8110477642069969","host":"s3://npm-registry-packages"}},"1.1.1-canary-b4fd7b5-1612548402699":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b4fd7b5-1612548402699","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b4fd7b5-1612548402699","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"3df082b49386c3cf2c285b56b5a8e7951404b30a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b4fd7b5-1612548402699.tgz","fileCount":8,"integrity":"sha512-NtdFwd4oFX8OOEZTG9t/W5BdkRgRuAUDGFicpVvo7MpRvF2df/2cb8LaALJZkxHhfVKsXPdKiIlH+74vmliSUA==","signatures":[{"sig":"MEQCIGZfzjy6Nw8/x0coJrHW4liQSLr1zcX6cNQ/sPKmIRIfAiA8OgI10szyqNnO46UHZVTQhuDl4i55zhxLDFtOVhoM4g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHYlmCRA9TVsSAnZWagAAahgP+gPxBF1EutgPgGKp2dux\nCdVx+y9CYnc6b5SOtkAHOaMshYuElkWqjsptOZYXeFA/R87grI92VjIRFSJA\nPAwk2OGv45GAkcVsA7wREHTm1GvRa5Hza0BOdhi+J0gaBkQryAICZnuSvBx7\nwrIHylauDpGq8c3ebWGiFBjWSQdXuaEW++Tsz0YhGFx9Fke1HBsCd4zfamHA\n1Ptli+gkDDj9d4E7Cd9UQyC6fK7HKTx3tfY0Gy54AX/645NujzwyQxvz46Js\nwpprI9znhJCEYQTPOYt32zqt28cXeCWgmyppt3vR2fdLQH5B7mq6/uhEU22X\nB8UyHqqbRZwzj0TeudpMdpQ/MFJB2GswNYzD13St6IcRpWJnq45lySp78zXh\n7RErYESGJllwV7j2w6iFAh7QfYYyEzciFOogHIxe49/LsatkZ9wZysNornIJ\nyY9Z3rDNXgIdloq3GBzzixECwdVUKVZTW8nsBjoiOCPNDZwIQfDwUxt0BVs0\n23RZs//1JwDwOt1ncTd/A8Jl1RYruX/iVha9rHlafN3UVL9z17VMVGzu+QD4\nhnyLh61rIDR9Yb3Wwh79RjJG1fechORsXOA5GCcwMoy5lWQfzbTUhgbqYri3\nn1cUmegvFVQn+xRLrgW2H6ZoVgroMW/j0zY0jzCgRx4X2j6N+oriGRTCq6Lc\nH8DF\r\n=Nc70\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"afbb8a8dbcc228c91a246fa992e04076618a4651","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.21","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b4fd7b5-1612548402699_1612548454174_0.9668404773279706","host":"s3://npm-registry-packages"}},"1.1.1-canary-f9bf579-1612628824041":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f9bf579-1612628824041","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f9bf579-1612628824041","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f6f8c8bcf608baf7a07fbf7f0d6e94a69c2282d0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f9bf579-1612628824041.tgz","fileCount":8,"integrity":"sha512-8KBP1q3zTtYS6g0534XA+0Zs0HHmO2WhVDeBPKPmAL7AeX2bVnZF8eLLZ2j2VmbSkR0Rn6t4Wbn4O+uHgOVDOg==","signatures":[{"sig":"MEUCIQDuVR2FSNA0E1h69iSO+KpdlAMJ9UUzGBAZwD0d9QbgLgIgQ8aFKnSRshr//s8n5qVqiwfQvzoO9TUQj96X3Bvldeg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHsOWCRA9TVsSAnZWagAA8kwQAJC9gtHs7uo3l08KjduK\nMRgaWRAreMRvmS/ldAy3FQLkl9jESbC32qiTN26+ffV17m/VzeR5ouSGggYu\n19Vu62Jw2xELvBwU5xNkZrrCa1RvGxoWoJFn5BaInEVQN3JZPcoV8ZMBlhJL\nvK63ru2Wbj58dwYSf8Mxe0Eug1dNN/feHSf5pqxP62JK4dwSqVgoW+gPxmWx\nJOggavJkvEG2u3thiSRprZW9ssiA2AxMOUg/4DpLJaQeSWxb+ZgIbYusTGn4\nez1FHqHy8txbgUe7Hb6tLF8kNafHR7JZGzm4CbuTVc51zRdhgLFJd7FPfr2E\nWzwe8r2ptDQ8Ya6ADvTahCZ6d8z6eRe21OIuuL7wp2neFI0gEO6yMT8cTVvR\nW9gwYscNWGeQjsb+lb+1OjXS9iwiRegktyca+x20nqEhmw4tiYdRj6BFG92+\nz0k/LzggMFQOU0CtZbxd5x9a8JI3dC7PcdH1PPJfFSQNXNDhgaEA5EW4DqMk\nnXGaAcojNIwJERy+g+bi3zUB1FTGzfQQFXr20m04g+cIDBm9/Yzm2z+uSZ4V\naGB3nl/JFDIkNuKv1BjIKVJcXzunyh9dFMmV55D9pEA43CnDTKl3W7MPViOg\n5ku4zIwAary/EAV754Vd/tidmlrg1y3SokAT3YayoA2SvEXpbH3VMUgqtWNa\nF6aP\r\n=qkx9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ada034761f205e0b869997efc82c200959ec873d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.22","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f9bf579-1612628824041_1612628885538_0.22885223289178724","host":"s3://npm-registry-packages"}},"1.1.1-canary-37845ab-1612652123711":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-37845ab-1612652123711","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-37845ab-1612652123711","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4f2fa81e167b27745336129d156c1bddeabf2fbe","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-37845ab-1612652123711.tgz","fileCount":8,"integrity":"sha512-QR9lrZyTj6yLZUO4gyh1WtAtMHYEZp8ehQiMvIQP5shl4bGwCRYol1oViBAC42CXRL/JspsLsi6PwdzIGqVN0g==","signatures":[{"sig":"MEYCIQCYaTyZ6xs6N6TANcsiFH3hl1o7PBycVJo9npqlQoxKAwIhALlGTUyaXq7TwdxcfTD5pHGwBt6hFhaMbbY2bObXsMoZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHx6KCRA9TVsSAnZWagAABXUQAJR+jNFPFs06UTGEXXOi\njeD4Vt1AMWlMFyh+kTGSU2Osta6dYVZaOf3Ry9zJWmxwN0g8Yb5twkeIVawc\ngOHrf8ANfXgpMMN2ToXDufS1DfK0VOvy0vr/0T1mnj2vB3uEPonTy36N7TP+\nR7UDE9czShF3TeiaMSai51aBFgvZwCf9qiH7cnCxHciid+71KDDq9POpXH6U\niycQ86XXXi/jN2KsY8TRAn2P42AV0KFaHmzSIhdCQ3XR4kHbUEp9IiVjHtHR\nuaD6A0fpjemqZcN5FGAobqDbgosMU0QkBpM/BSEBC+/CzGwz2QCy9iyBw4JZ\nUPO/BpnKOW2jKHBkQA1G/c/miwN7A4k2yT37m8uIpWKvTgF15RQ0xO4mBRF5\nZHdIVvqr90fdmoR2xNeKu9oH00ek0zW+qgjA7v+R7A0Y7SPYg2sKBrNWHVDk\nmagG13c5iZUzhL7MnfuuXixdgZCn87vdW7ukBBBmTHbkywiy1GuTUdAL/bH6\ng60WD725nOysdmMY/Exk1+2TlryKPISle3aSa2IeHBBY6PjsxEd2ZA6t1fOG\nJo8jPoTHoOgcP4LCNyKuP59OmPozrvNr4nAeqVPPGOPN1PNL2hAMFBAMggbC\nLzw2uBdnfDhWkHuyF86IaHBmYLEh8wevW+Life1rw+D3UNefNXfPm+i7Pynb\nGGIh\r\n=ohOc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d03bf30af84c55a423180953aab61d148e088ec1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.0","typedoc":"^0.20.23","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-37845ab-1612652123711_1612652170133_0.6402397377214768","host":"s3://npm-registry-packages"}},"1.1.1-canary-6cc5ff4-1612873622470":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6cc5ff4-1612873622470","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6cc5ff4-1612873622470","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2a0e478a0f004f236e6940a2bb2f3431564526ac","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6cc5ff4-1612873622470.tgz","fileCount":8,"integrity":"sha512-+4hG+4cee9JGEAjnNYaOZsRmgDkKNvb4nnh8n8cqEHZ+E0TtaPc+N679+xR21YjbEEcHsoDL3GZ2WXD9ktjQ9A==","signatures":[{"sig":"MEQCIDi2IB4QkgA/0vqyX7x37c3S8JHX4KzzaEHLP2Rz3xd3AiAaJDMtWPJ7dkwPb1S8FjHbo9KwcWzP876fc0GGoasZZw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIn/OCRA9TVsSAnZWagAASTEP/0QS+Ex4Qu5E2eA2J/eT\nYJkNL3hDFoWi9n3KR+ZXLT9t+pJg3r/ja/3Uy5zGkjH+5bh6loMqpt7cVGgL\nHlj/cxyTXw4OJ60IjxKMlXuHrAe4+nZs1AaBLKBjxurZCFd5gDPyRxaI4usA\n/fNw6M4eBvTKB74AkYtkqLZKusepF/P8WEJ74juiaGlBFrXyhIZMQe/ijKeL\nx6mVzMTsL2mqBAA9dGWTbvUpUPwPX4OdfWZCBPEQfGWL3I23e3mktdPNija9\ne1EJXSEL/jeFuiHeVVpd/G82YPlb4eA9oHH36DYEy13N+sGtT0BGq0RAEmB5\nsvwSv9AdCjfA2fpkC/o13VlieZQ6ztba7r0IUiSMO4hLVrfyMxQDIJA/ckY+\nHPw1atZIyT94N57KM4RQr2X4/WKSrfImhNN6TfhM1caGJC5wFVxRjm6AXjpS\nPoGEuv1+NuEHltfHFKy3nTG4Tx+np0NWsY7/3TwyBvQHH2eo5KjoxOPz7rmA\nNe7EvSXymBSo1HD44qVDjczEtvSTuvoMX3o2Uj/+5UL3wBDgvc+pwGkkxYv7\nzanh5Ot0/5QjCMM0WJRGqjp3iXK8Ia9f9n19kpo+mMZuuEBrNoKQTmbVQ1BQ\nCxXIQn0Hu5MiJde1MXYBI6PyPOTCXlwRFnHsVDnKAHc1lKzW/rAB/VPAz1jG\nvl8Q\r\n=4AMm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e7b94123a8b894e24b41c46912d0a76836b6e65e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.5","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6cc5ff4-1612873622470_1612873678123_0.6897414802082005","host":"s3://npm-registry-packages"}},"1.1.1-canary-f87888c-1612897009877":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f87888c-1612897009877","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f87888c-1612897009877","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6bcf195e166f1d7ec3430e4db06db17aad88ed1d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f87888c-1612897009877.tgz","fileCount":8,"integrity":"sha512-ABQDfv+9GTEo40W2YCWTQFRLUIKwbrIDlPUBBaVpzu4CUi6VtexGA+Qx8L6zfP7CHHCSEQejU+2Kda2YDAbXdQ==","signatures":[{"sig":"MEYCIQCPSm0+u3jAj6Hn5jAhDs5xoT/QyCeM/QuaSe7KL8V/uQIhANIQzTJl3bxXHD9SJdDLesFZsUbGu0jwtjHqbQFgMtPO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgItsoCRA9TVsSAnZWagAAQ2MP/1dbopbCbtDaci0+aEN7\nZcLm38ryliCH+5W46W7KNjKMCUlockum35lGg2F2YUM/qU2UdI6nt9GPe/Jj\nlI6J6a6bfApbaso7zt+flGDU53b7OouvgIwcTmM7MIaYhRXsr3CunUdgybUO\nN2rmxRhC2/jWvLxnYyx+hWpKYhhtJvAKiwAyMHNNLLMVwoxzMpnkyvL9yVhu\nUj2C9qkQaJK1JHl1AEF8EDVVTGpAtyRElkEBx3TsdNgvPhdVWCoygPfOcoIC\nWu2bE2FaEdLVu3M7cMAn0TnlQSUzHXLtL2U7v1Tm0G1Fe6VeVS32lkWI0jq/\ng3tlBQZvDeM/ka3ULyYWP6TFuL1IWO9/kUddC8ySG0XmW4wMu26poXPYiaUT\nw2zY6+9DhqoXqxVnLupqwskmIqidshEsdnEr+DZoxafWO1NUvi8AMo1bzfWB\n2/8dTJxfWtmP93gpK0oXRuht0FhOwlBqp70MOhy3StUhBj0iICL9kiXNbs4Q\ntFLa2nnru/Dh+G294MTIym8Bj8kZdTdq3oT+KNAinu7v0CM5UIMsCowAWZHe\n5/pdu3SpHQoNBv+2nS+Lw08AL/EhmA2zVgGA4djkKsxBgzFtB/3rb5XQlkL8\n46ReLXzxXeW2+is26RJQKvxXOriS1OYaTh4r6UviTcw7YB03ANY+EUlwi7PG\nxTWh\r\n=ISkA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d00e2d774002a22e561a9e2edfa96387696b1ded","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.6","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f87888c-1612897009877_1612897063933_0.1351265401581736","host":"s3://npm-registry-packages"}},"1.1.1-canary-e3929a3-1612990047524":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e3929a3-1612990047524","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e3929a3-1612990047524","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"83d1384aafa85e14d995f9a70f5db36d4a654982","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e3929a3-1612990047524.tgz","fileCount":8,"integrity":"sha512-DnSOMSwvyYK9amHSW666cPsqXIj3T1p60PcgVD0sDTDC02INjfRLTPZ5jNbu9Ps1Gq7I2srpBDxJct/XBbPASg==","signatures":[{"sig":"MEQCIHMt3h91ORcyj8TDbswotPc9qIOiJmoEo7gSWpEjF+ZoAiBeVfXidQfRaBuzScZLAHcWNPWXkBkD0q0XIuwmrD7qXA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJEaWCRA9TVsSAnZWagAAbK8P/18lpp7iOWihdi8/+fQ3\n3pr7ssHGn/Ystapoj51w+WPyxe79cp/D3+znUdQjlfTqVWPeFVCfO7llVBFZ\noOcF1PpJoAsM8UZruCZE86nnvqRvtsguDcI7Be4UiHZegKMfsV8KA86EHy6I\n0F9Nj7GbE88WNl61VdTvcwzLNnu2uiWBQPdT8ucVtmuut2vVEBS+avFOZpnX\n0xAvI6tlUqBeGabhSiEXjr67lz8OEu0qWHq4WrWNffzmxFSzn//Ra5iOjs1X\nNS7gQSnmj+91o/bupe0xRC7K7wn8OBlrSQb3H2jRGyS1Z4E0nwkNLeHlAKxb\nYN0rXyL5yzG91wnGqwM28QCMkZU9E2UQG7pMJt4WlkuifCwR+1eyJvRUFqkt\nqRDTgwnIlizm0x44SP/oEkoY2WJgq3dToSnVDMo/84+70osyxk83qR/5Funx\nA2FhzHGAO+/l4OHmNdjMXYRF1XlAjWwZUnEoM1W3Trm5mBfVoqXqVqZin+bJ\nYEldVbkos8I+ivFOJI2oxTxjpl8nt9TUfA0po84Q4E1yYs1Oc2z0qGgLRseu\nBK0DaHAnTwA/UhhDkmpbNSsFWan7XcZFaaGwYQcG9rZZvABJVRphN/Pbk3nt\nBp2h/LLaJkWQ5AniLYImnA514pQ3hLgn7AePQrOyvjN+PvfmAxQfWR/txZrj\ncEMs\r\n=H/wY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"47109e502673a1c52e6afd73449e84af7c7de0b3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e3929a3-1612990047524_1612990102252_0.9902104987424951","host":"s3://npm-registry-packages"}},"1.1.1-canary-826aa25-1613014643612":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-826aa25-1613014643612","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-826aa25-1613014643612","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d5ad826b79a19c7a19e209a9933b4f8704171997","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-826aa25-1613014643612.tgz","fileCount":8,"integrity":"sha512-J7wt8MtAfDugBPmyVIISiSfJEuf+Z+e7vvlh+UKGQH2CeDl1zHfY8Y1pwStcXcCy8zm/TephisasLEiQAISi5w==","signatures":[{"sig":"MEUCIDhFRijip+RG3ec5T+lr/7PaNS9Wy51MBxKR4A7irDebAiEAjKDiLzdiECpMMCpu5VdPaKU7v0i9RGsABeRN36AQs2M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJKawCRA9TVsSAnZWagAAd+cQAJ+yrAEJdPtGM+GgOvnz\nofM3sbavI7TdMztn7TacW7Ek68hsL0Ki2UObytDQ8KeuUnULaZbQ25XnH4ci\nrMJayQDjVybvIUFCGDVuKqSDwOjb/frCRH4eOlASpPaM1RRL8dwb414eQVm7\nX1O9xYjd0ZttjqO3u9KEIoseBdkN2uqeOO/Ej6bs8DYxnbHxlcIF6pbkYYqE\nXkw+wPJHaV4Cp0uqed13mMiqRBVgSgdD8J/wpfH5eDiuMA8ouQ3qFKYP3jco\nr35ElnoJQ6onaKXcQPrBRps3PQ0SzWONqv8kiX6F+LJI5/RwU3db4lVFJU+J\nMxYoqe6WGYhpte3IjK8EpNGyTheX5xBRhJGg2L8NP77lX8qXO96gvMZmq6z0\nC36pTTWvcopdXkcsi8YONetjMYcQS2g5xkShU7nFLsucWSVV6E1IgAqbJOUx\nTGbLfxaXEoP+X0aTmJqCQNmWdBtabv6GLS5jiAm09Bn8oC1Kfw7/twaWOdWj\n5kMEMEfYdweP14jT0ZkEtORK4+mFLcA9X328L+1jSKr8yQFqIKq3ltd1FTmP\n8pVwjD/vUMzEw4otlS6EdjjyIfFu+JMyuulaIF97vfL5wuOqWBtN6FsZTopz\n7ersePcD/nluOhosRatafrVBSslSJ/UB7Xcs9/kFCoOC80xmFbPMdBpEIKQO\nfApw\r\n=TgBS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ff4566e4ecb2e114bf275d3c0295946a9dcbfa66","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.38.5","ts-jest":"^26.5.1","typedoc":"^0.20.24","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-826aa25-1613014643612_1613014704375_0.9170892036330962","host":"s3://npm-registry-packages"}},"1.1.1-canary-58b9699-1613146062073":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-58b9699-1613146062073","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-58b9699-1613146062073","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"af53de4aae27700807dcd2d6df348d69c77a8338","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-58b9699-1613146062073.tgz","fileCount":8,"integrity":"sha512-UPKUIZPvU0ftdMtRqBBwVG+vgMG+u6XrWQ9NJRglksTBtMIjot2In774kFdS8t789RPIww0h+vWksXRYwS12/w==","signatures":[{"sig":"MEUCIQCljCca92VgOgZiRCRfP3AEZ5JkBrIUtzUTZZXEVJGa2QIgA1XNfhZF0axciga7oMeSSlzgEUtImaHlcr1yAFHb/aM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJqgGCRA9TVsSAnZWagAAlWsQAKAAADZ2cKUKQTkcdvfC\nwPjnlqTg4P7F44K6x+nb0tGgqPGqyrznfo/h9Wx06y4u9R9WVWvTGL/YNVDs\nCetBNvZ16pjs3crYdg9RM/UPvyhIyIWKH4AbEnvUGRxml6L1tzlzjzWgvWhy\ntwtY8oDqo9lD6uC+nfngjJepmWgupLtlo/QltT6EMGRavKYLljGwfYRcjIoW\nMCUV/w9gDTJ5+NElaxhw0+ZCEJUqYe+BzosA/2VJteq+9ZPav/Bpk2Xcxcpq\ndwnOF92RwKXamlZpeDWEUgUzPuLQq/ASPQYqFloBqYO641iITh8tTZ7kqzsm\n00htsIV14f3c7TTYx45Lz434sUwZRrxDVautG9tEifFkJeRQaQCsANA7d/0c\njN1r1j7omvy/wKChqy2CH+3ckaURyil5fuMJ8QUJKMuWy/+4ZzGycSWwJ9VR\n27H2+pAkQXMrQFhJk7wEVBcrD+071qQ6S168NbaAKWGtYVDP6MlCMUdC+1o5\nKJKc+5ktYzr5mKU5OSVhTipFASi+s6azYxKDrGsZiutzbVxoHso/yuS0E4cT\nm3fd0iDZjksmdF5NBUBQhUXrnLttWFQVorJxb9XZJjFrXmRe1JZd/81l27kJ\nA5GsdKTuOG5BZ2XAI+tuaYu2XkgDK0lOfF1KoperTqi/KCEwz8mwJNmi44iK\nYEtM\r\n=EytB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d8f29c28220aba90eaf2377d8cc7c6938de2da5c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.19.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-58b9699-1613146062073_1613146117754_0.8506221844156272","host":"s3://npm-registry-packages"}},"1.1.1-canary-bc1da82-1613170002290":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-bc1da82-1613170002290","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-bc1da82-1613170002290","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2a2a6b4b1e51158fef7b40389dfb0b1ad0284364","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-bc1da82-1613170002290.tgz","fileCount":8,"integrity":"sha512-nAd0JhxGda657RsV5TUxPGudNsL8GWyD+rRHNgLoSDhF4TFtMB7AWeTruog5KLtzhFneT7+f6vS6U0bZm9orBA==","signatures":[{"sig":"MEUCIQDRXnOUl5HaNiUZqPvEladG3OLY8HE9mcKs1BNq5Wge6QIgOk9V6823Pfk8BAKJN7vBrYs8B/1eKd+15CokZPNrJXM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJwWHCRA9TVsSAnZWagAA5w8QAJJsI1d7IKr+gLIbHi/Q\nYcM9QNEhx+6Le5Lk3Jzh4YgTZTzObRWeR0lN4QUq8fDTdSoxvz/bKhUHyUX6\n8KzLCCmLDeMDFJsX0bp/1AP+Um8kuq5B1xboz2waHMhQwE8XyMKAl7LOSdof\n1DeiC3UC2MUN1oKxbetlnoOn34DEkji9ltjpQbbR9n+iJOUmSoB9APf6v45w\n2RHifr1L5YYDZtsbNbGhb/9OEMzrTSKToV6UFtgpcflBLK4GuTPBqtfmUin8\nGlt8aAbTvOuLBA9C0dk0aiprf/IC5myqUu786dvvUY7tO2n1ERzOHoqS0nJK\nMfx5GnT7JQV8cE6C7Cw4UoDppy4NxsRHnClDj8n7RX0qlUPGb4p0zcpBFaus\nKQ5J8gZJ59usPyTDtF0a9kZC6vRCgKUXTLLAccn9G1NVr2w862kO/2JKpRUE\nsdjPcNuwCqyY5lDuRsTWcvpoJCfwpwmYjKoE3i3z31zAy6UToyHoDoOZ1rEf\npdE3pyiqEQgZ4Lu8abF5Brv+5pMvE34wTItyfr3KzffOlk2BVOE4b+OQPV3n\nVoAn7JHy+Ho4a0Soeq66Yaui7m1urTDqRd7m0mZ03IXrhwazt7+zInIAp/RQ\nFxqPYamNzbKmU987X0srKxNssH0DgM4gID17mpDoSdmA0Ao5eG46++oAmx/E\n1W9G\r\n=oTq8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"2ebbbfefb6ddd39f63185310e5e34c77c3bf913e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-bc1da82-1613170002290_1613170054598_0.0530641406366692","host":"s3://npm-registry-packages"}},"1.1.1-canary-0dd7fac-1613360741891":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0dd7fac-1613360741891","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0dd7fac-1613360741891","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"95513a47ae6211f69301a7d534eb40c4b2918451","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0dd7fac-1613360741891.tgz","fileCount":8,"integrity":"sha512-+YtSUcm8S4OV+zZlohv3mNWingRswGzYUVCGOIWH6sD/2v1pUCR/m5OggmbhG5HQ9hzFiiVD5WOmNfeVKUm0Fw==","signatures":[{"sig":"MEYCIQCVh6BWRif7hjIzcYwKjxDHzqJQJGLTzhpKlWSqH81Z2wIhAKTJ5tJ0zFi2Pb/rafY5MNR1alvQlKYZhgtk9RY4GhJO","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKe6dCRA9TVsSAnZWagAAo1IQAIS4hkPFwJ0S+Xp7L/Qa\nU3n23ZO9WkYEINGgkRC9anZp0ixTAAXGkRlm9+zuHi3SjV3znggYVToPFHE3\nzCQeCVw1m4JnNMUypJozmCaM2cef+UNik6SBnFULgNc/96Y5KpEsI/2YPeoz\ntilC/BkEI6RnNpULYLb9Q/Wo3npkoxAkfTnIo77Od3K3KC+r7a3wdInWJQPX\nX0LHLazqQWAPJcL4vh8oHHjIONrrX+1x9G5cx7R3UzqSiM/hpIyuEYhxiEeW\nb+sPvQIGZrwBhZwwXXTh0h6Kwxa9dGzbm4nnFpYg6mfnbhejQ7VaVgz+uALO\n26bvDCQOrmBq1DSMY1Vb1se15Pg2RjL+WkpESBvbj8vZUPH5YE4NnlO6pH0M\nGSyoiV6+XzuUDpqsaE5kC28GE3eGbuuQ+1b7pW5Lgt/Nc5c/ZGBjHlEBnp3p\n1Cyb8cIK2s9x2ro6/SKg/sNjlEKanjHTFwvk2QlHBMJjAmJskmE9cz6ShK0b\n+3R6FG/2jpX15kLI3qxOmQsIBuu8v4/jbF8OxJT05MBCsI6zXhRjbDnNJOuq\n5M5jfET89+jGbwxiTCZe0mcFwfxGQOy53zaHVH1vgn3WvigIZk6E9RazUhdQ\nGzeK/IBL8n1aa3dCz1QaDWx4MKqQZtdRA4TzBalSPlAGMVW3S9Oy6xTorJHO\nvvx9\r\n=k9AY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c8ce4956ef532806a9f3c23ed8c7e2c2f1895bc3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.10","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.2","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.25","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0dd7fac-1613360741891_1613360797082_0.8885537044438316","host":"s3://npm-registry-packages"}},"1.1.1-canary-4a2fc73-1613666253390":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4a2fc73-1613666253390","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4a2fc73-1613666253390","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"177e36742c021d8349bc89711ce7471b57e02a50","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4a2fc73-1613666253390.tgz","fileCount":8,"integrity":"sha512-Ibgylu2yZaIxvRkosiI3WE9TFOHYYLGktFP3qU91QcsbWBYUzj/MdgPlpkeeHWEZUg+fKhhC8h+u4fjJnj+qUg==","signatures":[{"sig":"MEYCIQCkwdAWvZWAM8r16zTxofReJIsrzyjKqVhl29Zb4yltGQIhAJyHW6tGtygtgPRLYBuAhtraWbSVZF+SaPhSPGsJIReo","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgLpgDCRA9TVsSAnZWagAArhkP/RHRdtYVBeODmLAcPEWH\n8JYyReEQtCZR0LR2ooQTxMsc9DCEtk/qiQHlPIw/tTWTLBYXTinbu+LJ7z0G\npuw2zxGc7LXw9SrRLK4isjvtvBejpFEvo4Dzi48srfb+mX4VAnCNxtCF4ZJo\n3amXGtzKxPvCv+oh9G07Te4rb8D+9utDYygVfksQFNb9x9K0U2+nxlwtJsqU\nMKQDfdkKNEAJ6dXXAO+DIeujdjWCmNCp0mEp/VW+IJF+nah92cqhJiexocIA\nUvO0Jd+Gucic/4a4jvrTpZF9J+Q1vbYvyXux13WrmBlTmr+H26xgXuJk0+MJ\n0rdPtOjEBNRe4PudmGsj87aoZnbkLKW+2lA4p3DRmka3vs1hZTWMfjJ4LKTr\njMTrKYK5GcWECs2BWj4Oe95XhCTlYew+p76LlUqKLiNccg/NslEL/V44LeGP\neYJnGk7BcLL2ak7QuX9Y8WAFxMrccUiAFD1Ycxe3lT42AiNrL409224lPIsH\ng9exj/PqZ30TnXmsttbQZg2h15ymdgB1pJALIL4PDnz3rHGBEKcGQZsZ0RIY\nFlFiVjp5yM4VZwiR0npClIY0ZHX/u3RV6dztDr6wXf+m+nSPT+DnJ59DO5B/\nWzbD5ZRGTmLcWvlg2hu7U8pq1ZUpIGQsK10CBfQDhCYGf/hI3UuWqxdBidiR\nLXNA\r\n=Ms4s\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5c439bf9aca562a23822eda86df4eba1c0e1f482","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4a2fc73-1613666253390_1613666307170_0.4834777466738802","host":"s3://npm-registry-packages"}},"1.1.1-canary-4499200-1613791330979":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4499200-1613791330979","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4499200-1613791330979","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e384e246297a6fb1366c7ad6e96f52c55756c7a3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4499200-1613791330979.tgz","fileCount":8,"integrity":"sha512-Qa5yxBl2yWcWUMvVtdc4ODUofaPwQpaodqr9HZfojrOmqCmsLUq3J8lOm417stQ2ujn+JUpTLQP1WeiUV2qnsQ==","signatures":[{"sig":"MEQCIGOB++ESq5+5YQSxDac6EDMj5RgMgb4ariSTfhq+nOfdAiB32K1u3WEcUAGd01cSsWRd3ql2/0Hz6Bw8+3YV+gy0fw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMICSCRA9TVsSAnZWagAAueQQAJuq+CEp7uv27wvvgl5+\nXDLMCP2oGqUT7HJQg7O9wH1kc8S2PStS1gGDj2aX5FoG7eGX0QrkQH00Ubm0\nkMKf3ntP6N9RQDCpI5hA2TrlCUiHFXqSPBtyn7w5hHLehs2k9PJGTHzDbFKa\ndukR8tAwWpPCTQQXOe64JPJ/SOzOywNTlPcwvaLjlyo1GHkvhK5z4y+8Sw5R\nI9FkwDfZiJ/vzZyWle/hJK/LQFx14LRYkqBnE2LhhaLbRDYycrRgOgUjFi8h\nURrfWgIQ6NrFD2M3QGozfD2kiVYqLyjUQv+Wd0WGtNOVhs+lWd4mwYRzqpJg\nBAlai3sL9SGcOVJWRUVp9K68jMgp5br9Tv2OIyNw2L7ZvdXANfs7yZuD1qm4\nhOx0M9azl1AMZAjndaLPH3butOi7vwJQuVbIiEaLofRpeztBj8MCjIY0i546\n5YvzguftGK5sRtrq+QGHw0PX0GL9VJKZOJiMM2IbsNaOsW/wktDMC4nT4UHG\nh4MyDSjyjVPSIQJVc4/e4d+AwbwssHeYxy1z19nB2LnkooV+ehC611otlukj\n6hO/k0qfogOMkBo8KI6GGH6YuQPnrRjLVXCHY/n9a6PWHTiHvbiTeVBJ/75C\nqb96Eb2yCvW4bysk1vrggWOh8JhY22Gde7F18rX1KsATscsBsnbfjlh+H97N\nLnYq\r\n=ibl3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"756d63d1d8b75d207d2b00d76fe2f2848de85ea4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.26","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4499200-1613791330979_1613791378084_0.0403247811682077","host":"s3://npm-registry-packages"}},"1.1.1-canary-c64be92-1613865688568":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c64be92-1613865688568","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c64be92-1613865688568","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"179edde8b559a48ccfdadfd68c2b962c842e8e04","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c64be92-1613865688568.tgz","fileCount":8,"integrity":"sha512-xBpCvWSK7vCcY306zsvmuVvZoL4TeaTfUMgZY3tCpUmf2Kw+IXHYM3j5GwW+w88I0/bkY9AAuW1fxPTA61TcZg==","signatures":[{"sig":"MEYCIQCMBs/CWpEIV6hj2vxxxvpCLGFPHyx2bgMFaRUpNomwJwIhANM1VzCslD4cTeYTLL+3dc9nS532q1YddTlSyMdTPJoa","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgMaMNCRA9TVsSAnZWagAA/ggQAIgymaZWVz0O8a0mcLjl\nkIIP3Pk71p8KnXGjdFcpZHe6BqLV788DnnLf6yM28FdzM6kuG/o+cR80nV4k\nyQvFtjDDgl7OK4QdtURWD8RU+8VS7S0XGulMvo7DOA0Z3XpS9O43/X6kiWA6\nJL4cU9UyItVaHB6fqA+rlHiZPq+fsf94yyZmjkLHYQYGTH61yWpiGTAmtThO\nmmG4XTRti83xFchH703JmJ/lJZuokG/x4nT6zxBtia7f8vXOSHoclolOaXNl\nUtYkzC0DanKPA64duA7VQFkF9bAodKSq/vl8LpV/NSB+vC6hUdKLNDjIBAZ/\nL4KnOJPE40JS1Tjc9VrC5tWJAnk3bKbjMknbfCAZ14p6aj+WN+1g31nmhcqx\nHdtxhIYFMh0x1vK3TLwrorBkhhdzSF95Y91UAR7KuOHDo3d0UBe8HzUsYFse\nJQV9aNZjJC1/uak/Gfqd7p1ndPbAvEn3/RVmTbCzQgRpvfWFfD7J7MozZBmU\ngNWCq8H6Z0FK5QqY0/Nqx8Wl/TRV+4bbWU6Qk57apGeiOsNvxZlCvoW8mYUW\n4L+NbE29ik8Lj4UndD04mtZ364m7PSihdiK8YV0Unr3lLAVAyUDSmLPAVT/s\n4/MJCET8Ritglv8sfifh1mzR7PeT31TJr7ywCE6WG/5N90M6Nm8N2vqn56Wk\nKZoQ\r\n=U/A0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a6a86e41f653a83acd4e2a87258a3591e74418af","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.27","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c64be92-1613865688568_1613865740608_0.44753249539706497","host":"s3://npm-registry-packages"}},"1.1.1-canary-e6abd72-1614045959458":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e6abd72-1614045959458","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e6abd72-1614045959458","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"241059fdadaed8d73aacba02504cce09d7147bdf","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e6abd72-1614045959458.tgz","fileCount":8,"integrity":"sha512-IUIFhGmQ2YbXDDV0Ztr8R0ROj7VzFb1qXDbkw90DhXHJR1exZhDnKVcUiHSWe1vQaKwm3UWjXXPnvwJBIRBKfw==","signatures":[{"sig":"MEUCIQCAkB/unmKVxGSVcIChkwjoSsM75yCAr8c32djza5xbqwIgPO0Va2BN5+HEWigwaqXW2isXnlQXvI4+5+wvK5zcYr4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNGM5CRA9TVsSAnZWagAAEw4QAJgWXN13/McCruRJWM9Q\nNJ+VLtJ9ul+9kdCOpgSXXw5j0Rppq+2lx1bsTivFmFcdnrQ5zZxIkZ1mKZPg\n86Wls4znXqImIB4sfpk+PIQC4jMXPsc7w7ttf3kxRarhqrcmueWcZcQPB6jf\nnqxxPVQ+CKgbmNA55PT1k48dsY/WhG10FakO/F1c7eWN9xUlk/uKUwycYNtM\nQenPy3ufDfqn5aFar+VTU3nlXTCGgXYPbt3k95rcGIhuPgr9qm5tkwQGZpDk\nKjiuSwxG5hyCNqVpgJ/LIUI/NCVd0K0QDcHpvdHJe2cQDRr5Ffr1RnFSs3kd\nL5N5k1tF9L9wvwgtPLbtNtSubpaKkPzJEwHLZLOT0xE2VjEwzKvn5oL7g6Rz\nqf+gmIO0Ym30p7V5zQjkavLMfzF3j6qSyQuCqmIcgD9ZY1ubuCffy3BZ8M8X\nBuZGDRClS/LViGXZLhzfMRrEH38u6aOIvFNtzB/T1G5q/QTbq753uYSif7xt\n0ufQwqeZfDywnUQdUs4VlYwB7fNsPh1ATNIyE3/rdYPaztwLDbT1D3C/LFnK\n59ipOJQMPVZV+Q8plRSkvFkI6KM3b0RFAnvWUi7Ufr+LV6yxfJQ/iggYQXcw\n7XK1Z733hwscMHKNzwGiRfu0/xJLsyNIGEq/AMuY/6vfwyl6OKQqycCbhzif\nIlma\r\n=4GMs\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"5537de8b2e0da609297d31be94e3f39aa90e8e89","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.0","ts-jest":"^26.5.1","typedoc":"^0.20.28","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e6abd72-1614045959458_1614046008704_0.13254011694923862","host":"s3://npm-registry-packages"}},"1.1.1-canary-9a898df-1614075665360":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9a898df-1614075665360","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9a898df-1614075665360","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"858adacc19e48719beef3cea11ec7a02235ca5b3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9a898df-1614075665360.tgz","fileCount":8,"integrity":"sha512-9gion5cMuMA91td44dHBNJLGmWj3s+yKLbLoigg4MzTTqA0C9/NEEv449Y+xT4WA2r9gKjFyqMX7BShOQjMcGw==","signatures":[{"sig":"MEYCIQCQ6PPhy1wA7PXxdDBexR2MmGLnBDdF5vkQzmJKQOPqVwIhAONPFvapPX4c6V6smVsTU3jLUXCsCdyaFNEdrp4eqaql","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNNdKCRA9TVsSAnZWagAAH4AP/3eTcYq8++4WYW4kmPB2\nd0YJN4rTWLhzhsLwL/O+s6Lsrs+tTTu2wgN0wYOii7ikvvhJEfoQIQdaK19w\nqnasmuHqJdEcjfFWi2yXuft0ZhyLIKNBMkPPB73fF++2zhYO7ORbAoxyGVs4\nD5AkiydUUs34kwfzfhdwujKdpzUkcgCNfsfFLYsnT0BAtYMcLvjFZGw7Q+9A\ned9Wc6QfwCm1eEQzyk5pOrg9I3MIAAtJxL7VMkvAaSTQzz3ETz/y4YshO2/+\nGCR+cRVZYxOBnbvdDESeXUuRBnpSWE1TzL/OMo0i6D5aoaQKYKJn53ApN1iC\nzI8c+/zTNKOL5hHfoH11BrwJdVIqc9jfzsBqft0hXlO71AJHTJSE+lk3eYi3\nTF7Q2EKF8HZTCv+gT5s8XxdWQhEmZ6C72hXEc3SbIWq8AfYzc8ufrlJzu53N\nonop9jb8LnTYxYa13zrwXD/G5LZDQOB94y19sGpW09CqWgsV2o+COPg8xQw+\nGCiPXXZtrOBuNBObTUBK6zQ9b09RAjC1OD8UnmMj+l5NG48WpqbzlL2XpLAn\nmb4lnl2ZH0+596luWGALwQbs6sfpvSAc08+1K1qrXupa1HviNnt3Ug106LZv\nCDY7lrUO71r3MYPnQQEUUpgfKU20xoldsNwnpX0pzHquWVy6g0VX9SGLwoYr\n8G2j\r\n=jiuN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3dfede5e1a9375f7f09948fea646b4ac6821ede0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.1","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9a898df-1614075665360_1614075721906_0.9724677828927712","host":"s3://npm-registry-packages"}},"1.1.1-canary-7b1e798-1614118965986":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7b1e798-1614118965986","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7b1e798-1614118965986","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b79ab2af8fe906659d21a4bc532cf8a449ae3f87","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7b1e798-1614118965986.tgz","fileCount":8,"integrity":"sha512-LDa06CnPbBIOHS+ayFnujmRd+xkYbzgIrYOycgPH54JRva7Z4A/FDJM3RGK+gNvmQTdGrgAQqQglls49gHDY9Q==","signatures":[{"sig":"MEUCIQCC/XGQo62YvOqa8KrWcCvEq/5N9//q9BZEYVBQrUHzsAIgbDDREgoo+SiCUch2asLEHJeM2i++s3LF2yqKsMWs8b0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNYBtCRA9TVsSAnZWagAAL1gQAIcTUudI1c/9bTmzBAzb\nTy4WjaRfRe8tR1GMHY5U04ishWPrbVzDDQreW4murG0D2f3lEU/tCz2TzzFL\nvSHr15M34jIGkwXTty76tTSM9tP7saAVigpMFvfG7n0GPWrHhR9GcS5/2PpT\n4pNE8OwtEDyCq5agSc5pmqj0N/RsWUMmzHN578BVNg5ml5Vdbl1cZw+z5kiY\nTHVwPd8ZcSyy9Xt/IMDwd+wKARY85Bt2Mlfw5Px/gTYnp6eq9CotG1PUXkio\nFNJz6uEIfCQPfMgsKxp2Ko1LRlhXCa4TqtTmMpij5Tgtuvcaa10ybhNuU2Uo\nvP6KBfZD4B04QBmB52MAxNGW4iJZl1PHSYs+toPNHAz69DBj1/Lx4e0yOzow\n2l8nFwHYZZasiD/Nwvmyqe17hwqnCosLRSgtS4B/gere1KnNUgvMf6n+jz0n\nDXKar9wAkWZwyqrDgaadQSbJK4DwabuGGL3DeQHUzBGONS3AYd14rYo1Ur8c\nFTFVH9uWrl2gUVEstVB4sViFGq8VqxG3S7InuVb9H9U8fb4mkqQKe9fth42l\nKmgP49OM9JPN7xKCs6vNBc1MKIpJUS2yjbFcOP2v89NNI20FoJ4Su1S/1Frt\nBFhLGOR3tnCiG5pGuS3TZZR8Kzl10aOUrFojL2HOc4YkIc38KMTgqqiGQvIj\nfRiH\r\n=IRTF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d6791c8f5328823651cb3ccdd14391963972716b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7b1e798-1614118965986_1614119021085_0.8311527429650267","host":"s3://npm-registry-packages"}},"1.1.1-canary-fbec41c-1614122191378":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fbec41c-1614122191378","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fbec41c-1614122191378","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"21c1aef87cd9bfc48e8571d17748ebcfb1aa35d7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fbec41c-1614122191378.tgz","fileCount":8,"integrity":"sha512-Tu/FuC3/xfalkJif12VhQ939DuEOEgTKm/+CEZU3PHjUC9zfC522PFiRNVUs4kBEznYk/Y4Uvg0SmegRxskbtg==","signatures":[{"sig":"MEYCIQCnCDgk9NLj8hvaZJsbH51MhpEHvIKFX+bhAujr6qr+XgIhALFWlLkaPS7QDTkDcd1+o5UT902chSvQjedWtTTRt/cS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNY0BCRA9TVsSAnZWagAAMHAP/2febqqDzQjR6oJ0P/lt\nflRg4UC5AR3t8a61j0U9mB8MWg+/u2eXzu+Kv6ld5UdboPTWDbuC22q2w/j9\n6lRcP9DXmKqpmmxBh9zQkPptUCZMi8k49PGdy+sSQgDv5yF3fWr6L5lz9wrf\nIOg96Eozch5zuQ7sClD70wGMWZXEJEYxqcWPcPYdPGsZdKgJMvAYhJ9dut9K\nl+MicLAnHo8xAyugwrt4ptc6IFcVL9sjQOHOurw+JGgpRkCAyEHFboVF9LQj\nhjR41biqnGBbb7VYv51Z1dTBONiWoUaaZXKXIm4pQtfSd8/9KrOC6a+vzvwd\nR6f/2J2vWrNPTRtuuDT+R41GNQ9J6zLPJUE2lCXuqZ98RHY3h0kIaNMpa14x\nOjHySC9bpxJ6/iVw9ofLyEZZruO/dUYC1qJ9XcGs0qVgFX8F1imHvFn15jtS\nxv01o3afVPOciSRdtFscBVrN8si8m2hJvRkr1BctCxGQxRghyAZpVxGwyBaB\nLlRaK7NCGQXhZOu0ud2Kax25eW3YS32/p6EA8beCSkWVS9mP4Kn79SlxD56I\nHJYz5jgxvdMZBfyJpqaiigbpkhE1K3O8YATNvgCLQSTvuureLfKbkAJ/ziRH\n4eIiDSXiloeAW6o3VPgiCTQInq2+lozzeNr/9PYApKh/Y+619XrE62f4TKqe\n5r7V\r\n=UxIU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"71cf6e895c1bbd7e2ff1aa01b13b3c630eadb0f5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.20.28","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fbec41c-1614122191378_1614122240749_0.13744157037225269","host":"s3://npm-registry-packages"}},"1.1.1-canary-69c5888-1614208467710":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-69c5888-1614208467710","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-69c5888-1614208467710","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"74a1c6ef85eb8d9f4af1be61f62b5dd4da13b5ba","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-69c5888-1614208467710.tgz","fileCount":8,"integrity":"sha512-Ce3ZTYvurJ11SdQzvSboDsKrMk0oZdmi8ncgjXNRIAc+FGHxGbBj6HpOpQyagNqNkMNAawTuLlgBqRY8qdYURg==","signatures":[{"sig":"MEUCIAgRp3+c44eS+owE2MReXbKNeqXR34TqRYN5fY5l7/JGAiEAwKEZF8IKpGYN7GeWeh/yXWR8t/yS1kDSmt7ASoz93m0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgNt4ECRA9TVsSAnZWagAAI0sQAJ79o0ihRoJlw1wsy5Rv\nQGyEG6d5hfRR1a/PMzBI3ZYm74XL8TJf7IoRvZXUtmvGk13/V3K+1lLQzULV\nhxjlxxHP0dMShypl8uclxk0WGqCLxRd9cj6yUwBedZX7GGFQ8bt/gHGHI5hU\nNt5aYbbNgYNVJ1G9I/7/+g6MCAzi3J+oh6/F4utIXcaQ0IRbyVbi++/7IIJU\n8BWt56XGjoDa0mIQatjetk2uysBGBHVYW+tjMpfBdnNACPDM8QvnLA3OeVcl\nRbs4izhY6M7zXgNYNe6VqA1ZX0PFHGZi12dSRCAubFgkedD4zQaSSBen0DN5\nctovvBuxJfLaZKAa7S/y5IwXVacijvxj5svHgFM5nVMVsqzs8mqC5/bDKVak\nfzLHsVIzd/E6OoRQxyt17Qk5CHnBq5dT1xU2XOwGzmk9V3DJ96GO/khZMWEU\n0jzV+EK+R6x2dFvIJ8oJzvoThbuNqZDOq5E+EQcNQnRcDX3/X4BT1qLsoETJ\n8KPQh1B5TgkzTnG3Q+iTRrsAGacZ9mlwyMb9oX5rtHS5tr6bH2GOOFnGBO5T\nqLQyhN09WMJ6yugoGdiY/ChvOhnOuq7TqYDt9V2N/FH9gGGnUaUnQChsDhFA\nKls0ksXR0aLSYh3Vmjk0foeKWA2SEso/FUDgyXwb29ZPr64o4Swjr0dl/IfO\nOoy0\r\n=7gZ3\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e2b58657bf10e99cf306d287df030e5c320143da","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.39.1","ts-jest":"^26.5.2","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-69c5888-1614208467710_1614208515691_0.8538303807252541","host":"s3://npm-registry-packages"}},"1.1.1-canary-e2a2fda-1614350809006":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e2a2fda-1614350809006","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e2a2fda-1614350809006","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8bfe935eab6c674cd712913e66394d924850326d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e2a2fda-1614350809006.tgz","fileCount":8,"integrity":"sha512-OlAymHPqrMhpE/pOOHJvCIl+7YCEQjpyS0DFXaRMGqiSyM9CKsFXDerf+U6YtAaC4Zsywq2rsTqOIO3mvJxLCg==","signatures":[{"sig":"MEUCIQC54p/5UAATkGG8I1Qem0gfB8zDgypGjZ6lbAB4SjwBXgIgNCBpjghx9lvryJuYXeLWdXye0BOB4blqhIOQOlY6Sxw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOQoQCRA9TVsSAnZWagAAmPEP/AikhIJLEC2pcJP0HDBm\nvXh7H8L4ybwbRnWCMhKDUH5bpBDmDCk14lmonkcxDNQVBjaKlNj9OOBuD54b\naJ9LjLO3jWk6yn6uG2Yerv1My6Tai5wj691fur7d0N+RjqZmPxdfS+ktTUrl\nwjS7lRunEXQM3cjUEubYxG9ftOHbvRf5nMNg6R/euCF9w0Yo0iDwA4yyixDT\nfa0rB22PAe/RYhWGy/cpVz08Fexv3Db7nJO6CUHB4omIjkmXW/EoXzGqJfiA\nbrLymqwUZgNkyxtogoXTey8765c/1FXwBanu0QtuGtVqcOF45U8RqnKBT+Cf\n+Hv1NEtPJDJds1ym8DIJIRNRP5Hq7kIAMTFmKyB5MS4ja+DncUNI1dM0u4sO\niO5J1TXoVp0uxaJBiik4Jd3Oz6ReFrAJ7U7yZvL8MQ13G32L7UW+TdJi+u/l\nDFnOYPgIggXac9ru4LpUwYssYkqRjcuV3khkGUCH0/6tedPm0anu4OEf3yrL\nMFawRoJUYLBb8Iq+01qH+61qfoUv8axpKSONvyP+3wsU/wGqVOXoE1dQlDXR\nCC4txTnpQFDjbBIjpoLtdyI/fEwXNqAYBwbSNaDG1EA6NEyKohVjN/rw++Q0\nrGdaGpl84dJE7gGF2wHjIkOrdofE5Pr3DM9XiFGpOY1d1hdfuux1I6PFU3eM\nWO9T\r\n=xiZM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d5e3274f03ce1c06c8c661cbdb3713b88599405e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.20.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e2a2fda-1614350809006_1614350864266_0.45412129158079884","host":"s3://npm-registry-packages"}},"1.1.1-canary-557da4e-1614464576863":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-557da4e-1614464576863","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-557da4e-1614464576863","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"67fefb17f1d99c9dce575e431c9f57c131c70dc5","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-557da4e-1614464576863.tgz","fileCount":8,"integrity":"sha512-xwnsskm6zMUyszH0H+Ao04V4PzPZFKE1a9AdrUUz6cnAwhNJgpWTWsDtgtFfN5eAbBEbaoVhb6cFVy1AzZkcwA==","signatures":[{"sig":"MEQCIDyNmNS/wKAoEYw7Y65PsbXkzus3OquJ2eoBaHG2mM5qAiAKvhYSTbAieGLdhEFwN/oeAh/b1twOLFPKnJkCw64KfQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOsZwCRA9TVsSAnZWagAAQoMP/1biXXIhKlmJGXWc0ve/\nTYhatKZmEOIISX+vWVP4y7s3wJ1D0SKrMoDqAEin0AXEOaVQbhHpCzsf0bPK\niGnbRzkCQWHFsOzp0VdtDoSwPAvRPTfafggigJqfDdJsqhPIdceo+l3VZCw4\naE+Qc/OWRhCKxL6zgCMAgvbED2hFQmLpeKhMqU3PeIvPAytsF+eeUzXag/6I\nUZNZjONdOoa+1fcYgeQXHBRMbx5J8/cQwjtQ59DJrH9gzQLKaLoKxNveUfS3\nwcG6lqvMyXEA8lJIBu0PmrJ2wJTNMW3Fw29eYXQovobrEkq9LEav0ETjLBEm\njbPxNRV4NiCKqIcQXOrqbfkdphRyuo2t1/PuJ8Br/vO2BtfJhfiLqlZxRuho\n4IOC0vINgAFlNXj+iimOxGXT0Yt9AtCOJBSYtq6qokidkVePmUAYrzTJRqK5\ncx3J2t0mroxIlfrGii6TJebrKZZPXphxTt/nEduA2aICJH/ZcchgBDEsomU0\ncLPpq3df5udzIT8r5O7HVnPc+49jPHK1BQ51WVWu6OXr9HSg3OFKp5pRjVIv\nSk5YwEW6diAUvPUPX/jUK3yJMe1GQ8AbYcXGFmppbs3GN/7TJ0aN7h2iXKLH\nfAn9Of3ZwQdFD3prm9Ag+Kw51Q63/60poER8iEKFVGPaJG/KtHgWNKDCgi3o\nGeCK\r\n=6irp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e5110a4182dc84dd49d68e69ca61a580ac4f226c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-557da4e-1614464576863_1614464624375_0.4902178140679021","host":"s3://npm-registry-packages"}},"1.1.1-canary-29eb579-1614554908052":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-29eb579-1614554908052","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-29eb579-1614554908052","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d67f0c25aee2b21d0b9e3a8d739fbb49ef76c794","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-29eb579-1614554908052.tgz","fileCount":8,"integrity":"sha512-7VXsS0hzHHnttkkvXaJrEextNGBhCLsE/m2CGKenRTW0pCqdvtJnkOzdFViTzjmrtzH5UMDB0s7PYIucgBZL1A==","signatures":[{"sig":"MEYCIQDk1M6WOUB9BeTVzg7Fy0EhHAJFNFX78pFEzhxRTyJZzAIhAO/I4QSEQMxzXqUQqVqj8mR1EBZQQ6KppW2Bn2M7BIvw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgPCdLCRA9TVsSAnZWagAAV6oP+QGxath2VOYw/9syWAtH\nzxSrwll1JkI3XKHZ0j7fSaUm6dhrxc4021fX8Ehx1l1nwKYA6prrnXANSr1O\nCFQ6WIWEBRedLlrEPn4lQ772nbmAYR+Yvjuyc5aR+tN8K4TnmdUfffKmptEC\n2fyh4nNmIbT/aVwskqCvBsm9/MRsdgoizDDevN6oB7amCtpX+DNmDMvYzs5o\nU9NDmXBbe3pYR2QTMyPoeWbxIpEV6n2lVlyYSdkTPCdYCL7AVsc9Gb+diN1A\nNRhtXR8Me9lrZLJqdmbITRn+dQMjmKJiYUhu/6Z14F9duUomcW6WE9Cn0so2\n5WUiw8dOmyjvoLfOBQp2OrSfMeye1rzcCStxpjqg0UJ+CU9Lhf9EN6BY2kBa\nnHdFlx45NSxCFKKNztkl2+cL1pdy3s4IAgrt6olEBEZvzeea+xkBDucZ1xIj\n4xTSQCkpMq7gghaBgby5YBOPvJb9VqoUica7GF/MzWHjIaD1SJllBhOk1EBc\nERT7RRMN+8VbYufteovVjOY9G99hLxd6N0TSUg0thtTb3S4l3IVf9oF5k6oX\nv59+n70oRKRFJHRDXWHkU0LTubrhNENAfIyF+Qn0DroXvO6M3MlO0ycmGsqC\nzzUobVbhpCaVn/7zFqtPFP/3+saYVKyllVzTY+VVnojA4EJpRj0kCZ/TCdjl\nSqOe\r\n=vcnB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"946605ab01089be6499a6644303eb39ec43a0a6f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-29eb579-1614554908052_1614554954958_0.10055237214291601","host":"s3://npm-registry-packages"}},"1.1.1-canary-7d30d56-1614835170404":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7d30d56-1614835170404","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7d30d56-1614835170404","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"b15789dd0e02336a5a4a105765b74281878d8dae","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7d30d56-1614835170404.tgz","fileCount":8,"integrity":"sha512-qbmevQ5TUTSNXzMtLRhCAHyc7ipGm72DribNYX3dv1oxb0WHPYnSu9GhiUi7+6E4rYpcCt0Q3KyI4Nj40MAKcg==","signatures":[{"sig":"MEYCIQCvcmKFALOrGTIrYGKwJIeOHveusUJbKk/WS/3p/6aeyQIhAO0uB1DJDeltG6j5Zq2/H1HZu2Y+UGVoc/HbjaiNLNtv","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQG4aCRA9TVsSAnZWagAAMkgP/iNfW2BPuHZcoGzf3fH6\nLUA2s3o/oLUOLXh/ynLWHd94Jqef/tbaXi6kqXt56T72m4+lGSrWiOdobfOx\nOWzJBxGmM6E/sApSTBi1MDC6QHcBenj0OE8yCst4qtfjDqaggl/4pPmPLiYp\nmhUMcm/zq7vrPfHvr1cw8UGxhCUOE8Fa+t0315zCEmWWnyPo+TPf7oJ87ElB\ncaqiKwBSLxD9PxP4Bh4V60QZUZ8lSX9qy5eLu1GCaYDFzBeMMmthSGCtpjiq\noSG8W7J31rc5+yMVYSw8y3o4+Uu2LN+rE0UWKtVi7T5bkvPmHkgYmSvIyvwf\nQ8Xkmpd+lGRMuBP7yZ6DVMl94kWkKEqB6IKpaYdq2JrCAnWXXi65VkSeSiTv\n7PImEYA0IPaMoe5lhoz+zIO8/smQ/mBs1y5hmq3QX97Fy22vlhq3xe03wGoc\njX8ur/KPY/vLqaa2ZJYDoNVwemGzeR4GpOwN8ec84NSy0ALvtqoEpmDtETmB\nYBN5y6OnDLb72NZIsm+UwD0K8+B52V/LSj3s7TUpMXdWHigvSG7Tauz/x/Lf\nmgjLm3tKkRB6SwFBd7jSuceJtj2wufSt0OCR+Y1sjCwBRoaAOjWsG4X9mnp1\n+6xGgqOZUXxSZRqGB1X9XXXIzZH6RHOMs6PaNi4VYG/CfT0UZdj6heZaP0Pj\nOczD\r\n=iLia\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"25566a699a71383315e6de8a287f0a6614e9ca06","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.2","typedoc":"^0.20.29","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7d30d56-1614835170404_1614835226290_0.09760083690470167","host":"s3://npm-registry-packages"}},"1.1.1-canary-dade30c-1614846763103":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-dade30c-1614846763103","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-dade30c-1614846763103","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dd3710b06307a43b02b1cc1c850f1255acc59cc3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-dade30c-1614846763103.tgz","fileCount":8,"integrity":"sha512-lyrVRsWBSdxu69kHq3bPq1jJLiyU+yiUkDL1B5IH1cKR6FMD2hnkl+/P01ioOdVbTn/7qzSHR5baPmSlc2cEeA==","signatures":[{"sig":"MEUCIF9NV8BEHlT5RPPNagLDcKNA4XACPh1P2JnwhWkmdVD3AiEA2qKHNC50+H6RE0ouHdktyF+4bJUs02aDmUnp0hhuSJI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQJtfCRA9TVsSAnZWagAAU38P/A1jwATeIn1AJ0H+vfnQ\ngYpiENFpObaQ/4hG7CkCMxf9LIAMZdV7GS9CEQjipc5iIf85qkbA96qB5h3q\nj75Gl3K5T8xi3dzSZCo3iyiG5uUsKrvt5DOv+++72TsmHUe3QY6Es/0yjXfx\nzpYCB+6j1tauRdN1pPb5XROV2yTn9Ub4xGpEKuDHfexTzMCWuqFIIRmUCgoI\nMkrzbckhpxRPAsUAsNqVITXRYaoQ0XwcFtv4Vn+pSGNbc/nKd/3j+AyP56X2\nAekQO8jmDQlFnDEsdJfQR03UUz+G8hXHGhXoGYQpAhkU97/ijklw3YfaoMKn\ndUkyUnTaODdDiyf/+rQGfHf4lj3mQtugtVjhVMtD++t0sO08qockJVUfxTY4\nm6HN1+R5/oCWYSL3LhhR3WhxOtjFDEbgzN3nSauvfSopgGxCerMJhCNJP4Vm\n8PMGkFCaMbgXks8hR7TEToOGp2OJIgCzRTyrmk+WrlS7IP/GK9jUkdEKAANd\nKNFOSQfi5PAoqNieKrtHwuGOrQHvKjyOVNoBMmTMVtGRfZJJLxd7XCSJ66YV\nZEgsP+KHk++JF4+HepYva7auLsznAfQ9cIDjHCSTty61vI3zT5bFS9R6LHiN\nZNamMNJZoLZauakPOmo4VRxDsqSk5WYM1MxSX1f8N+I+UOJLdOI/2v5pFgdB\nS9p6\r\n=RN2/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"858538150f08720b058101362875dcb5988ca835","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.23.3","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-dade30c-1614846763103_1614846815093_0.9234870784269855","host":"s3://npm-registry-packages"}},"1.1.1-canary-5d81b81-1615048197914":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-5d81b81-1615048197914","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-5d81b81-1615048197914","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"61d55a23d47039ab28880bc229d35e1e3eb7a63d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-5d81b81-1615048197914.tgz","fileCount":8,"integrity":"sha512-Aa9zLnYIv88+/cc5eJRh/FnhejBUy/Uotfsi4sSbdPfzJbXLDCvECAJsjt2W9Nc5yKtc0uuu7boD71gsDpQYAg==","signatures":[{"sig":"MEUCIQDZkpD8RtYbNFhxhfeasQ7kGD9YBi2M4AycRzijma+4jgIgLBsO6UJ5JHNYAbfOkiZuhIaXuasGrZObE3z9+AAOBrI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQ65FCRA9TVsSAnZWagAAmv8P/AouXUtdYM+JhEEB6Tlr\nfy129CrXxS/64Z1tizBTXpdahYetEJq58vERS/jFpqvnlNXi0y8yd5mvFnIF\n4tHGAgTE92i+4OouZkKwYeji6veclmjiP2URAvP+M9b0+OQwuyDENKQRrwrF\nFsERpz+vVGOmprQWZruMZ2k5TnOoaFglcnFwbLxRTI6peD0Sp2ZrH008ymct\nox5qb66TnyB3hQvZlvzYNYxLwqfRSYQjmHzP8mIOxl+5+KNSpjpNVGHgdQJf\nebMudKvmNRF/5pJNInqrkr2wFAFVj1Q4JZSfO/BscBWDIuH3kQD+rJpU5JtP\nY3x5PpJJ6xoLjUHsgEISus26PmrQ0iXR0YISv5UFHgFt63GkwNhcvQNSlTlF\ns0tYORS9VdQ/mJN/l4dNUhRjurYzwIc85CBeEv8CTalv4RkrwFrmeoERFlRd\nwp9U9mwFqQOpOC+8rAcUYYWvLJn/DPm0pf3oZFizBI7jeY6HNTMETrnQu9Le\nb0EUlAmkTHXjeRpWFHRpSYuiBr4yipBN0ifxFZpwICsbEOFSS0jKeBAJt9uJ\nZfTuW9e945qQADNglkcgaSSWT/XavChWpPA6JrNDWVdipoWd5Vs+vTNPfebY\nNRYwDCNWcWNVqEXfdGoxq9OnXdwUGksTR+N5unkVMREpwxm3o+6kmVk+NYcZ\nj2A4\r\n=WMeR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e397ab9ba0320462f7f6ec4c3c398dc9bbdef98b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.20.30","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-5d81b81-1615048197914_1615048261487_0.49711023023349","host":"s3://npm-registry-packages"}},"1.1.1-canary-d6d292c-1615159271182":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d6d292c-1615159271182","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d6d292c-1615159271182","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"77f9344eb821d8ee9bae95af5843dcdcafc416f3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d6d292c-1615159271182.tgz","fileCount":8,"integrity":"sha512-p/KbU8JK+CoPv5jYRcJoQ7vL2kX/nT+JZH86/LJQW3YGxx9Rf1H6jbFzOZfpa+9QSCWo+FyDnsLFPmS/JXbNOw==","signatures":[{"sig":"MEQCICVe7WwM5cOXaEbwzke7vhxwyOqmVNdvoBCm1wzG3DgAAiAsMiNUptclxpuPj20IdTbgfvu/tL+IQmkOoe0m+jZk8A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgRWAUCRA9TVsSAnZWagAACIEQAJ5Mq+nW4+OjbrJkmVzX\nxa9lZh0prkUFrv7ShkLuSe/zDhYrdn03yKF+LYt5LAKqDDCzAWIkLX3w2RTz\nLf7HMB7ZmbAeB19ELzQauDutY4+1b85Sd4zpI1StqiMHuyyMKQ5dzgj1khyu\nJno0l4ng0/8K08/HwY5ufbFEdqXevLks8L4BB/B+KlZ3e2ueQZycGy86Mc3F\niEV8NmJi5klB+Yg43qYu5MCzAgRM4qjE3b3z52Keew5XJ5dN3lTEEqNdT8+F\nhglmIsbtoyMBFBwf2Xua1f3br4Di2npc83BcTe/FN6JbyRzFTYpFWqXQtQk5\nIK2tWELvDlcjx2oGUO52kq4zaXUVhmqk3w3ji7nRL3ecPGIbmDYmNcjyB57n\nl29dSAWkZ75KdSInQAVwpTL5HH+XvQPNNauATuMnqFz5DbgCiOelIlY5n6/s\nE2XEIGzmPcIaTssPGHJolpQyrsbSPBydpwBo8tYoi69RccSi8ZoK3r6kVt6R\n05yMAr+3ZtnSt3tvubfYXVd+uvINbbcd2x9cktKGWiejp0DnruNCOLHoi5pV\n7JnPNCK2lZ0PC8/CLIL7sgqnGBXOzgQNAOOEvcnb9aSkyWPmfw8RFdkMsY70\nWasPJHqZikvomx7G3BhHsvQ2/OomEunWcBYIkFs5qPnrVIQ06iuusOqyfAth\nE9Yk\r\n=Qiv5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"bd7f3f673a98294322ccbbf780fc06390a2aab8c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.40.0","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d6d292c-1615159271182_1615159315577_0.2085201024232548","host":"s3://npm-registry-packages"}},"1.1.1-canary-97b22c4-1615279991651":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-97b22c4-1615279991651","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-97b22c4-1615279991651","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"8a8ec0c65389b0741414c0348fb338f601bf903c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-97b22c4-1615279991651.tgz","fileCount":8,"integrity":"sha512-G7ZWSLIGXZ2aqBgvD41QgGzQ7z1s3SlvKtH+L6kRlFXP+75PRUU87zH+1lwx1MpaS4guR8/G+mWnBUWrvQk1DQ==","signatures":[{"sig":"MEUCIQDZTE3yY74tyA4zvpoqxUmVPLcic0RZ/Hd7+ImuyYBbiwIgeopWDswFflw280zMrITMGz1OSSIJmDR98qxlqRZxYK4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgRzezCRA9TVsSAnZWagAADckP/An6w6qwvU8SP0eaJgWr\n5nc02fw+ncArsdsbj2L7MyhUYBHilD70AJMIfMKPSKIjEyKj6qvnJaQLAOfJ\nmwMiJfjDhhUHeBwv3IDStqth0zL9r7oZ7Ueht/YtHhmc4fXGlbdhtaT27FN3\ncLPn+8HNLyEHq55p1wmH1DPQ1gQ5JxSLFbG6CoyVWSSL+M+qpOJDmKxavcta\nnoPF3lXCpiP6uUVPG4D04Am8eqyCPo7E6+ofrAiyTp4brrAbGvMPx7HnhHw0\nOOl/CfcbwE5ucBTQgexO3K3zncZ/NLylr+W+wcdCDYieXXc9jz59yHrXNTqo\n5ijuZ4g0qACdAEmzUTriVPhMkFu6Z+sMwX+64uqPxg8il0pJVcKlY2QscZvm\ncAAa4xbVt35oMyyDQczlm6b874zPEEsTHsw1UlyvWuRAxkun9MabjpXHrotV\nOKz3LnCb0st07RBZOnza0KNHn0eulLnFWNhhmM5Cvzmv4P6aAWmpxwLCfO8F\nkDrTF1JaIpDRR5WJlTscecpkc7A4yQc92F/AiBTjyswCvltPW9uZBCKJF4be\ncNO8Kw1gLPDTbk1engUnUmiDKlafZkMedKj6VYb+nciNSK6uKRXe47zTTpPM\n1BI3cRxmo2UVWa48IfZ2njldz9vSDBzc0JDgvweoR7NQmZxa41gVvmcfW5uk\nzSq/\r\n=CglU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b2c6cb08375a23147781b478e553f85035efdf0d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.0","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-97b22c4-1615279991651_1615280050411_0.5836451352252552","host":"s3://npm-registry-packages"}},"1.1.1-canary-1822da7-1615418103314":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1822da7-1615418103314","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1822da7-1615418103314","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f737a5e818adf35b42a02df9953878d8482ec048","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1822da7-1615418103314.tgz","fileCount":8,"integrity":"sha512-alrnKhyqX6AOY7Z5/fovLgYTjbgS2qF6lxkUMMRV3K4RynH7N6GxOxb7NUAxdLYc5NavFvL7BO9BJNqSrwTKCA==","signatures":[{"sig":"MEUCIFfkM8ynwQjXRpXXTI6msteUb7hVvS6+7KiGlxWLYKryAiEAx3YAtE9GDmhYZdGKlgspuvqrhjeQXIkID18B9jEs0zw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSVMxCRA9TVsSAnZWagAAUWkQAJgPHYhKiEc5R4VNs/Vb\nU67urx+qruqzu5H30FLbFp+4y/+mr++pcx+7UunsFG/K/nnt6XngbCTqLiBF\ns1I3/71KSc/Rr8FyFUANEVmzuVFSuydglqqT2t6RQGO/mR8X7zfNlT2tJhQ3\nxs1FC91XLlbclgBNacbkKvNpvgHwP9FaScLFANlFGTV5gUUFGXLKdzXScJNv\nHm5C+g/MrcvjhXsQCOE8NO+M0HrDTKEvGUKbM/Vw+xc1ESoTRoMFt/4LYT9B\nuls8aMf5FTe2efdTl4Ri8L2ULlS0YKsXJYlZwxF2wqgShRYxOPFSasf0gFcc\ng3BllKqECDRQvLuR2OaUZDa2yy7LVXjuXfGzU+utHnjUMPepG62qtukwDkfY\n2UT7AxalNOAezk76JRolLamtdMyOw3bymHAl74Hjfu46dcSErbjd0ovF/T5V\n0Qw3qJEqCe/ZaX7MN8b0cmiBjec7kfdpL4XCJe/1ow5yy3h3GrHFoZOL78/4\nmbx7PmDyo/HvzGCdZIujsqn2o5OeiExwCHgjC3EHTBSIZGTPW/Ts9kFlk3Dp\n8S1C/BtjXuh80Ctyg/Ux/ETOwHpFIELPCcd3blA58pKyFBBEAD4HbfqN1vgO\nBNrEQOdOU6OlUo+5gdHe6P/8UFufb6/VvW1DQd9vgarQOBvb3tielWDDUcSe\ndV+g\r\n=6odj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3a3a9f9b63c0715ab3e1886c6e16794d9ff22b53","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.0","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1822da7-1615418103314_1615418160730_0.659955592450189","host":"s3://npm-registry-packages"}},"1.1.1-canary-eafa57e-1615439907923":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-eafa57e-1615439907923","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-eafa57e-1615439907923","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a14f529e5da5df382881608488f6a14058463eb4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-eafa57e-1615439907923.tgz","fileCount":8,"integrity":"sha512-1+98U31y5keLS3qIA+iRDvaiSVjECob4Xv0zd9DARWKxca6Ir/Dr1Ysp2xtNxPohNtGbu73CGuX+g5bttZQdmg==","signatures":[{"sig":"MEQCIHBBVAuLaqlRj/S3DDg0X4nGlsVAViRTwA4zLIXThH8TAiB/a1lR+IHi1JQOVKkwPh2PpEfVl3o+P7I80DS6AunvFw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSahWCRA9TVsSAnZWagAAyh8P/3DshFZ3m3KGEQdh13HY\n+g9rhCxH7LoThaJrrkvOPyZGqx6HVmkH/MRUHZKvJvT0FAfDff4hjGFKSXFC\naWU3iuBDs+GD0fyPhHnoyK8osdaOhcs5zenH0er5BTjs/DfKG42OOZ3gGU/E\n2XhtAO2fbMG424InsJEfeJyz0dyUmH2IqreIT36Qpu7dFDDYNG250Bg+JyaA\n0b0cSl3djJ4+y5PuPrtzDQn8VFWED6WLWY+5YRxx763vAWPkS0QFVeNyka5D\n4SeNbegMcF/UT4Kg5pyGmfvpIOtZYex2bOanM7qU1GYnFne18d6NyHx3tTRv\nHIUVtlwxfPnY5hEuPxDvRSGNclzm3bxafbbEJbZ69LlSjjHQHaisD6V8SRFl\ndkaNkIvCkYekrf2OT1Zf3SjMWWTMAuu8kwARRlTk6fpyxEC0R/sJI29ofF2s\nlvaYdee7WD134AyFZ9l1GUiexURMUyDJfoVyg6HHCzHKmIaahJYNk8T5LJBp\nUjQkYmOngDZVIgXNEyySvl9xRtl4ZP9Fr6/1kpkF4kCfQ6OgCs3ncMm22LOt\nxOCeWGwmufrh/jB+wqoZE58umT4n0WuHGC7Fa6rb77+II28cTBUPePI5o1R7\nHWONy7n2hiK/l30xNtwxOsbnt9YyUgotkTXyBCFny/mF0oXBnPkxHbqbAga5\nGE7W\r\n=+ZTp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c7f1a9a6a84467794e770221876cffc2fe8a71cf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-eafa57e-1615439907923_1615439958437_0.7602609874224484","host":"s3://npm-registry-packages"}},"1.1.1-canary-5ee4803-1615504510954":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-5ee4803-1615504510954","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-5ee4803-1615504510954","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"94e4989268ad20a49777a3b9aa3337fda8e0c92b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-5ee4803-1615504510954.tgz","fileCount":8,"integrity":"sha512-cfKLLLmFP86Bl4gQ1LYoIj1dRKMp/aeIWWp99c6gSp5Shx3zqPDO0FURi0zW7KCEJmg18TDMO7Vkcv8TPDew7A==","signatures":[{"sig":"MEUCIQC1PgR81aDwA1HBbYbduxxI70M0jxxHsajZ3jNSvjskWgIgUDKdxkkesi2NiS11rNz1/fXUEQZJU5g5+RGFQRlh2Eg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSqSzCRA9TVsSAnZWagAA4BYP/1mWGwns3Ueuz7IE9/lL\n9RMpBUoSTH7yKmGoQrmUhkKhPFMQmnPlTDX18bQ89w2ocPcxwJ5KefZ3vWvV\n+UEmSiC8xf8Me4WE83Y4hbrnPvPYHZbbtWzDTjI7b0JBOQwGrmZOrJBstBJQ\n1zKVG79K8Mi3mFBM+E2x7UEqL0CtIAsRhfhW1SQvBwJSs3fBOV3rr9vzq718\nOh4C3IWI9YnR+5Vke8a4X67UgQQHtezWR/rzNx61vrZemy/W7n2r1rie7zsv\nUpw+iLhcWVGKc+/vzo42MoqdE/XIZu4jm6uUvTOJbWN3iYL+XMvo1ygaUXgq\npxRObCervQlESWPobc4k5m+Qxnb1JYfaem/ze/9JT8flK5SeAWEicnu9ksSK\n8jgv71OCo1PKsnGC8W7KB5u2MG1MyCrTvd2zgbB5w3Cc97iLThji1lB0/TBt\nAJpqnQ0Trg1cVVw28esM6g+qLAh30VG0IlWtK7N+mrlOZmhFdWLH/Iq866m0\n2Qy/MwU6F6+wGqQdPBmAtMO7vg+CUHDPJn/iBOAv4vNLX4STX68pn3ZQmG5O\nsfSGDjTzXf4ezMzenMkts31HsSa21e8SY66pzAC9GMLAT9Ii3Lg7XyOyMbg4\nRJoWWNRjEz1ic8V29mMoCAe9uIL2NVhCL2Wkyxs87gno9qAl/cskpfbJNO52\nY0Fn\r\n=DCK2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"6d6109493fdb6408c46b0360056a03e1175cbfba","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.1","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-5ee4803-1615504510954_1615504563183_0.8660354827839292","host":"s3://npm-registry-packages"}},"1.1.1-canary-7c52b3b-1615560023836":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7c52b3b-1615560023836","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7c52b3b-1615560023836","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"54ebbdd4cc109037c714fac026c5bf881150acd1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7c52b3b-1615560023836.tgz","fileCount":8,"integrity":"sha512-cg5c54P0MMj6AUTexxShZ2/VUz1wZpzo+2LRC4MCX/mRVNvkUcy9c1KBB5wOQdUXrTZZSk7zc3lOvXR/AyVQ4g==","signatures":[{"sig":"MEQCIGNgZJMeZe/Sq4dW2E+HSTfl9HEvGVTFgQNh4q/91Rk3AiACFB45N8movmBxE0yckNcgFP27UdwxBSclkxyoHdz8kg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS32nCRA9TVsSAnZWagAA0J0QAIgwceWFz35z5ZXRWMPn\nIDCiUSt6qxTO0GOyb3huVm8K+5TJEwRgsb+WYZcqqMQsndAwFTvj0Nfe3z5l\n19NuWd2AnUFVD7/3d3C7h70nQyPp3DXJzekrs+CtkH1nNsJHlhgiq/RQesCg\nMSqnJThfPiQFeQrhTkqPepIm4NOsCPTB+Z+FNtTU1x8ajx4xnYSN6oAOSWfL\nkibl9iWxfZW+fWq+u9lEG60p0B10a5ed6NG/qhwfDoVD0NPi0GZUmInPQ6Sm\n8NTb34k+pvaooFVbFbb+MWRnvelCkA2D2n6wsDZlZNiJdRaPnVQLzi1vX4T4\nBBHOwK9XXsBXCkcga/sBAvljvl8vaPeM9mmpMY8NWEAKDNg3kvf1JpObeijf\nBfENRlxmq3xZJDMQTUFoP7Jx+SXohc0XQB6g2fpDYZ5PA/WdYCeOnBsrmaGM\n3or2FSQxsb/XvZWjGd5mnu6v4/6w/hZ22wlDjZtW/RxXUx+DAPyTc40IlMTM\n+9lwLNkShPo+RN5I3jXa9lGZwEuPruil2rLuYXuwpJXjGPxEkatVumAMQigs\nE85chkg5KdPMr9gkTtdHZxDDBiYKdWfAD1IK4ICA2uorlToCQsrK91hNIm+V\nOZsAu17qrryk2QTgoQPe6JSbsikJGAroG33+KYjyxy4JsuupgaAsXWSIX3Ht\nd9FK\r\n=OG6Q\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"06be163dc30e09cac7736308559230d747a257d7","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.21.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7c52b3b-1615560023836_1615560102796_0.19667101680602062","host":"s3://npm-registry-packages"}},"1.1.1-canary-a35b410-1615585902465":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a35b410-1615585902465","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a35b410-1615585902465","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"48d88586e6fb848b83e6bb3cc115ea0c6fb443a1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a35b410-1615585902465.tgz","fileCount":8,"integrity":"sha512-/j3YyhW7ovpWKPw9BZNNL4fQyOYC5GWantSnxgGSDDZ0Rcz11kTBhS5fnxKyyiJr2UApuCmntBU2KkzaPb/dEw==","signatures":[{"sig":"MEUCIFbfvExorfwX5uYxUsuIDQ09Wd0sCHmOedfuTPEy+79YAiEAiaDDD8DqwcgxfX1yTzCaJ0wjoiAoH0ABe2puzuCuJlA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS+KoCRA9TVsSAnZWagAAfIwP/2Wtvv93Sa4935OK3VSv\n6+svOWgEUzG5iwHN1t0EkUM0cOcW9+MzmfMB5s8PvY/W+8pXzVycnX5wCzg2\nNxGaRzkala/ezWArk/2M5cJLfvvf5Qa+WVnl6noeKll32vOxWZfoZHtHvvta\n+dmu9MkUHVPXpzCjQOaTm5lKEDvDIWmd5gT99PeVHXrYMEzBSVj4NqsIw/c3\nXpRAznOhpNS03nEWQBglB9LaBC9gOAsHHyxxWBbFqggdWibi908YFjU5X3lu\nyG+IS3+y1SEY/EzJ+rB7z6sxD+xJvwFIXaR2K+dMjp3BL70rz/v91vTehl+7\nMTgknBFmY58Jn2q9IcgkP4/HfF5fC5mnRuJMxK6gSc2sJgKmFrWExWcPhsuQ\nXc6dG2d2OiEJDeofHSvLH9VoiTqHPbKKEvgCB3G2varqRISImhGpqRb08E9O\njJFU5vKNQYjWK2IhVtDucKZbWPF9noyp43M/1Fm479YF4vwpsTTgTDwDP22p\ndnKkn66v9uF7y7Xf/6KcoqGYh445FfIiFwGq7ymeRymN6ERYZNmsflyBArdK\ni50TnOfgh/SDVyXGGXJvqSdjh60f8L2+R0mvZb8mADFYmsxUHYSTcAf4md6j\nr6RnBDB9C3N0Q8oF0iIGTaw1D6pvV51qAraPPbwW0jkVKDGhjfM+jvWKBqOj\nCao3\r\n=ClBO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e6637ae8d510b2cba3f49bdacc40056a4e392a41","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a35b410-1615585902465_1615585960443_0.9644346444936029","host":"s3://npm-registry-packages"}},"1.1.1-canary-d8e39ec-1615694045382":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d8e39ec-1615694045382","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d8e39ec-1615694045382","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4394e6f70f1f1c873fabd6832c05cd7ce9b6061a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d8e39ec-1615694045382.tgz","fileCount":8,"integrity":"sha512-YDUWFOMD5E4SaX8ODrEcOrORKu2hhJs3GJAjnNq7zADd2md+iMZRP5u97tLxpFTygXiTdhNKcHAkbxfvOnkKOw==","signatures":[{"sig":"MEUCIQCHXoW0zAmr+4nhN5GVKnoImjq44d7tp/YvFcwUjK7JfQIgMJvSsHmCcb77l5JT/Rny/9oUoun18cjdPiAjsyRjCM8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTYkTCRA9TVsSAnZWagAA5kEP/1vh30LDV2MTxxpAyV5G\nbv/47f93WbjfIJI7Rb6pih9impV3xg+w+mOuJMSoDiwdv3wrQFn+HBkdEyF9\nEE3qy5HkLdzdw8CKgxrBKYLjn31Fbf8UYgD1labNmN8NEq9xqpkzUoeuoi/8\nj5bPjH3Q79cIFZLLTKNThgd8WPVtMKCGqlpP/KLgEHnQl8ECP+X6zvlLKFDB\n4MdrfYrdwBLCXqxl8tcCdGbW0RkScNormF4KQj7PgB0HLYrdyzkz9YwCy77R\npnALKwMqgW/ufdyMncB8oQ9gJieKbebL4YJU2cbc1dT3cZMFFj+ZcFrkjsPK\nF+SagRwGxd9M+C24Ms81ijxr2hF9e2UTwYzG/c6lX/tL0MGxpa6AmhE0ZMEo\nUUA5bgTs26Gj4JmYNjbEkXGGkVdaWOU8ebuhu6sZaZhMT8ZMllBvF6auXrFt\nXBsBovChcR3VFoZzmLLvr8TL4rmVTjhMI4vbg9EJLixbHSiv9zI6trVFdET1\nRV1zM6u2WQCmzGOJ4f6JMC2ez/LhuYiFVXhxz1iVFdUxUkGK48yz6Siq1QRU\n2V1FN3VXBmZYhcn3CDZy5bmN9GMp9b5lzNcr5TD+M/0kzYF6E6kckyRDHGVW\nttFCzp19DZvF0Kbg79IrEIk/EYbK3Y/9nxBJOuWQo+HzfhAGFmNR7DLsTiuv\nJRB5\r\n=smy2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d4d4e93fe8378f1e32113742a23a10d4c47a5489","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.31","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d8e39ec-1615694045382_1615694099056_0.006338883404237272","host":"s3://npm-registry-packages"}},"1.1.1-canary-b550c60-1615752338803":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b550c60-1615752338803","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b550c60-1615752338803","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bc7a7f8f5d1d1fc10ad146e1d07422125898f623","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b550c60-1615752338803.tgz","fileCount":8,"integrity":"sha512-7dfndlVLisY86aYQm5K6smorQLmjOjc2dgQ7ZateYh1YL073KYTUJ6vLsm4wDdqcldxi6qkGbLrFpiG1RfxFIw==","signatures":[{"sig":"MEYCIQDFn7fEIsFZ//EM89gGhJkwnLiArW0WmAvb771ZCxF0GAIhAPEGtiVGPdr+rzcZgydE02i7vEzx6euxD8zoYUPSymQe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgTmzDCRA9TVsSAnZWagAAdewP/2D2pfceXxkx+CgQl9ic\n/HCsNOOE7NJvHbvkj2fAaxb2qMCDC3K/Bq5fCpmTVDQsQ0uhTYd/V5KrU7Nj\n4HfIdMH2SGKtpCZqaJFsF7FI8/yCg85pUsW8utCpuq9hMJj/H5IwtrFpCAVu\nyEDdD0BleWFyFzxe9Y1I93Y9O3N0YRvRITPbPEtM/O3GUEHYxaLhwv2sxk/V\n83a0g2bSz6DHUVUHC5Nnd+w8dAgb1rOlxr1Y5Syd55eTDFBFAE86TKBnXeU8\nQ9nxUFssA1//A8ilYPllWrTxVMkSgMQj5Gbukw4w8xQdrryMuAGsTfyTgyB1\nfYAjvOBpwW/NKyeBskTbksN0I6TLF4/zvL0FIZVS8613GvPaZH453z/X98ee\nK/df7j6wlWWU4OZ9QEgz28k33kXlySFkoySM3CblIW4abCPIGKtlJIDCUGkt\nh4ApI7jva2h16B+V4ZrgGBjXTMlTnyGjzUDih0b/NpcAXv/bZNCNtJw5pRjF\nD3QlyX7MZNdQGNm8CIhPZmmt/l6ohYutfLIdGVRxufWYGwx9Q9qmRoi/8P8c\nN2JwFgzLxa8PCepMJlw2qwNohLaLdbac0S8p8LQmoarzm5M0j0bFM6SEead/\n4u+q7+fA/pzqv5BjmzBvTE0IZ0CwPKkjJEcgdos2y98CU5Gh838dKLjm/hHi\nPG97\r\n=ezhv\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"cecb1df3ab1200743d36443fb217f94b39b80211","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.20.32","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b550c60-1615752338803_1615752387311_0.632160818727495","host":"s3://npm-registry-packages"}},"1.1.1-canary-b538b7d-1615850164778":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-b538b7d-1615850164778","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-b538b7d-1615850164778","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"82b8daa20b7c9d384bf39ba82058433440ce83ca","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-b538b7d-1615850164778.tgz","fileCount":8,"integrity":"sha512-XK55U1i0ygPgS4cGezdJ+n0DXXem/TpsboYVh6fiKmGvj5zK9J3c2YU2DqauRHjRezI+hWzGGXzH61uGEfTJgg==","signatures":[{"sig":"MEYCIQCX98i6yCc+HTsz4zRMLZHUV6iZ7hwVTyw0qw1gJKHqkwIhANHRwINyyj1DhrBXfvpX7Ytj9I8eLItG+9w8sM3FxURB","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgT+rwCRA9TVsSAnZWagAAcgwP/35k5VP2NhbXK0DvGn6u\nv30TLi17OvPOMqJGv+4cgzSc48EGs9+8TVd6602NyHgp9BEK5Z6luxKFnja6\nM7fmMOZ/zo6gFkH+74LUNUNH1XhbpUKEJnVWdeBOHfFpqgxftfK5rHivQ/A6\nPFfn4MKm+7mqjgTt678d+06BaohKZTtevxOOCebEa3G5SAa+aHn5rPH1JbrH\nHm/ANWOsQ7QrAJVOvVTgcqpVXXPXLcfAgKv9KK+Xt5jh9sljrxVZYvUK1lkG\nOFVPqaTBW0tM37DxxpWeVEwpBkXH4NhgvaVtMJFKikHgh6uvJYzjWap0kJLU\nnsf7+4GnNpcr6bOEz/tvQKIzHShyhaHZk26xT7AZkh9wPSSkcqrIN83VLSsh\nnXiEraKKevmFGE8hMwqM30u3vdd1pFTlRZ/X80T8tPbI8JC2pulKd+rAn4H3\ntcE2W9mmQ1lhPwhsQmzs+Hxx/kvgNNXz+mdZcoQO5ZJmoU3N8FaPzn9PQZpD\n1Dxbj7OsI5ihBN48+a/gLPc9ULcCwiBTw0Dgdt9T+F4MRoQzosK+9CBPTf5q\nEwfH5zSLobLMtXvE5Gh3YoQpbdV0R/J+NvxfjXjrJbMXt792bM8uJCT5lSDq\niUcgAzgPeQYVVfrk62xM4wgkOO2jlvohUDIejH6+BE4SgZ+nGxf+fiwpvqSZ\neluO\r\n=6EZk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"00242a26cea1aae7131325888df0cc70143e8027","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.2","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-b538b7d-1615850164778_1615850224071_0.7671026968824117","host":"s3://npm-registry-packages"}},"1.1.1-canary-9e46d0a-1615883131543":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9e46d0a-1615883131543","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9e46d0a-1615883131543","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f5964c0fca26e80bbbb4ce245da64ef49161df53","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9e46d0a-1615883131543.tgz","fileCount":8,"integrity":"sha512-cux3qeq8GumcdNM2/PWouYdfgWAUyz9wfDJ9KmUlgNOoHCAT2+SXitk6HO+9MHkHc3RqhDbm+jpFOKptTrRExA==","signatures":[{"sig":"MEQCICfJo/uSUBZY09E1nQDKBtuH0U6fAdOjllwe7wFR9qheAiAcdR0nfJJaC5i+gzESoTAE+ppzgCFvf/uqod+m2v6GpA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUGu1CRA9TVsSAnZWagAAO4oP/iHuoqgRE6N9uL0QuGoA\nt0Ccdqn5vd+1P+EdK2ODH7iAGNWH+zCA0L/KVxEMgcwAAALoSeqg+Gq/csLF\nI04CcwaSoQl27HeyzL3Bs+T3FsZd6e7j/3QOCHeMW+9WiCrglODDz36QJvP2\nuO//SXYm7e7pNGbazuJWbkRS0ZxNCPXdxdveW/NZ4OJCSdFiP2df90Vke77m\nPd5RngT2REmr7x0JPOtO43pAgH64mxCy8RIXoVue823xNOdfgKY/+OV7i2jP\nXgiwv8Fr7zv75L514KaKMvlIVvHQ1Q/xRu4do/tFduoVT3RyqBMnrfSRPo84\nTgVmvbECH5hiQRevQJshnEj/B8G8CYz+F3YMANwygyNO8KF3EOvQ02R8nvRf\nBG4QUY8NgLiPWVJv1iIemW5JIWjOHMHWIxa0zyn8ZTVt4FQP3y1NswCh1FUs\n3SJvY7r/rfB47eRbsKFUimLI9aFud1LABkBzgxegA/HqZyg3jl2znDWS9RVQ\nCn6/IhT/APeoI+dBwtOd1PjahM1YgIpvh3jaH03KDM6gkFbbEw51/Ey+xKB/\nMD2Pr9HTJTC/gwE7OLecu7048pe3TEp+8TpmMr41IJfRbWGBLKhIZG7skMLV\nYVYpSfDOmqf3HuLV7bfgIfm6vuE4dKusFlk4AZmtRjUOTAnD+gKUUY7jsNTi\nsX5H\r\n=OnpZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e88b07c585e25d4a677aee12d87d887ab96c3678","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.3","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9e46d0a-1615883131543_1615883188578_0.3621817124797926","host":"s3://npm-registry-packages"}},"1.1.1-canary-98af860-1615905150272":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-98af860-1615905150272","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-98af860-1615905150272","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fd0f470bc91302ccc117de4ab1969d548eb56c47","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-98af860-1615905150272.tgz","fileCount":8,"integrity":"sha512-L8n3MV9wTmlHB7yZCLTMi8ua+IzszCZEXhWOG5UL5Bsh4ULJnwY+KExmDhlsUYMQuVNaul6fE2a461VTcV0yQw==","signatures":[{"sig":"MEQCIHmxphpBxsp3ZfmmINTg87/kE0vFaxipwttrZ9AO9KKiAiAoGCcLE/XDFWkA6X3AKIUXc0ZB/reC0018m2qe8n3tnw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUMG3CRA9TVsSAnZWagAA8SIQAKR3jLDm7pEsJKNWDJXP\nDQjPx8p0RWr/Apc58o96vIfyGOCcnNFbGgA9Sr9UiR7QhZVRbTgRd311VY2C\nyzRvHeuufGmw5JKqNQsMjVAKEmnNOB9EZh1SZfWHk2iqKp+jlPPeZ6jzj3dB\nwF30seTw2ky/V4sbXpcQExMrY5oljJvGXaAaRFu2SHOCFshR7r95bUqCJOeg\n6vQvqhAuRJKMhu8wSC9csXqDXGk3OvEmQXaevBSqLFdbYAE5EqlDN3kZaBD1\nLO6vgHcDXX/YUURrKETOQStoBAkDJLZ1iL3n5FSOkIVMzQ9f798VA1/k4Xms\n2/v1BDfltBm3xgBMqUcxIXbfe+806Bu4tkDnVEaLdAPKg5ost23oruv9uYLa\n3kcEuROZ5C40V6gqZ640Knbs/NgjJLGovMQ8pzyHMydMHOWbuka/iUYNGhVs\npqAacCIN3wqmmKQffwGyS3g83drWy+g6rPsVISZ9nPG3UmEK9gWHlfSbGxSy\n5KJof/hkWRUgsOOA1P7chr0gC39CE7RBdr6/qpFq/u0zkZJYPRNuRdQaG7/y\nM5oXz3q3zC4Rw0q4V/A+ZmmPtv4w/H9esWK6U1saNYhaRxXAUmbACDizRmyh\noGA1HXJFoPaub5oABUyYTjDe7cEs7/QgebASVmp6nkEjgDo17p0aVt0adA1y\nU8Qq\r\n=vQgT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a6cda0725522f2a9de5d76ce3b2269a2700c27af","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.3","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-98af860-1615905150272_1615905206589_0.07730054270050823","host":"s3://npm-registry-packages"}},"1.1.1-canary-8bfc8cb-1615988155338":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8bfc8cb-1615988155338","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8bfc8cb-1615988155338","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d3b1620952864cf0e36b1c037cdadb23404160d0","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8bfc8cb-1615988155338.tgz","fileCount":8,"integrity":"sha512-OH0fgj3jrM9I9ry+6t+PX1Wk2Goke+NiOgJjvoVnC+fWOsDh3k3wk07IFQKAUpaNr9Nr+45D+90xhblS4gKfKA==","signatures":[{"sig":"MEYCIQDell4rQpMyPE0Z41HZBWBTr1mVrVk6jf9utST4tVXMTgIhAJ4Nw97T9swPfmLd0hKJEbMuALN3u4eCKcZaSpHSiJuU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUgX3CRA9TVsSAnZWagAAp2YQAITZp0VBehXL6CxXECak\nLBIzzF5czXIQWiygUqUawAWoeoyYEDcqdNr4mhFQokhgJ7k0Krqk07/PKIi2\nmCNnR84exMqWtXRSo+qd3oYnzoSOv85HXIqX18K+ujwxTG5bG8BkDCEbwJoi\nOLTL8qbHhUtusk9fZZlkAjLHcONcy9DoAVg6BoQt0CVjUD9eHTrCW4guxI7b\ncPLg7BL8/xq2n5OntDssGD6h+817q3TuA6YFkZ8DCYgb0YhDVM4D9py0FFpq\nekj35zgNRMjoiThkdC8B3cl4O4HYqQN4BIq+tnilc13+k5qECFeFfq56HyUp\no9I1T03d3g7B9eYYTZxQ0ylMRNZEt/uL28z/bQ4yESpJD/scqifqaQErxeYi\n1svTnL07pSMjUgSfBtrH8zDEYx4kG2CccVYntDyYaFVNyvmgXPBP1i6y5k9S\nIRuvHJeGhanLZXCfJMMDm8kARiASt1fNhe4jHPmMrzZYitkOqreHKEqmH5z6\nnwtF4nhz+7T+dWT4o+JDveO9tMlNK+aX9PtJ/++kXQI/WtVJYcHHYSblNas2\n5/lGZQPZQhU03seRoNustCvcLX2bouFIuv5IimLJdOOhVADOFDLl5LpzEMva\n9jyNa4b/4+yY8B8Jzcd7+9Djg/pc5lRjJLGWglTABJAsGrIm2WcTnpmjlY6R\nyVpx\r\n=9Mou\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"966926424cbe4b76186dcc14aa5798e663dae78e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.20","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8bfc8cb-1615988155338_1615988214666_0.9096917863576826","host":"s3://npm-registry-packages"}},"1.1.1-canary-94ac0d8-1615997123234":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-94ac0d8-1615997123234","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-94ac0d8-1615997123234","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"66d49b83d938b198d9e06eca4359f6f744438ecc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-94ac0d8-1615997123234.tgz","fileCount":8,"integrity":"sha512-58Wwz17Q3uZFWvB9zGXmD/GHGaz4aGrAypeXb4L1ww/u7DdYQdrSX1k5d4p9IM0e96oLKk7VTxzfY/etR6ue+g==","signatures":[{"sig":"MEQCIF+g5KgXCC2dkuTPpMatdNOu4U2beuJwfq8d35Wy9hbHAiBqE6SNxE4Ycnx11RHJcox5U7ztPFcScpuR9aLvKCxoAw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUij9CRA9TVsSAnZWagAAMRwP/1E5jFUlFS/YuA5Hn+GM\nlp6l3zLX8K8nHAE/DbnJ30O8kGJX2BSkjqo+FKr8pdp0iIukncY6U087kk3D\nCvWsaJLYKbT+JsyJOOWoi7I91v+tJIbYTKdtrFy3k4VimJaU5eiGBrNdCXC5\nfue4aXrIkqHQLUR2TqQUCOhnD56PUqVYe85aimHn9IOlm8k+MKioOOKko0fJ\nOV74erJ1iP71qKnIB/1R2EkkK4BOqSKnLaFOoztiWkwbOnIi27uD6e4i5veE\nR9XrDjzSVNmf81S6MBJIbsr9RUtmL+aIJTGtW6WOCK1/TC9AOeIjBWvOkXKT\nuXHdl0FKtmJpSHziF2H7rCDgIdng7NA9KWavEAmipzg0NJzwNh4J8zcir0Qy\neuNS8qAd0Dvp4yONySoEoEFiev3uo4VjE8iUMRrGUwOc/VoyC9b+jcFFGGFv\nhHU9fLKB0k4NU4rAfFrjvPch102IgtcbDGpcEn9H5Fa0Js7VUiNUleN8EeWo\nCVozjf1bnaYqd/w4RtcxqAo4Zg+x8lqqTgwfImXMuHs5LrQ91MiOyeqn6tX1\nbSne8faLda4+EjdA7hyE937xSfAyJJjuuAyZ19MkKFH623GduSHu9AquCE3/\nM97H67+Ha5A2p2mfKR3YlGtVnRnUMP60aRJkNIgt+Zn29pp83RbE/Cn3mw0L\nB6db\r\n=QDgO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"511c0ecc85cb925c074a97193478fc661e1b9b68","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.4","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-94ac0d8-1615997123234_1615997181256_0.7449485123636133","host":"s3://npm-registry-packages"}},"1.1.1-canary-d033a6d-1616044880033":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d033a6d-1616044880033","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d033a6d-1616044880033","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c8eb8238f3ff5da42c2e3565eb93b560d332928c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d033a6d-1616044880033.tgz","fileCount":8,"integrity":"sha512-ArJx/874Mc94KV4rD15uW95z2jeDRXE9YFXIZ/9jGyZV35hQq2nWbq3Vh16M6v/lgWwKEJcg00dOVIwnOZbD0A==","signatures":[{"sig":"MEUCIQC1Ng0QPc9dJndngy5i88O0xtU1UFo4R4ImLw0eZ+soewIgKLgZzR4/ogThyR6x4PeD0CDNi76OlrocedADfG4u8Ak=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgUuOICRA9TVsSAnZWagAAaUQP/RrCiy/BSUX3DST4UiqX\nqQgqgRaBIBIYi6kPgQQVWGnId+haq7M4oCed5oDBiiHOEKYCVzhs50+W5AMT\niKWjYwM4RJX6MwjOCi9hAkJcGmd4Qh7gopFikzf6iO5OxgWqg1JQm9zk04iI\nM1dbUtJiitRiPpfsvnm1L+A8Sl422fWQHj2+M1XSEstCvcZIKG/ZAGN8Z9CV\nHavPm/V7ifJk18cxahGRzMs4SY7H9848jmCiQpe8x5iX9yEpsUzoj3H7MKL4\nmlQyvST2NYAsdryOiMD8BZMzTR9cSZSjWLgkjPeIZEmSOuXO125rgdY98L+b\nLLA8Qht3H+BF8aTuFAwBKHw08r5evmoHZ2O3iOIFmktCGVyeYiNV6MthvMjD\nTriI3+pC8pLZZoO6r5xBEMogtKVW6JyAgR3BjyzGIWyZjbBoDDHnGwMnfDHn\nvIOYTIOX1OSDBidW5L53XszQYvbkaRX5czEFvlEmsuvd2itYJwm41pRevFjx\nqWNZMzb1Xdg76Xd7tHev7hBNBfpnI7/n3lwXT9NQkKgaXAQv7YcwZ7x/HR7J\nNQwFg4WmyeNL3l5Uv8DjmWWVBfJ3y2tT2RGexLqng9NqfBmibsaW2ICELW95\nghTjbP2bVQxlKmICpitaDQJfqs3nELCiDli8REFbWYRGH5ihL2r/0ohajI4r\n1dq4\r\n=1C5A\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"c966d5ca89dc110cebc59fb7378eb6b4b3296bdd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d033a6d-1616044880033_1616044935719_0.7866005238984264","host":"s3://npm-registry-packages"}},"1.1.1-canary-e2243c1-1616109354245":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e2243c1-1616109354245","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e2243c1-1616109354245","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"56112eb63937d3d9f99624128ef81ccef40af673","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e2243c1-1616109354245.tgz","fileCount":8,"integrity":"sha512-QGarCzeEYM/5VfJZi/Ug++XmVVN75Owvi90LtbAi/Em3yU6dFqPHbw5ZXy+6r2teRryxLJ3B4WGfp8sKnMtdZQ==","signatures":[{"sig":"MEQCIFUSv3Q4G9gpLBFUUBoxLAvBCBodJLu/vtzxGk6egDlAAiAstfpqkAcLlzWmIgdY5N0r6ZzGTX/zvEz3hN+qkCE4Vg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgU99gCRA9TVsSAnZWagAAY6IP/jIphP9x2iC/m5yFzV7Y\n2HFzvtNRx09hgI+bhcaBZC0+Ixwa8TzR/A/1DElojDLxzHpTZcPmvojCGusc\nzKHHI4FVlUNfG+J7Hd6/adLlZoitqUkLI+dwHjzYmrAvjJaY+v49flqouCUo\nxIf66NdAFg6eMQbjURvj3o05Gma+92IjIbVk0fU5zpkAlI72NuUM+K5QZC8B\nInLukutM641fLJhjpIgKmuJ3m9uZNC4tAKVfCxZ2wxopHYIqydnrdVAKhe9o\nj1cPbS/u0ClDRn6CtcK0JRkHAuXBxnGZMK0Hn6nwAGQsfY9uBajO7f77pwz8\nnvs+8maFoLXABG/GHed5NWqn04vVw8/F3f0RZAR1fC2nz9nZFntTXA/ViJ2n\n4VsxHt92DQpLvisVVs5RxEtWajOiLDSK7Idea+iEczqa2JpXw50gci0Z16gN\n2UZ2awAnDz+diYA4Cfo453yqvNilNi3CHRvA0uEfA4jIkIz+OYywAB50bgs8\nl1T0hn99qXJ+zPbjhrRjUzmEDM6462ay5Sm6R6OnQhhx4yTrS8xYPoNcc/EE\ntQXuTpf8+pyo5WMgV/43yC1QIZLgv0zziZ+Zfwy01bo2xRthzI/74HNRUyZm\n8Pu8nhIg0VDTggVde0EQM2R+0AdquiPcDkWWB7R29IE01y6iEyDgvJhF+iyH\ns5To\r\n=aSis\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"08449328a7c0cdb7190d45ae781c7e865ef8f22a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.20.32","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e2243c1-1616109354245_1616109407902_0.14092076395027986","host":"s3://npm-registry-packages"}},"1.1.1-canary-e9d7d61-1616109361245":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e9d7d61-1616109361245","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e9d7d61-1616109361245","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9c7817f520b06780e6917c07962de70eed414f3b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e9d7d61-1616109361245.tgz","fileCount":8,"integrity":"sha512-DP0opqjCZ2/5FjCyv5CuY7OrFVV/kuaDJAWQmKWqFcDNLd/UGOptO5hhoQZkzsJSyZ9d2xy+QI8qhfQ9QUBNJQ==","signatures":[{"sig":"MEYCIQCualig0V2Ed2ftB4MbFnlruZDcGG/qamxi4zElWSqVdAIhANFTEtMjpg9CbM2O7ZZMNALhHtKPZtJQyphO4txYn6wl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgU99wCRA9TVsSAnZWagAAQ1YP/0wnaoRa+JFQKxQpyAJY\n9HmsWbvzl9K41KYZ5Zt0Gsh5N87g9551tD2exz2zx1UD3B9kmLkdVpyFnj+g\n/61PPuDCM2tI6C64N6eaCXTeqeIxd3DyX2e8grBqbi0Jeb3d8g0bJI4vixQJ\nHiFmb99udQ3DPJq5gbWsGtlVXKV48/ke42dJ3AHxmhtFQxA66QRiuWUtnCd9\nnyGLUi8nlUIkla3gPWDKmc9jlW7GUJEq35t/WJjp97JPzFy2WE4xePkw9XYq\n+THJnut3dcEv3hshAUxEeovua9JYRUVBpcjrjRKOI+q0qB7iP4bHNOXB/19D\nNKOAhM9BZubFP3ndH0ouXECiVmhVNFBfuJgZeJR5ez55PwuaHSPGUntys0sp\nUJM9wEnF57WzVD2wVFA/7WYQBBePAubC17uYUDNnAa+o5L5f0gfU/hzQpjLi\nBy3/pG6WgnErghDonnx7LInzDupEPAcIcOMK1vpyuITIAFWV8jRj7TbsjHVU\n+P2WbrPhPSKcJd8NKC3HbPBu1R1oQsuPIuu27XEBir+3Uhh1zvRrBYfxn+eK\nfQ80UK4qBswAKeD5YX86xC6Pgrc++gcA6sugNm2jvMK61gbQdanDTnK8K2Mm\nP4W3VnZuZkpHwIWRaM1RNM8ZO3Vb2BQcOPA6v5zi4PpHy9IAV4++oUgkB8JE\nZ4P2\r\n=Xime\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"0435770869f2d434e8571542b29804457314e145","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.41.5","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e9d7d61-1616109361245_1616109423999_0.04322864606508636","host":"s3://npm-registry-packages"}},"1.1.1-canary-68c0300-1616142237901":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-68c0300-1616142237901","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-68c0300-1616142237901","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e5ce8b14110b2f78d85874d30fb3e511ffce18a1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-68c0300-1616142237901.tgz","fileCount":8,"integrity":"sha512-E3VQ71LBX7APIDAni+kl/+UtEKesVcrRbi/8yIa1x6Q2DWJIbCp8HemKpVZ6WH/OIcCaiJ5mUTzFhvEnkUw/7w==","signatures":[{"sig":"MEUCIQCph/lQ2NrINQLK+v7ybDXfP6KDsZxtXzwwB6Si27xjtQIgO3xT8P0EZDOhzFzfJVWDQejve80CmLXkEFebwIzqiKA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVF/RCRA9TVsSAnZWagAAtq0P/1pckrr00SgOFVHZPFSY\ne3tQTOqEKjampCtupAT0bOcWx4ZyYwvOr4uz589qTIUioCWtAVnRavihEFgf\ngC5i4GH2LvwXdI2lxSX1CxVeqog8eRk/zkm1IhPesJQ1pmpj6QTA4VOZlERX\nhjckgIF2B7BngNvtI+2Ou9JFoz3sBcm4OsErv2sZ56Y8PTjNcDdZWfGP+C8D\nXGvx2trRFxarCgKGq2Tf733LmhH8CoXiq1ASsJkCOFNt9tfK8yEuLnzx8UqO\ngumUsUSOf7F6Tt/O6xlsnuszyRi0iBxsVnC+Nz/Pmbxr2X18+6CCPNbq4aNc\nEQbdQItGq0weOvRJ79irtnRFVnIsHvRSO4EYAhbtq8Tx5KtAnMH3f0/W2IKu\nk8XbBCf+bo0DsT94Y5R2jVgtCyC0Bj2Y2mT5Abni4K9M3wrONskZrR1/Bc6D\nFRT5bwlI8V1UJ0+XetWbP+EvVv0BzYMThXei5Mo8dZ1ozzq1e9F7ogyHEJ2g\nq/IH59emBpWLSNul4T67NXZdMJwvSLMpKdGJA4ajJb6L7fpDF4Agv9VLDHk/\nvKE6hBU3UlkwDtkDtf9DcQyh4r+WLFpWnEbfDXQhABOJz/pJErfn7u5VTEVc\n/lAEDn1P9HHKcTuMTCYcbY+VtdYOAkZrgy0ElAPtZjH6DoCkkHahbYO1/zX0\nN1Ty\r\n=qk3P\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"03f453e9c5ea265f6a65b6329f3ce7a7e25f3be5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-68c0300-1616142237901_1616142289027_0.9961495384152308","host":"s3://npm-registry-packages"}},"1.1.1-canary-a3e0d5d-1616220452205":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a3e0d5d-1616220452205","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a3e0d5d-1616220452205","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2e9f969a586c02c42df02002839804bf747c2927","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a3e0d5d-1616220452205.tgz","fileCount":8,"integrity":"sha512-r295D+xjCrqH143Fk0HdFf8IX3l6gI2bUGFnWh/Jky8XOQRb3stPt4dKMn10tn9SUyAJy+Jqpkro7Kp4TsAQLg==","signatures":[{"sig":"MEYCIQD6xqMb75g3NXo1nhnKpvfyWPu9jSfsSin5V0B6y6oP8gIhAIp97AigN/7G/t/+N55XGXZRv6iLRRZq2OY51NQExAxq","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVZFYCRA9TVsSAnZWagAAwSsP/jf3BfeFQ4ePwwR/UCzO\nEb4v5mFEjzVVIbPe8vgtX5kSS5lags1z4eF+hDxnZLCCeB3B7SyNfvenBgti\nZrisMl5I2gEShM+cfAD3vieHD+Ym2awwGpJrMYvcK3w/ugqAYEVWHJ2uVdO7\ncZ0KorTXy1FWX6fPBY5KqR/Cif+e48pX/iH5D2/UzKhoeIk0mZzBXcOI8iqL\ncA6dkOxYHidAZyB7JMw9AkmjkYjbjqh8l08U2GF4IYCFLPbYEB5AoK6k1I1c\nwtnb0uxgug4Eea80gw3QE2zJKwqB+Q6nkrFuCXiUQolsHvJAuJEu8VfwoUO3\nmisQloG31NItCVWJGJKL1RORcl7IoTHsTW4FJq5XVacb9WaKt8JRlU722Dis\nEDWuyt6ycXzROEY2gQbhl7THo5FThCuPBkBX+DJoiahvlGB1tRNcHtnz9P7E\nCGJmaGwR/ChLe433lR2y0xVPOzuey+DK7cnUfAJY29s0AG33FJEs5RwCSAB7\nXHBmuaQWJsyfpZKEozcniMoY42RuCvBplLupOmfB7mrF92+2GmwEtJl9EyvT\nyg9Z4QCT/Acj403IJui5IbAbw+AVmUIqx/0xgaS3dzcw/k1pMuPZ5Llx3xjz\niyqUYz+s2rUsiGb70z6sufOIjh0WBOkMm/Bx8vAVKinkQlVQSxe+vzK/3FWq\nyDKR\r\n=E2l6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"49228083daa8eebe6ad9344d04cd118a13f2cbc6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a3e0d5d-1616220452205_1616220504155_0.8541997163141903","host":"s3://npm-registry-packages"}},"1.1.1-canary-e3c083b-1616369072757":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e3c083b-1616369072757","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e3c083b-1616369072757","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"cc6b68045e247e3d2f3d24730a8843b4117e5133","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e3c083b-1616369072757.tgz","fileCount":8,"integrity":"sha512-EUS6I7OwUqzZkK76+RakplwmuQQLdO+GeBttScSi9g0gHLyWqLVVPyZWVmSE1W12SXlC1EQhfF9ADfuViSKT+A==","signatures":[{"sig":"MEUCID9sTZC6j0GHyJ4m4NtAoPiRhVraI8XYu7Dd4inXZNNhAiEA/W9E2GlpO1ogYEVioIJODPBIJ8cQ6t6+dqLp+8z6c00=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgV9XfCRA9TVsSAnZWagAAjXkP/0go8/eP3JJgRIHU6wVi\nU7VbT1XbWbxc4PtUXZKnQr+yW0QYhagDmiVXSbhyzrH03FwEyljEm3qzEFyH\nYr6Y7RZMnzBU1lkFgi4d/wgpFgP84/j1/o1V7R4GM6qsgObbAZpdOdk2Jrui\nfhTVkRjDOnw/GtyXqullpdtSOjs5ZNLEUfBOUwvV600z9QXyOK75N0DChxvW\n0/VP2IiVmak+now9vg1CvN9kD7iLi/xAI0mq6tfW/dQiTyFJfXmYGKA0bSAH\nomp36mVfw75fx1WTHTDuonm7YeQYgzJdWpwpLBDh3PVoK1qyApsoJuIJmkR5\ncih4DkR3QYxyE9Ibh4hNgMjG5uNSXs+/qlmEq0154i1Qwhdxi4M5TZSkwwCn\nbzzQceMeYyBwvMmbQNBgYO0xId9rwJNIjEDTstjdTjAHNno4Q2vDc9PuWL6b\nVaBJQrjJobXyFtSMMht3lgmKkfTqznUpREcOhGNrWZ7g4E9m5s3+g8iqjbxW\nKUXMZEOjZrRKTY4j7v6wn0U53IT7eLzJYqtBmpcs+zA0vQ7Yscm9Ajntg1AI\nsGST7ghjkSv/Q4bKQYccIIgaKEGCTq3udcGe7vVj/0KnDLotiRooK53a+Kpx\nUpbb2Gf9qYwNIy9/ic451KD8zhUkdu+8oX9Obxh+BIko9Q2bRTAIGR42L08e\nEXiA\r\n=vEbM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"e392766eff7f3df695b06cbca53de0d24a43245a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e3c083b-1616369072757_1616369118899_0.20084194479320128","host":"s3://npm-registry-packages"}},"1.1.1-canary-3b39a81-1616376520844":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3b39a81-1616376520844","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3b39a81-1616376520844","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"97b738b98cd06ec65cbe7726fd88b904ee764b1f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3b39a81-1616376520844.tgz","fileCount":8,"integrity":"sha512-z7w9OOwVdiUWRs/WrtcB3eP1DpKURRB3X1gQssQQkBU9hEEwW5B2khwwWG4TNV+9Y/s4c0X4eSEyKvdnkezK5w==","signatures":[{"sig":"MEUCIQDPefiApm10m65UaHz4Lsf3GqwTk+tQ4/gytVtweu+jTAIgMO6SfIcCKdb1VIvzWMNkcpxSfyC+UsUxz7nN50A3O1E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgV/MHCRA9TVsSAnZWagAAjikP/0Nhf3aqKCrQQPr2wCeq\nF9miNuf+lI7lxm41MRp0M9TuTWe6H3xS4xZjjWIdshGuW4tXBpnqu/r4JUqU\naW2nvhq1QVEO2D2tCOFcJXnXcmd0D1IlprLN/bUap3qglNy9cUzaiFLQiKEL\n6GrA0l8U8qMptAuM4zuMcwPt74P/etuY7jstHYydpoZ5b99sZtjloZKkTyV6\nu/p2Gtso1+vSR294+xeJMPtTzpbpm7fNlV11P6t/F2C7YrNfPMJh2bQNdjp9\nGftBN/EHnyUEYsfkNUbWboE8FUES67y8R4hG6JcWC3zeHdoyepTuI/SqzkKj\nxaSGqe8IF04u7TNMAjOkeAnPoYOAG0dOhUzgiTZJzIHUD00BGFxquU5bqazo\n2tDM7GOe54qgNOnY+zZHT+mPpNbiaDxWiSZNsHyb5s2P8CDXMBD3CmE75lxx\nGn8pm2EnuXLzofqN21kKiIuPwoTEfTiPSy6fJ/0mXYVq5pY5DEa31kTfMfAZ\nMNAbrCfD4J/ziuMvlZDnc/BfjCwz7MalWDwqiHphj+cnRvKX7lOhTn3Zdf7k\n8r9zfeFXiuLLimjHi9NgA5I6lVMGGaFyJZ7QNaDoNHSiBBndi7pkfoKHVrPm\nFP9scf3ZfQuUZIlvZoXoy3J2GydKYQaTWjkJ+K+jfJm8RWv2Yq/oOpSc0YXx\nrs3l\r\n=7oAU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"06912218eb6cfe6e34bfdcc80fa535efe656bc1a","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.1","ts-jest":"^26.5.4","typedoc":"^0.20.33","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3b39a81-1616376520844_1616376582478_0.619563069676804","host":"s3://npm-registry-packages"}},"1.1.1-canary-0aeb522-1616393828933":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0aeb522-1616393828933","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0aeb522-1616393828933","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"038fab0b9860b27c2ce64c39fe5e8108976e5426","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0aeb522-1616393828933.tgz","fileCount":8,"integrity":"sha512-giMQCTNMMmUhGV7ScFkHLbs1KsITaLNaob86l1AEI+KknBMhuiFEBod5qTK/6TD/IRoVIQQb5pC2yEH+gE5UCw==","signatures":[{"sig":"MEQCIElTgVU0ebS/mRpiFx7wVGQAUh8mFuGE8rtchLE7aPndAiBkdVIzQ7i5cOVC7pcf1Dvfi3ySF8QTzuwh8w/uJpvTWA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWDagCRA9TVsSAnZWagAAphMQAIkCrcyK3T+6p6VWMdJ1\nsKZagR7uwjL45fYHac4wbZ+/qyivcyQ5OgUgnUhRoz7nHiHG4ThUzoYyzkle\nasbCwH7VIrcRcpfCHXLMJ5gUaaRHjDOzillyiAT0bWj0MUJ2VDuFIVmpvIo0\n0A3nL1yHyK/an10uztFJCfYtJ48IMeuz5ZGeuKFIf6g5ISHiPBRFbY7XTlxd\ntWlURx69C2BRjbx+6kc0SUmrsCYJPvQA5L48N2MzeSr7Qg3dRkfkqCPgX3qa\nkmqFaFFWTzeqiwFqbpfgSo0eAm1WXO+PPJuMvxYtFOb1I2RUe+SZEV81a/7C\nlelnDDysvnBSiztm86gdytVzoEe4ZtA9vNdElQzAn7z4+97h2bBURvCgomvO\noyqNVQi0xteyR9iUrG+vPHxMGV77wbH5ttuNTGcJgMnwKT/zYZoDIaHcrMsk\npxbPOZw+s3TJzduBXzM9ZCTgrfNJV+cq9smm4PSU4ReaDnk36gYJHm+UhnQj\nfkKspMnwdck4mlgn4hRGwQluhkWmYv03BW08snxwrJyeFuwedWbCW1M/AbdE\nR6SoJqJCZ2e/gMxLX5obF7EEGaDWUjEVDBmBB1xm5k0b1Y9DA+kblCOa3mfL\nAZiacYOn3beoDA2GC2WKF4Y6imbstzlzeeeI+cCKgWH/PWOu/YRTlpd7rrbs\nmMVZ\r\n=we8G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"3b0b89d916cf927ed6af38a4874a3b578fa83661","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.2","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0aeb522-1616393828933_1616393888293_0.8667138361949573","host":"s3://npm-registry-packages"}},"1.1.1-canary-7d49358-1616424988972":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7d49358-1616424988972","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7d49358-1616424988972","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fcdb477e9bc88e77f8d70d41d4bd85270ebaea53","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7d49358-1616424988972.tgz","fileCount":8,"integrity":"sha512-l9s7tsLIHsp/xybSTTKpedNF/V7PTmjMcBX1GqtN3xVAguAGMvE7WArotXP00U7+zZOMkjIyJPKAAYV8/qsvuQ==","signatures":[{"sig":"MEUCIFQ1yvvsK92zDmWTmECjw+jaNaHr6l917aGS6cJwDRCMAiEAl3YnQxEZsLjWv2//TNl5/FvM4JoS8/FvLgqPbXUPmLM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWLBdCRA9TVsSAnZWagAAGa4P/1TuTg9CpAsyBmW3sckO\n35G4BrQg+rnulGIV7LCyjNvZ+r6934a4azSfKQ9XB4OvCh9Tda8cUnvGwpug\nPHg45FqsiDxE4mIwnT1o+o1C6sfe1rrQS2Et/8kR6EnhP2BUpnFb3bdaCSVC\nGhRD2enVErDppbmAJMOTyMMMzUGkPqKYDDXdZk9A+0la5gFNlZXhiJO1Nc3Y\nMonHKtnkodQQm1vFQsV58mVMc99IICmVagZEUDiZto8PlzdUMA5T+3/seeUd\nhCA9ag/tO8PEg9YDiAJzaSaC0QM8lUTZa2g9rdadWd8GFPiew7RDAdOeh7du\nF5CQsADVejCkBADEYQTVmnc4seKkjAKG3H0iBGBCwyqSDCnTyxZ1DPn90CfZ\nzH010y2nskZPTRNX/XhrUAmNMl0h8jenHf9bwIjDumFR+75H6hEpL7nPSlMh\nCKsa63qRLzqU7J9SVGUYOMe+G282CLdDpOLGsspJD0+QMgba7zLLcq3vcH0Y\nvCdl+cQyuKWEzsfOY4GPxuaqrRplwqdOe68YlMw5UuB0jNDHa1vZ8GG02kI8\nbGZ1cNSReDazdSN/YWFKF2GgdutY1w4SQGSnPFvamaRGEMwj6JppjVB6eela\nyXZJzESddhVwWEGVT3DSZoHP8cqZiSHabYkkyai9/P9KeQoPZ7v5HrapabgF\n9nn0\r\n=+EIa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dfc1b4f5778c06d4a111b16605ab91ea730507e6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7d49358-1616424988972_1616425053113_0.6886791384553181","host":"s3://npm-registry-packages"}},"1.1.1-canary-9e8da5c-1616541306562":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9e8da5c-1616541306562","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9e8da5c-1616541306562","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e1595dd70b57dcb3638627964703b7200b2ff96c","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9e8da5c-1616541306562.tgz","fileCount":8,"integrity":"sha512-z98bZo4mvvQVXW+deHKT6Ke/et9oBySSD+mpA+zXOuJYbHXFqAQdjkXy6BsrNGI1atwhfrc49D61jB67Ji9yLQ==","signatures":[{"sig":"MEQCIFMMegnbteb1KtUNJOscjbUNSFuy9AUxEXTle2lBhk+LAiBvq/fH3+XQpgMmiGxlFbU0FraX45myzFNWxh20aEVZIQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWnasCRA9TVsSAnZWagAAzBsP/3eeyPCifA4yT+fpH5hh\nKx3+5j95k1JSvLg4HzeDUybUE2Bgo6spxL+ZkKXxVaevL5jnwBVWvGKopRfB\noyIGmhEL1AH9mTE1Fn1p38kf4Um0IC90e9vqvsD89DvyAORkV4Ohw7+zFO3d\n9aAyX1pD9+VpKJ662FjpXLmcWkHsa3AdSvzXVB7/uUo3+/G+xNPSz2sgRUEj\nGTSwEg2uNfNk/wIgHWEk4V8c7O7lQpeGLOQzd32rjLX8bZIV0CYd412jnH1/\neQvLWMuHDuIk7VMwozBYVS6lh5MlyEogL8Es3EU8oDsrhtcrBjquuxrZyZCx\nY2a1yoddk/fR+n0FMxWxa2B93IIkvRv/RIzMYF7Mq45UM6qHTBRDmzx50FTv\nhKABPECaTS/j2BvAWFJWx7vYLPIUOpSXht7SK2p9iWzdqM+ZBv0CIpUuAXZ3\nSNX3J21UCQMYU37wpoIwpyu1L9fSFpICtoYyB8nnvdJH4x+JV6lbw0GAZBF+\n4pzFwPoGvWRTJDqC8fsOhanINHrNSKqVwsMWZa2GgZOCMRqCatWq4nN9hvwd\nlJmsCVWS+qrFP4Nere2pY+SmZOahkqWqiDZXe1BJetJW+Y0CAi+yTv7AMXFa\npDZCMCTObiIsv8MVFWtuTm1OQpLqjSTMAgfWmGZopiZSUCvgCiHbElmpD6Sr\nEQVc\r\n=qd11\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4e8c6dd8cdaebf302e701f4bf78c7cca4a720db6","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.3","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9e8da5c-1616541306562_1616541356053_0.1162907767781074","host":"s3://npm-registry-packages"}},"1.1.1-canary-d9b6be6-1616596890182":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d9b6be6-1616596890182","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d9b6be6-1616596890182","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"96065091bf1dadc7e42a72bf28b5b0f7eacb3ac2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d9b6be6-1616596890182.tgz","fileCount":8,"integrity":"sha512-0bWkJf7RRyFgzHD8k6NXXdqaGRIUZ4PDO/ymUnqAO8XyEH4WTBJA8ubHyRbi3ZHAwFi6J/46MZgYyYunqFoxUw==","signatures":[{"sig":"MEUCIQDv+zUjYWmQ2IkAVhCxd7waXCItUPwqPjP9Vx2EuwIFmwIgbF7vmE1RFVEXZXw6ePBa3a32nPqhULfvWi8IEckD9/w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgW0/YCRA9TVsSAnZWagAAR4sP/1msDuAgy7LV16dSoarv\nLsnb4KBj1buoX0hr+DV0whxQ3FFhhmIrK3r6X52ToYckMk5ITso6YfaBST6m\nZZ8UqiWsw0sDUhCb2FnC4rcQXLiiNjvRVGeGbIZtOY1K8M324/CqFMOYufad\n2slbQGiyXEd/8feIOpcZ04DkDkVys/QnF7eaTS9emhXw2DEHVF9Qgl8w4bLS\nxG1tjiTvh+gf0wutX55hBpHD/hzVQsl3u+TwK0IzwHcS/B5Xj2WK3q+e/Sus\nA6JCVU0e5M2frT/vb5xjYZngMahIb8/fur+AlVMCRxWUfuGrt9+GlbHNCcSN\nlNRGeZbYOzqq3KA50G/OPLr7qauQ7BKCqH3wgEYwH4zhIV+rPJzUT9RjkBYV\nUhTr5gGmfqskgcERoDsxpAwcEv12hjAS3rV0/ImyIPnt4d4RvHULKFOEqRWq\nD3/nbKoVxm4lFt/TIzrAR6MZHkC1k9EOdjBDhjQ/kBNSa0CCx/XeHKvTqxya\nqxLe4rkIUEHaBI8sp8sNstIVNpNWRAtiw8QXHhT2JUYDPcru1AfP94HTvdBE\novpLXSNO0PaEPNLnyfIWRUIfHiQ8zF//B4xDc+RTeeTUKRQF0DfvT5lmxnAq\niDBcJPUKOHToL/h8MeaknDWn8WaRXqpHxstObxJ19lm3ensOfLCh1MwR8tal\nOXnV\r\n=olGO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"fa23e3bf9abde6ecc3745aa548eef6b9b46e4647","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d9b6be6-1616596890182_1616596951807_0.9548950108167689","host":"s3://npm-registry-packages"}},"1.1.1-canary-d312191-1616643438682":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d312191-1616643438682","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d312191-1616643438682","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4281ab06b898b5bc38f93be12dadc65042a6ce66","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d312191-1616643438682.tgz","fileCount":8,"integrity":"sha512-n8wqhXoIExdpjrRnE+a7BmpAZrLOd8GUdgLhyyuQy9f+fteqQU+CtYxvJ0kg8ty0oSl/09RJwfF7UOF+wij3IA==","signatures":[{"sig":"MEUCIDn2yGobziBO2Nc/Tos1AKKrPjrISL+lFxlpen+4N1TmAiEAl23/MururKt8z0GfpNVnsak8kQ/nkeGEe+EaO4erAEY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXAWpCRA9TVsSAnZWagAAhwMP/3PDoUJGGBBa6A628r+X\nXdu2FGqGxnP3QiJPKWFlH4LtTfwmaPrdyyqjxCHQu3ta9+93qG2oRJ3ur32L\nDo+yBGonrQDPAGKlGZ+qyjEvItsYwPW89RQzR+WxEQ0RWGtUmNLFyseJDQg/\nF2v4Xi/O6+l2UXi2XvCR2aq/to6tVwVFACUjIPXHtX7srnnLtfBxVa4ovNsB\ntReCOxJfZmgaDU1CRS+8/qz6fh0kvzji5EwHiuuh++VeAUtEeEsPOwqW34t5\nGbRl7xZuwwqDMIkZ/dS7V23kCX8j2xGf/3pHrNYpLaM06nhDyKmiIUPaS4Hy\nKcSvxdNsF+YqVE5uj/+wPM2rbAP6bB4yFW3OLf4mc/xkw+exGL84a0kSjm3U\nf28XgrDjK9XnkGVhZ7FYEZ1jEj+72dOygVDpjI2/NCEPl6AqCbk+0WKUNDdI\nZjq/eOCC0ge0jyGye2xfJ+1+SoczqUI98lniF8xFrDmTPnZoqaX3RPakhTaU\nlKEJ3yIL8I+NgOVRGLFUx4G536d5Mh0xpgoobOcfIBWzAtz3jvu+FEOezH/C\nsQpTJenWDrOkJVwyOzgKdZpqU5usDe3YkWXO02k+vpL8OAFozT43Tl1s1wW/\nNLXkqZ6PquXyRd6s2RKrrBYzAQ+mMwkXepMW++aosD8/l1re7O68WHLbBkgX\nFc1B\r\n=/rxr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"aa9cde461f2b60ab088a64aa0a3c93efcccfd200","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.20.34","typescript":"^4.0.7","@types/jest":"^26.0.21","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d312191-1616643438682_1616643497277_0.1456259963418236","host":"s3://npm-registry-packages"}},"1.1.1-canary-c6a9f50-1616695706194":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c6a9f50-1616695706194","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c6a9f50-1616695706194","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5c3941cde3e955029d2cfd4dea07f121b6385236","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c6a9f50-1616695706194.tgz","fileCount":8,"integrity":"sha512-LeH8rUHwwn/U0uB7tnd2u6ptdMBwwKEEH9oFr2jiJG2gOvUW4HJcrFFcUZ+gGIndvp/+/nSZxJsVuI98S8+whg==","signatures":[{"sig":"MEQCIFiUW9w3rHimNc1xvKkwobfXrVP0Mxgq7awjypu5Y54eAiB5v+fEA6NjheSdZzSPk5K0hTd3Yz2vHD3OWn8FKMJ7bw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXNHOCRA9TVsSAnZWagAAbyQP/jR698DIK098GjMjM7TJ\nCrVltV98DvbmPHPAKnlX6YdPF/xtCkir4qFm9qos6dTvUWu8ClvoauRy8XqR\ngHIQFRurSM6lNrgOVdwOGajB8RV2d42aTffntgHxnJk8nPXoyucz6tv6Gx77\nl+JuKgIm9aXk8KXxd2Fmc6Shbok8rUvEVIJ0+ba0FUJ871r++Eu9dG/0H71C\nSCqrWFY0IRDFCNaVoVQQIb2doyMoAE4e4oy1BeuFyxa3rYBzj8DALRA3cBA4\nhjfqoFIfwPxPTVy2P66kRWuJhzO0ryX3EZ3iRDpxDy+bd/CBs2yBPj4/wDLH\nhUwe43MHI9/lwXf0GbiIemGwQ52hiwsrThTthaJdSTi5XXPGTKP9ZApSB6Li\nOq8oxLVkqxoGj6ixQ3oJiT3LBbgk7RWcvYNzGok654Hxd5zYrPdbSnPz/Rs6\n2uMi/JjOZggAu7bFJlfyWd6UDaiLe8uc7e8ypoBwv7UnZB+BJB0t9zrSz8mb\nU0+ASBPCWxpuduDJ5biqK0z7+DMV/+EffLnXpiEJJKYmw72Lifia2+olYq1R\ne36ZMVymKzL4i9Nr5NQGNPtBFrrANl6ksmF9uz9Ze0983ptJbNyVslxH8tBM\ncNRxn4CIXo9brjE+10wC9jWv+8umlNNS4FbXqMll3ZEY44cH2hxWn6GVOHif\nvgRB\r\n=bMwX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"76919f5534179599d4cfee00dc31805d032aacd3","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.22.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c6a9f50-1616695706194_1616695757488_0.033838190030037296","host":"s3://npm-registry-packages"}},"1.1.1-canary-0cf9796-1616792841962":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0cf9796-1616792841962","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0cf9796-1616792841962","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a29855e85717b0195d519c5a95452b4878da1087","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0cf9796-1616792841962.tgz","fileCount":8,"integrity":"sha512-LPeCKUBy7E7rWAXWlp7b4Q8RAfzHzZVUHheaP0Ltum5CIKAirfCrMB3hPvirCUl8jXA7M7gM25qI6OweR0HbIQ==","signatures":[{"sig":"MEYCIQCvXB42XfddFuGuA4/D1KARIhOljtD4uowA9ct3+2LseQIhAMU2/YCx0MxnIqJ9CgUX1Llv4CzQKPcnzOgmbuejzYw4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXk1HCRA9TVsSAnZWagAAXsIP+wbUUp/zE2EIwDJTnAtM\nNGTFTc6kGJBV0i6FYqLZrn6shTG8hJeG47xKwSxX3Vck9pcblU1lPxwmtcAs\nCc1xsUO5mCwXzRs4dwOXn3d23TkmpUjGtmIeFAwuVmdSQdltHIwk/DmDI1do\nDRiNUVxO6IMWmbUT2mi2ytomEX+oQEjJT+gLU16tA/J4v93pRLFXJktSUNps\n3bx03k97kGItYh5fgskZEomUsoOYkw8QNLDhPjjmQ+eExGsTZQF42v2mp8+n\nudEFJY5sTBWSyNtfnGFN+JP7dzKkMTxDoG4mJWL8i4DlFDcbjAz6TBVuesQD\nZl1AUG8dUtKjRpAmm8azzcyT1twTafRJikSmKMVBREJs+tsPqqfvA64eagW3\nVFsJhJEB0Tqwt2D4eJrQphvSEjaxVScGPS9z/3Ki5mjD02fTtmYFkXkoCAYf\nTvghZEZS71ayL9VJ76b92M3JJLfxk8J3VtHly9t/TsLD4tWQci9xwVb2B1w1\nGWA01YZVsdHU11KTbQ+mtXblSx+YJX8G8J/hOYEtr5Tb2csb0fpUhB81lK6e\nyfRN+zaghHu9oyzR4g9QQX97QJXMSnOdI8aqmc81sTDJpkShT7053hpfJWls\nqHBo0X5zuupDzQjgq9VD39boNfGdc2RKZ+chgXBOSHL26XN+/sA2FzZSM3ag\n8nlm\r\n=qU34\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"47f068a07fe578fd875ff82e8e3543e8998223e0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.42.4","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0cf9796-1616792841962_1616792903244_0.5044583897737327","host":"s3://npm-registry-packages"}},"1.1.1-canary-d4ce30f-1616823863898":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d4ce30f-1616823863898","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d4ce30f-1616823863898","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e7cbba38f8560b4a85985092b6c8deb738aa26f7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d4ce30f-1616823863898.tgz","fileCount":8,"integrity":"sha512-J4FwXWXv0oGN7EuN7oWyGYREMffoMpvhMgELgPf1KJn3TPdMZT8l4o3IEekrU6dQm18CsRm3mJLSxSxW6vHoew==","signatures":[{"sig":"MEYCIQDKkb4JEDzE8p/HZfzAiWMz5QmM5dKPyiWyND2tLvzoWgIhANANUirOdbHn9v6f4ZrkhQQyshrqTUZ1BVYfdq6Qk2tN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXsZ0CRA9TVsSAnZWagAAxAUP/iaC+eOMZv8qDEAp0cJ7\nL1TBavlVUSTYt1Or5il29amwbzj76V3xrvsCBW2QgBJjFztge6o0WoZ/0xLz\noo9X0xjK96EDXutTnwuXSZkb+6wyfOS3JImF3kyJmuuhyvYOOPhE2AWRnOh7\nBCNd0kMGhzRr3IVBoVEPGl2Ko8Jg3jTvwdKdw/4cthxol11TphJ0MVaSAXDw\nsX2raTUYV/AtbVKDYmbXLxyO7FaqjEXOe3ddc+MyuiHmDODLmi1MUlHaEJM3\nOAULfTwtwH3ueqmK7C2GnOfH5jHDR/5OX83jz0bv/jfS58dPktVTFMId93AF\nyxUVCkUrC/YH8HGp+TLzkzBmIdmdAUy3ZctoO+NaQTZ4q8kPSSO1QriafC/+\nAGDrKcA+h0ku4JnLgXPm7Y/h0F3FYz5ogGzP51q0YxQqmjCrvXSM/UUQyTgO\n2zsORMoYD2+EKRWCVkWHYKM4q9b4LxvBWvvtKE0tnCJ1BZb1q/uO3Z0YVAHN\nIm/oaAnKPbJlQXMDo1mdlKR7POQXn1fJJdr1e8fbpbNgNzeaepgHSsQXQTbo\ncaZOAFlklJSSywt03vF21iFfJL8+H4pkkl/9a/TipAYTl1nSDFS9mrmLxoee\nlItVwrx4WHFo36bv7junGGJPpspsIfDQ1wTEbL9DRhfT6X1r0FnpCIFNzW95\n4MUR\r\n=FhIP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4dbb557f6e5dc7f56bcee0e462b69d925a8bde99","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d4ce30f-1616823863898_1616823923628_0.7240230645180641","host":"s3://npm-registry-packages"}},"1.1.1-canary-d0a4ebb-1616913025554":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d0a4ebb-1616913025554","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d0a4ebb-1616913025554","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"12558882eca4fb7ea40d8db9585c3c40286e711b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d0a4ebb-1616913025554.tgz","fileCount":8,"integrity":"sha512-1xfLc30rEeOTKHWT5+gE0FZQFDAPgJRfikOPTJMaqBDY8R80ID7GYb9LOO+yKXZU/8/BB9b5OzFknwcU9iFEFQ==","signatures":[{"sig":"MEUCIA26xq0MAzuVwEsdXNOlCefIc1GFIXZFgtVceNwTzxCXAiEAgtIQjjxJP5Zb6Z6V9ul6JsXKT9VsvTif6hwd7HVK7DI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYCK6CRA9TVsSAnZWagAAYdQQAIajvQ4Epdghrp7vw08V\nGbTYREp8d/XfUseZLIQf8C3d3zIXx9mcr45opP/0odXWE38DO/JPS5J1qoKc\nuviKeicjNy4fQSwqhWyKjyeBiM/FX4HsW86YlKo1RwPd/j3kiy0DXNpT050M\ngwrZ7lAukc3djbMLXmXBmpGE7ozc0UZh2hY8G2d1Eb+JryB0f2HyfGHPjwfL\nzjN/Q54RP11HYUooMzfXgNhJz040axRQKrCyJszn6XOLiyafDlqsrZ/+ttqa\nTi5vY4ZGpOiJwZtZLHKL9A2XaglxEhfGHN22jmP7q1rzrAYGTDKCOtAvBtV8\nP4MxEjUOHnNUT9DA1CsIrTlm0zKlqFhefuSa+3nFKmF1MajoWuR6Da9E34WL\nUnldUzvkVcrg8NI1e0Ixdt/imt1ty74hLpoFkH3LXvDiAFdALMMo1hwXhsb5\nSsOgL3WbzGJU7eR/vJ0jm4ZV2ZmUa3WklS+/4bRxYqAT5janUm8Dwive5Qn5\nqOwsHenUlxd3+VieMPDJ4VeyCL9z652GoKjH6PvmXmz7Ef70LtNBXcIoFgbX\nwbgsSgTo3MyhXQRZF0H2Of+u1NBRa+YK4uoYgmSn65j/Ri6T1wAYANg0mNg4\nf+fdJZCXZ6BvZfnYVFr+1WxwGgF9x8MJZaspiZ0YBsnU3aDax+5bflc07dWg\nHDsu\r\n=aRPW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1e7cda14961281681019f5191e640566d256e362","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.43.1","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d0a4ebb-1616913025554_1616913081512_0.004938970090222483","host":"s3://npm-registry-packages"}},"1.1.1-canary-cef6442-1617031481510":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-cef6442-1617031481510","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-cef6442-1617031481510","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"beaa6e1545a268ef7d9d4accf0442e9622ec2ad4","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-cef6442-1617031481510.tgz","fileCount":8,"integrity":"sha512-Gjrqmy7zYi7I9KQTuyZ9+rYt66cHxT0d35PYIWhGMsjOo1sgU9TalT3dmh0Fy2zcJr/BCBW9Jo6rmCrlbOHQNw==","signatures":[{"sig":"MEUCIDmvfHoYn2hVAKUp04lvjmv/+FlbY4oV9JHuIdAx4UASAiEA7NWhZMKpJusZO5pOvzRARIaXs5eNnzsjcjc7kY72zqc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYfFxCRA9TVsSAnZWagAAYe4P/3zjUo4pPL/ZHyPrxXHJ\nejJ89ti3X+fMwRbmVv0raurDmakPoK4qZc2ZwMqYf3q8gOBKr3pNlPF6YTXt\n8kaoerpxNtkHG1KcHddYwpe5BdYaOinA4Rqx9CvCWPJrjxS0C0U5BGKbzwV6\nBkoGih6MpsIh4NmAO2Mz221NtVGOIXEqOjPwuacFjIEq13vcpTXYL9NPeeii\nRiGUe/cgxWGj0dpQ0q15yRyXQ5emLF6H4TImYjwG2jP4olUrx1AMGJUEUFFM\nZY5JUP4MQQ1kpfxtkIwG9wtoOoIl6HoMvfj5xlrhacD9UISUuvOKLCcAK4/O\nOnFq29ZK8fKmyiLyUwhBZPyUJynfC2h97ESPcW88Qvq5/HF7EVcvadjvZDyH\niBL/iVNhPUIBJOo2UF4r4+g2myZ4KMsJFcBx79993R76sNmFAxSOkwjgqbxR\np8I2RX1nWEBkO/Ip5JOT/msgzIpJDjhVk7RrICA9Gy8/EAymxlIfAtpTU5JC\nI/4c9dXlRVoKUwTTHM5R1t5jHSuqYY3+yMhvKGlM5LSldrtj9Pl0uQIAsdp2\n+Qm7ANXYcB3WRsGtlbZw4C4EirmqvNJM5XRVPkood+qQGu5sQpi4nOwSsYpm\nwtuiiiKVLwIQfRJ8IRUYzLNGbjiF8QH7slh6W+XkvhzePaCBqZkHcDfV2Kj7\nxP2D\r\n=ReKE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"746f284f348b10ebd443d28292bef573bdae4ab0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-cef6442-1617031481510_1617031537503_0.8887476904234826","host":"s3://npm-registry-packages"}},"1.1.1-canary-1dc550b-1617038482209":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1dc550b-1617038482209","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1dc550b-1617038482209","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"5dbd75eb80346a369d82b403a075b0c2ad82dc44","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1dc550b-1617038482209.tgz","fileCount":8,"integrity":"sha512-U5queZ/tIl8G0mms/nLyEE5q33/C8H2KSMr0R34dBnE88WLwZJ18+LRSLlWMAALpQguEqpKL73QhLSt+TdWg0w==","signatures":[{"sig":"MEYCIQDLaWMGaeUPgeH28NdSi0FBdeh4LbaBracV6TALY20ELgIhAP+OILejN8TGRyEEHcL+yWZZcKzuZJZXCQQlTEx8cZ3c","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYgzHCRA9TVsSAnZWagAAEigP/ijvrrd6OptAeHkgP1zZ\nhFBTEzcO8FA/DSo7xaVcaEssDUHnaJM/H1GGz63SMom1lc81ovj8TWfqpnoW\npSfEd4ZEyglPYt1MGmxihukd2Br2k4r9g0eZywE6LrQYCQafiE3FjhKvU2v5\nAzEzJbpeeRQvXcOjger2tIA8dVrtpzFUQERT0DhxPlqrV5aBupBszK3uDE/X\nzLpymUo5nqmQ+jlpbNGuDxarXpSAeGiVB8r4ljIF9Ak/p2tPcwygOLqUna5N\nAWNzTUfd0HpJvuwyliJmnvcgZUYepmKVDOaXbNH1CeQzoLkfmtVGqPelrlvp\nqsncwJrOutKpltYxkA5hLvuGlvledfd25sPXpnp+Qn1IDDGDt9bnQITRJ0yj\nfekeOdOZMqgfFKR4tccX1cImO2VcxHl59jDPHDLXWGW7EIGmpgmv6z16bOXj\nHuNWA+8U8x8/+JsyJZ3nhyyK6ZFow/wc2fdON2isd0m6FZhFGqd0RmNoHt8f\nYF0GrS0OpY1FApt+6TxK74Rpu0WN17xuON0EijfyuiXIKU13WNMMOlyve6XU\n/5pLVxSrJmzmprEjL1Bm8xdjAOCyrp/GWk7PvbujlUfXbGQzqn5uNKHtITIE\nUssnR/oD3ryuCDP6IK8gn8azNwzmEn+vuq+3A/1sFyZF1zctpjJInZ5LL8VZ\nmcYC\r\n=5JA4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7cbf0095811de3920f024e30c33027ec77dfd080","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1dc550b-1617038482209_1617038534792_0.6647878833696141","host":"s3://npm-registry-packages"}},"1.1.1-canary-36a6d8e-1617142438959":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-36a6d8e-1617142438959","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-36a6d8e-1617142438959","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"93c061b89ecc4dfecaca00c783bea8f779f4850d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-36a6d8e-1617142438959.tgz","fileCount":8,"integrity":"sha512-znntTmEbWJuYRLWdz/EFfpHC4IKnHi7lvgnM9PxcX/sc2VayJevlkwerMcdEjO5V77nXxlcfqgdvJffauHenWQ==","signatures":[{"sig":"MEQCIDvrf+Hqo8JZquDS5ldxkw3B6grrYNz1aX5WnFKoU0syAiA20LwrNbygLTy7eiixRGiqEzWDb8J6h6gsDTfL+TgpJQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgY6LYCRA9TVsSAnZWagAAC5MP/RJ87pDSK92YnSuaIGDE\ngklK89WvaDI1QC4F1wFUw2NHjm5vFo7hLe11apRAQEvwgcR9j1Qayz1q2Jmv\n0p8v2f6liIWnqRIjekwl6hfhgKkH057l0999tC2Pj8/05Fgyfwfi3EfYgOUI\nMFxMb69RjY5upJzUmU572CaSVF0tZ7SgMTYw55YahUiLPTF7ADBG2N9Tbfm/\nXmVmanW4OIQTZ/KKvxcc2vcbmItZ9O50fPcz0Bnu88qTKTp8TNXKVGDSEcPE\nvC/CpwuhLwvHINWlaGW9Q6KKi0G6WJ1bGVgsHetOt2atrRBeg5qi15tXXRSx\nhK79ejY5C5wVIJ4bnVTuB9vHTAXppZvh1O+YZBPU0wtfs6UNxbEeTfMpJtaw\noKFQsTjv7kOMtZyDwV1ZqaUpmQYPr2P0m+a+aXs1S/czzk4lWTwAvuv6fHbo\n+TBcV6HzplXIGitWBzqrwD3h1FxKxcq+b4s09lIiDfN7rvf1DG+6LxJoUzeU\nwWrS/MHsRuwg0yfn7NrXVnWILZ5giUFb78lWCg6v4rqXPZbaDDLlpG97rVtd\no5Sat1AsqOBV62a93R1odXZtkn9K5Sd8ahiFJnB0s4xHzVUKtZUEy5JVQZzL\n0CT9lPTxhMeMGA6DTuKkXlQa3YYHP7pqHHLtwiKiuZs8uRl3eaH/0nc8omdR\nPtH8\r\n=qkIg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1fed8aacf303748b8b203d2b8e6dde103df6962c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-36a6d8e-1617142438959_1617142488317_0.5513014762649264","host":"s3://npm-registry-packages"}},"1.1.1-canary-fb9608c-1617481017009":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fb9608c-1617481017009","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fb9608c-1617481017009","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"92a9e1d90e440044ae08b69523d814b533b7fc46","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fb9608c-1617481017009.tgz","fileCount":8,"integrity":"sha512-fMXWtKr0kYmPN00jgwniqCFUMhzjQspqzjx98wKAJeJQTnNyEuZ0o3NL18c/xB2BsLAu2/YW6fP3PEaKgh9g6w==","signatures":[{"sig":"MEUCIQCG3hLe8wPfq7bOxL6bb5kk/EJy92IUAgwdt+5nQsnbYwIgFamM5/S30f1sZOKrTIvtrg4hsAGhbV3Tkv3zA+nqjdI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgaM1yCRA9TVsSAnZWagAA1UAQAIbs6p2UX2/uUrSHmIxF\n7iXjcqq9LpeykNJNKb9e4FOEQnK8qoo7dZJ9htxgxtAjFkG+QsqTFlD/vSeL\nY8cp/fjfTpNl/SxRc/SgpcjzWRpCU5jbWtSRDzrOqeiJxry0qZPwYLxQRr/y\n3Ksz1Es/n1pgf3jTGpv6qBB1Nnke5Lv9tDI1wEakDjifJPS3TvKxw0cOyF1O\n91ptjONb+2EEvNOZgFR5x1gxFar1N6qZ+UdHGGXAoCbse1E7ph4k1uI6p9gj\nm4mQ/mxJZJ75qDIONNT7chOG4awIrLzwjI6RpUI66mVt4kPgHkt2qZEh7clp\n0cW1kogk5928VS+gd0A8ru0cTQslSQpfCMNUkiFBE/OEzNtgJd/Ulna9crAe\nApxdLIF8QBDOyO62Y5wzVDsHk6gSnC2O4vuCQvKIHt+3AJ3HeBX4YyV408qA\n6154I72cqVIGmNG5u/O7KaSbn5NTlUveMIA2sR1tcgfF+e0Lcw4dKUY/GcZU\nV3unSXbVOYLyxwnN4XmxGHy5xFGfVxHer1j0sPnQnw1mrfjTV8dMFozZBdy7\nGDncWHdE1IU4Cs4KxNRYkh3aKE/wVdQWd9cLtjOeFFRf865gUuwaENwOj1ji\nNDI+Zn0SNmkvh2n9fgdBYrSDhXyOLoaBInig+9iMQ78b53xgsJ2Otha1xBat\n9rjc\r\n=9y4C\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a36b9ac9e4f1828225f6541a1ca3f724f3806624","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.1.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fb9608c-1617481017009_1617481073558_0.1988390839561256","host":"s3://npm-registry-packages"}},"1.1.1-canary-8cf98e6-1617647342641":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8cf98e6-1617647342641","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8cf98e6-1617647342641","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a253870cfa6b7ef9513aa1a218d2ffe6db8c9a9a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8cf98e6-1617647342641.tgz","fileCount":8,"integrity":"sha512-t9aDwBWGqeyzdT93d+e3lINj9QYeDWZ26sfkXi+eDyBMV2Yuq53IjaVY2qkuwajROi6KE9Qt2U18drD6X3c0dw==","signatures":[{"sig":"MEUCIAQ5S3uSG2j6sZ6ilCT4f5Q6p8QCABgD7zVIuxMKpm4NAiEA8papZiok291hoNV80/F7MP8fBTARu8AGtzzDR3rn/k0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJga1cwCRA9TVsSAnZWagAANvYP/i+G5QrlFr+xm8vMBdLq\nlR1WthrbIncHy/aHDS3XqcWDdR6HtUTdmHf6/nqRTpkshY0MUn0W4jlkRrSS\nJF3xSIud29NNBXla2BnngPeNuPD4NmK4jRhFEBYvcKIaabzj9lZFdbo2P5Lb\n74/oLAjCMeoNus6P/QXVTybutcliPPatIlZ5nemJLBpcTPmJ0p8TPxO4AUFR\nCeKp2PRt3HDMVWcF0+GltJIvbeGixMHpnUayfdPI2BejlG7D2bnxGQOar+Sy\n2iivQdPpM7gzfRWt9ft/nuTLRtX0KcsfveNbvmnC5Zix7TYk/Sg1bX0AKEBR\nfyx3RwEuAeGuTByo0TuzjQD+0BVr3ezVh4WabqyzUUQzLjPiLySh8sz8eDbF\nnNygSc8uaBWOpV3BvROrYOhVFFGSjGKKUAuxLNMZlGLRDsYhezH92Az6wSWG\n9Pl8B0wdLVGJDWHGiYGGY7WIlcu3jeM7Oa1vyXfUlzFyDZB9IbJwDkwu6c3R\nwIXewdBVG0nZVxYqqYE6kUVXsQLtNDW2N5b2H4hjkLQDj3mGgwuSyEQlQaHM\nPlthKm4Ckt86YBIvrrgJPwpfF9LDUe2/EaiJgWnRQVUWEHCvOhg6OKU42R1A\n8rSLhPcSF+tNfcufMCNrA5I+RAggUQ2Tam0aOnHN546E3cc6hucxSVl5uKWx\n68Db\r\n=XLPH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"dececd280f9fe1ab10159e3f0feb3c05d4b8c836","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8cf98e6-1617647342641_1617647407608_0.3973282913623537","host":"s3://npm-registry-packages"}},"1.1.1-canary-4849cbe-1617747227075":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4849cbe-1617747227075","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4849cbe-1617747227075","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"611cd8515c81b8617248b17f89bba66b13c961dc","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4849cbe-1617747227075.tgz","fileCount":8,"integrity":"sha512-SI5s4uiGdyR/f/axpoW2RpSQmWHHQYcRtiljmmLeRa51kv4TIFJsRv+YNHcZYsJr+ca1UTEqC2+dhFAORhjUUA==","signatures":[{"sig":"MEUCIEEkM8Vnyf7K4jK5I3oTbCNivZ37zycBEnk4jhywM/4LAiEA7PpMdQ1wwTBAjZRDIdlVRyndnKmSUzhuGVG61YnXbxM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbN1PCRA9TVsSAnZWagAAsasP/2WXzh7eWiFYEe+w8ksO\ndeu4+w29L2M+AKbFMRztlAPc+80rCcBkpOAEjET7fqCTNrNJ/Lb0L6GhONdG\n7YhIyKcl/EMscANz5EXisuS9G1aSZ184FHEI3LbOjDdbfyzWtmYyiUHm2Ib6\ne8yrCms4iw+92GXBsbwpZZUqpdJ8cRu4RtKJxIWQUPlZ6wWQ5sEPaWLbgLzT\ningT1LgSSHZs00yn0cAJCLs/HcUGbTvRiVmjuc04cL6CyXOUrZLJG5x15acJ\nwBmm49pJT8zxPXjrNtfoqVi4vMrFd/fa0J15JW/Og6QiQEFlhX25InHQAti7\nplWyUUnctme7i6/ZCaHphpZEHS0XpdpLSLpMxtsTziewTHR0KqmidrjUjNCe\nElCwG0DcU4NoDWF0Z/hoUJkxBHufBMI0ZkJgmKuk0hMk8n6/k/b+4kD91aRR\n31ol94MdFBu1qtbMjC0gaLPAUAnUrmv10vs7YFuQ52wK4g8AxYg/PwW7FNL5\nYiGhtkXyFgiOe1gkwmmh88l45T3SB1mwM4Ic/kuR3vdXUNTkNGWLu5UzrX4h\nQRIJCivgL1pwgoniEII2Raf5IIuxw0ObXwpqnBKqX0Py0fKNaPggkwpV6y1C\ns619JfNfya7gElJz5NRoFhwaaNXumtjHLQCx7QXuTTDSvtxOB9ebvw3CMj/8\nNLn8\r\n=bCN8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"965aebc4e073effe7ac99b12a5de8f3b30577cf4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.20.35","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4849cbe-1617747227075_1617747278819_0.5557950998088241","host":"s3://npm-registry-packages"}},"1.1.1-canary-d849564-1617833694213":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d849564-1617833694213","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d849564-1617833694213","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1bd8b78d7868cdfac2435f0d03db16a525944a49","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d849564-1617833694213.tgz","fileCount":8,"integrity":"sha512-qkbPfAuBeaHy85ZE+bJl4zSRbN/51DOelM1sOHKPnHel3lNrdpk4HloKy6OunvluAc3K8N4R1FZTOsAK9xLN2Q==","signatures":[{"sig":"MEQCIDv4bWAtbTJKOu+A6SshNE9Inr3IjFQPLFUS2y+0Cil6AiAs1kpPvkT4t/TmnXjio/ltj8vhLhxuHF/l4nVfGc9XuQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbi8YCRA9TVsSAnZWagAAkgwQAJPSY2oWasOVj7m4ibCW\npoxvbF2eHltjBh9xUbG0OYcrcOlKqcMOIFERQesz5stNp/GuoMP/MkwnixAv\nJcuX9I9H7wg/hEGYfEib1+lW1XBxKF5vGetufFmF61+fi6xREuWEDqmLXyK+\nY78K8jC79uxfhibEtQ+beCmiFu9FaZ9cd+60jujfctcNf8PC3VbB4u+oAfGN\nxKGuTdw3WWJBsvXr1X8G3H/bul0IiWSlRMX+Y39gWooykbK+XyJDAjUqbXYL\nVkx0S7mmcxvFDgFgk/94uAyZWBqC5STHGNBSZjcAtZmWFvx+u1CN0tn+vEU/\nHU5Uq3qrIwLmCRdzQsApqsT0ZHyeEdO1CT538ENBykuTtOIySsZ0uNhrUPyG\nyQCIVnq4JJUziahkmQeraYxg2kS0KPtScrcUjlXlyrtjoVkUVNj23yXbvvL+\nPvg1Dq0d539w5cORdcyGKSyXpV7+DVOU78q8m42l1mI+PvM2Qq2ItcrMVgC9\nbHP+6eVQQogV/T5Xte8Hh0n4Zj239VJcTcQKqVi3alHp+IWTg5KTStPOEQGx\ngZrkqNy2OZMwPT2HcMXExplbw6D5XwahLaVu/z9haoITv3qjQ582Zu0zVg1X\nwWLXljWPNuUdarWxeCsJ13cdpmE81u+1KrFLNmpaTFJFyvRPJo4RWSBawCfR\nvSL6\r\n=jGAB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"291a6dacd858eee460798dfb588885bf8f3e035c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.44.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d849564-1617833694213_1617833752029_0.42394015886634673","host":"s3://npm-registry-packages"}},"1.1.1-canary-0bba690-1617945900927":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0bba690-1617945900927","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0bba690-1617945900927","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"83c9136d14d0e1e69b267510dcbbfcd5f6a9d16f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0bba690-1617945900927.tgz","fileCount":8,"integrity":"sha512-d7HheXiVPu4EZnX9TtIVq1g6B6lancUOxW5JJcnS6KtqUbjlA0cSnjN3PNymocItBc1+Ja33GL6YMr0Tikhtog==","signatures":[{"sig":"MEUCIQD1UjB2bzCCJ+imQBYnYiAourz/hnKNmcUaA5Q6NHN0KQIgUZbFNqb9ZsNCfUSQ9k3/6H3haa5yuxzhMFn9PidkqAI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgb+VhCRA9TVsSAnZWagAAkEMP/RNZ4pzW7C9RJ9BSuCxS\nDiNg5kxb4rolUsG33Zb53oJ1FBAacjrWFiN9rXQuZmHYZ9ieE1hqRYsWba0q\nj0IIzFPg93gjalIqDSBNFGwnjoM4eHzyEDdPmuPtaBDRbZ5pbkIbTleyxzJS\n2imrlZrx0JNqTbFu0ZNyuGOpm/I7lbW4+Y7gHocIY/aWlGW3IllOhvsET4Jo\nJpSJbTLRMqPUI/UM3qa+P9pHA0A+IkhHM5Q4BlhL0t0iUfmvmIgCm8KZqy3z\nmEz/lifhOI+NFe3uc2oUWMpyRltO9tp0jdIVdu+23ErHQa5bOcFvH1cNAeN3\nIiEc8sP0tOZLfZ25nobUSRtoQ4zZYj3e+3yg7yH+S2fGKetVzzs5NpUaOwQK\np0Co2gdUUCjgzqieR5Rkph1tiCAtC7yFCjmX6fiyxrxSEqwaYotpt9oU0vIR\nen/MTBbJ74nubq75fE9WiG9w0qVHbsAsrIwZMdtsyq8WJbXPYwsg4ovH5OZM\nnuEuplS6VQeKpSd0iJypwWN5T57wOqaAz+xiU/s0PpH1ia676mbSSu+JxlJE\nFj/0F2WbWqWUKqcN4aOT7Rna2+Pgr7Gsm0J0myYE5Pp859BweX2cBVv2YtVR\nEkyqKHudzsSRq+Rx/j01ChzyNbhZyxo6vXmrnJLB5Dqlla4DtHU9brsqWrS6\nMtRT\r\n=5h1G\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"8d1f6712ed80cc95d5b241b8a60dfaafefc19d6e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.23.0","rollup":"^2.45.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0bba690-1617945900927_1617945952796_0.5744356447081811","host":"s3://npm-registry-packages"}},"1.1.1-canary-2bb2c8d-1618006766393":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-2bb2c8d-1618006766393","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-2bb2c8d-1618006766393","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dc4f929c7fff955057b9fe9c5bb3d8c15b3bc903","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-2bb2c8d-1618006766393.tgz","fileCount":8,"integrity":"sha512-0aU6dbJFbFiF9OeV75Ml8rB7wX72vfw0rvL5oBk5NSiJyV/9ly8wu8JxYkSsaBCr6QfNoyrKlqDedcqTqwjQww==","signatures":[{"sig":"MEQCICtQ40tEGkgB8nPpPtwic73jS4fwNxRklgWEQCJZT3mmAiA9AGQi98QSh7uNsCYTB00142iTs9E9RSqnS4x1P6QkJg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcNMmCRA9TVsSAnZWagAAQjYP/1+fytisrC5MMUbJJ7KK\npOx+e1LXCE0zI2aoZRFl+yKUeypmJTTy6iSJarl+Kg6j86taXadGOGdRqVN9\nZJQaCj/H9hL87WEFgPs9YwEu/ODn3MStlgz5FeDvJxAS5VZ5TL2mqkGP5Cyg\ntJX962/8X/4qyktUAzuKiG9jF+7HWiG8tccgX+MTGJ7a2VW9CMDoEVclTAH/\nKPEY7nkolRNN9LVLEnNABotMcpWFaHHVZYDSujoZwtzwugTbp7Nr9CQTvF9M\nHc85XvUmDRCmOklfmmF9Yn2d78ZJQPPP+Aq20SK7xgDR0asNLxBNPhp/p3u5\nRWN3K3mc83+ntpJdduXL0LIzT3EUqLcSp4MidvzjQGEUyoGjaHgG0HtjrAU+\nCEdy8Tyoe1wUvg5GdzDPXcpuMF8TJvyriDJZZeYEId5ZW8fcCUKSD1NGG01e\nYcPHVnxcUk6e9h84zS3Q2a3ezFRyGNTs2qAI2SAV8EDyTsp7sMawtByM/M0Y\nbWBvVsrhpUPVi6P2/dcDABzjmwD31KGtuX3BPDbxdJs7vee+ki8JndocPyHw\nmDF4H9nSRVbjNkYlWX4S9CkazAalEoB+m3Z2gvvDBj1cmArmtVV80fQziCYy\nLRLWAdCUUVDupmawdwRYxJdlb54IvPViRXOc7daI3fauS+XYEg3pYthQbJTh\nWw8H\r\n=eWeD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"60b9f5630e0f3026ed5f8b8220ca295beb1730af","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-2bb2c8d-1618006766393_1618006822341_0.257900425943669","host":"s3://npm-registry-packages"}},"1.1.1-canary-1f15451-1618031968125":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1f15451-1618031968125","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1f15451-1618031968125","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"df36ec0bed69e8e2ac93d1a6960de44d752cc824","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1f15451-1618031968125.tgz","fileCount":8,"integrity":"sha512-QItRhzxYD304X6RSP58SwQAqQPSl4yjngocVPjgZSoPQRauBstAezYyAyz7Rx2r2jevStvXGB6HCwAz5t/4RPA==","signatures":[{"sig":"MEUCIEivS29GxuNRwi0Rl85U0q072t0d2JRsoN5rK19QLW6tAiEAlLbAkGYEO0zJLICdiLQcdbiG42TiEOKdimhinZ73LpY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcTWJCRA9TVsSAnZWagAALCYP/17gR6EGGeVGWs+bljKs\nYnRk2fbaJ82TqJDSPJcZchDWAks9g7ezFBBB/H6QbmB2/6RoxqGIQNq/g6V0\nlg/k44mRIoSSxfybssx4N/9ZFhS9AeavmR8Bgiq0hC8tCtyv+F1tvYCKDubZ\nc2RrwW7ezLfRdcvbC/sv7iZOOrA51Fn2vDN2w3J80cAEpXPgwBclMh2nZlum\n4IfZJIkjYHkXpzVAzLuQyCNuANKFrAyV63IyTguxYR+hfLZ01OBa8Y+0tDl0\nbf8Q+8bxaYFoj2z7XipYSs/4X+a8oQ+4ZbODRnIlKIvzbNKUDr+QrfhUsMzf\nx5r6KfpEdiX/Cv77Bkp/V4yZpVYaFrr5WAxl9lqB/CNVT/aK46tQ6lXJqQ6X\nkWASMaTDiTKVDoYZYn+gLuzcwROjDNF+jUr0vzDg8lHNGE3X40mz/YsPo+8G\na9J1FJcCFrljauOt/wEVZMhKqdKWItfynORgyFVrUNEjr7IRsdxH01oY7cWH\n7vcjNW/qBH5BA0S+Ups1GH/peTyV1YA3G+eXOgBvtEQ6j6N9m4/VQxDSEjQ2\nFBX4gW8MeJs1GrPhRshV8emkj5LFd3wXBoNrlHDU+Dt2lwXG90dn5CR41oBK\nxPCWqIly+lf5K/y0hUBMSQ8yFuqTZlr+HgmTywaZ5dy++5eTIT6+Qiipp1KV\nQWp3\r\n=029I\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ff63dc6eca679817bfa6456cc989e7cc3bd72a37","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1f15451-1618031968125_1618032009262_0.8038380690153271","host":"s3://npm-registry-packages"}},"1.1.1-canary-d15e54c-1618265739056":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-d15e54c-1618265739056","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-d15e54c-1618265739056","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"752e46a8542fbb666001195fd3b0552d88387969","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-d15e54c-1618265739056.tgz","fileCount":8,"integrity":"sha512-IkStrWViiZBx1y0LCLzua1/W5YEkbkHOrNbQnpkwOrzfcTFqMGlIdxw0+uzT2R/zfwVGSzKPdWimfN/PXOugzQ==","signatures":[{"sig":"MEUCIE0Q2o4qugulDWrFWgK9uh/u8cvO+pPWs1Xd61DpbCcyAiEAgX5vEfnFX9CgULS6178vxOQtJkHjLE+PMcPyzWGEZdE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdMa9CRA9TVsSAnZWagAANukP/RgPoQUef8Bdk7OvGY1y\ntEbvOAM3HKdr5vxdbRdcwvrLnVXtYYcgTxF39AiYdAfvFbMA9QmwFsWYmfGN\n1n+IQe/zV1D/2cAi+OSrAnkOFefFzQvPyJw4tCbSLC99v7ifa8iQrypOgRc2\npKgLH9OgxeXP3+PZtDKSLjDbgmRCAOXCr5DCr3uco8FIL5VAUdN/vpIU/vmz\nb+xE3Dd45WnFCCwA/xlvb0UL3n0Tn1S/2FcHhSmjx+HcRf3k8wXIzgjz9kTY\nQS9OXSCxkUy+I24dglENWo3O4tn1t3L1e18YFOSrtvWytjqgnx0RKwQyFFI+\n9aRonMlpBQfASGTr3TQbEumCqn87kzJgVvJe/hdJIhD7bF80HMTjkR3B82uv\nsSoWq4YVwzlK5v/iekmg8TQFZKZX2xp8waSneDIrssWOJnYsgif/+sljcmAk\nexVya5ClZcqCxZiJFdpV1bSBveSHdCQ+kDqLtd4fTziiPA6UMDoiOIGKyWED\n9yb3Xf2j6+Fqmt92a7+JTZ0XX5OEwq1VCsZTAr4gsdwzyU/FdMro5NEQjpo5\nEFFbf8XqFUTTJX3SsYPuED304/YrVHFOmAEfEIDgvOXKGt/KBuOHv4NNcYgV\nkKEUHMR4TvfZqQsMDeS9E4gtbnXEZwskb0U3YvhClKcWWydvRKST8qtZg8vS\npQBZ\r\n=CoMc\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"62e12225000194f48a95b1b95deaee949184c73d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.1","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-d15e54c-1618265739056_1618265789460_0.953979646788288","host":"s3://npm-registry-packages"}},"1.1.1-canary-4e82c16-1618292263250":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4e82c16-1618292263250","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4e82c16-1618292263250","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"9d50a77412b7ed2e8296b0b033d1279de51925a6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4e82c16-1618292263250.tgz","fileCount":8,"integrity":"sha512-nvNcXRE9ECcqlLB2iO1Qa70g+b7Dd0KwmFdRnXxmt+2XQKna00eDcAyUnLEbJKEsyFzRu9Gk/KQGp8g7/6Schw==","signatures":[{"sig":"MEYCIQCmtU7DRXXVVhTRryl5DqO2Rj4zf+y73yc+VrnrsEAqTAIhAPqLZkrn9E1IV0B++XLhkOk6GOHkylRFe0Ims4Ul8fvg","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdS5bCRA9TVsSAnZWagAAdHQQAJnE1hmxNxW+uXAuNNd6\n2KEpcd7AoDaGTltVJKrEDurz5MLkStS0zHuiuFE1aQwYOt773dGsHKpe/KYq\nIxtuSIkjQUFYlEnaZqoVhIKivuZTzHbi1UK7TpP4L7cNwjjc0K4Zmaeo3qmx\ngqkDkDH1ojFiCjPTLl+lN2Ff61ekQSfefqnVxZRizhl1vbKo9oYojnH6ZL/n\na7tFSaAlh+GqJvbF2OA8ZlN8Rsyec/j5qi/smqKsX3b843v0sXMNVk2/6pHA\nDq5vfx6Auqr66WO+3HmeaZvrw6wMazwYUlIwCeISpcq7DNLuNkzELKKDFBj1\nHDoapTFGDWWvgNDSzU9zkMfRF7l/2tAtrKKdSkiJpYt5PZ7KUy6ly01cJVoG\ntHJf5gNVoUCcW32Z6pd5j7vyV99pCkYyq619LbKrwvZaID5/qTpnFzFnWjXD\nNxxKEwaPeZbHvpOSov4eVvMzFnIb/5lj8oDVS8HIlYa8+g4xoFLTOAjQt1Zd\nOKg/r8X/tI9QhkfBoClK4sJZkohm6W2o+KQqu8iKNNj3kuwthCdCHWzu3ww3\np7scJOF9zWYS19nMqwzGxg4frZeHoBB+SfJj4q7Q2T0DCEm8bDyOdTKnvPEm\njm1YGLLJaqjDsmUxzvQTe1xKIg9nLqUMgjFhJTU7X5QmazG4sJLbCL9gdJyP\n1zSz\r\n=WPXT\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"245c695f2d5a89cce14cacfa9501b90f85b1a199","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4e82c16-1618292263250_1618292314707_0.3784157010790501","host":"s3://npm-registry-packages"}},"1.1.1-canary-65dadd4-1618438532691":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-65dadd4-1618438532691","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-65dadd4-1618438532691","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2d838327e790636cfb6d0852030a464b15db121d","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-65dadd4-1618438532691.tgz","fileCount":8,"integrity":"sha512-0C9JeynzEhUnfEfCWW6cBPFlQFGzdwDdIAPqaamR8wjY0crI0dj73B9t+gfs4A/uywMy6NC9GjlYX9rbKGYH1A==","signatures":[{"sig":"MEYCIQD0nChcqAwf8pcW7dgEQrhGLWuE8jPemsriJ+V6qrQwFAIhAIwaB0i1P/XyulrS+vi4hSOPPOsBOErHbF49tWE5gNAV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgd2m7CRA9TVsSAnZWagAAPscP/1M00t3BCO8Oi2pFNH9q\nACv08RZKHJC9zkdokLdHoNZ6GBMJoUTK1igU/KKDpnpsWS+nRq3GrA2tUBgb\nLaH3DH8X9uKljBuYdhbN5CuiphYnVzFpVBiEidPqjizvhw6uloCVEGcE62ax\nxukb/pbjszES0pcKMT8Q670U8UnY1VXA/DoKYWvz8mDUjMTMxizIXm9Hxk0m\nl71uE2VQxwJeNW2H/oO99UDCmfz45jnZdrT90cV58HKs9B+5ptSKozprynoa\nHknXQQZzMKzt8JfokfVfXHJGiX/gf2uFvtYli1sqFo82G38Le5xBUhntfd2B\nNZ2AQVQbbU+VK+9FcrYn+oXQljTHXq2xXt22Tu+irAwQIpOnoG62CeebkeXx\nCSyJ+C0T6nOyTI5CVuF8mOmBv0MBeGO/yUJfHfcj+Vds9qUAf3QEVejnUk4D\nidVvOBtdmX1Z6lYOtqfABkkv4w7CfuR7C9cZqul7uZkR2rNhL9BD86KAPF/F\n/MtfnHS1fUgnpzZZNQiMR30uOAiunpbsSb1ditFSmh1GhS3O7SI9miP4kna3\neRRRbVrWBFGmmHSZjDFqcd3p7YxLIScNeRn37uY+ZqMaxwchscPrIlIOF5qr\nKtcNafRgjiFOcdhTn4LKHNoQxYKi5U+a46adQH6vKD4KfgLjRSXmhYYQwY5H\nOeoV\r\n=l7RE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"85bbafdcc5236f9eec3b8386908b7809e0317e3b","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.11","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-65dadd4-1618438532691_1618438587203_0.19806901075305317","host":"s3://npm-registry-packages"}},"1.1.1-canary-daad75a-1619146307841":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-daad75a-1619146307841","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-daad75a-1619146307841","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7d34417ee0f9c0420d4e1e769cf769c7015ee96b","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-daad75a-1619146307841.tgz","fileCount":8,"integrity":"sha512-mcR0rFsBfe1hrlYPR5xGrF6iyGq/f25MpL+L4ujILBzT2axPvw+IZC+TaXv6UgC7olZ2lm73NPJNTR4jaW8Rxg==","signatures":[{"sig":"MEUCIQCkbKZQv64Ze202DeqcZ4ruYws0cHrQkxoz9anKe4jMoAIgS+ozct+FqRvqhF2FXktwoMpAYH+gBm6c2fi5OcztNcM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJggjaACRA9TVsSAnZWagAAOqUP/0jbuQYt/gsOjAg3vYG1\njKI2HolcOIqQtNXru6D61xBHR3UWqzy9uE1T3v5Rm0pH0fswFSz3u6CFjP1D\n5J/PzooOm0k3kwt53FnohdrobkPAlAUYDdDzpWrjACW1bKN/OBMA+AAWxL1t\n16soBVP0ZJsn2lhi/jZ1H3glNDUgHm5rcSpHGXU5/Urxv1OhcS1/RN78Mt87\nO6vs8ouOO/1uz+b7vBbT8uBx0EjPhCvAzcEk5MnUkJaPclpU0lxf4v7TgeD0\nLBX1LJ2yOSsKmqLpkvt2danfDOKgFLnLCxooxN+bGFYdd2/t7rrK4l60n5WE\nfdf7agCuC76hLwk9lQabk6eGZX+i+QLOi5GJMHzmqBoEXq8XxYuhz9tF2uWm\nSdc/mVPQrLIX0t8QnBknvc6Ff17UVkTUEZvrXRahk9UWYAQ1cusjqjbNobi7\nyn9r4pYVjBjaxep+kV4255zBciXXol3fs+h6ZmawI25DhndVJw8RxcAbDnxw\nTwWKJdf4wSo3RLLSQtbO1M6IpsHpL9d/qTa00gFP1M7FGpghs0YVRkCaWnj/\nPlLJxNk6l8St90xugAtAwv5FPcOYJHD37iDeiRfVLaaR9bdlOUriqWpejCxs\nvYlV9QfDj+0SSXBkSUs5fDmpJr28dZ4+MhV6UvIp3V2sizcHx75wMUn589dg\noHzP\r\n=gaMt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ff5cc893a646a2ed737d48197e7902c3f1540154","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.24.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.20.36","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-daad75a-1619146307841_1619146367743_0.41659472989320556","host":"s3://npm-registry-packages"}},"1.1.1-canary-f2c6cdc-1619218187727":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f2c6cdc-1619218187727","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f2c6cdc-1619218187727","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"99115f8c56cfa795783f794f31a3529794b77eed","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f2c6cdc-1619218187727.tgz","fileCount":8,"integrity":"sha512-VdyR7PmmH57h928xC2X0WXle9gbvQ8Kxbp0qIADvkNbIx3KJ3oyxEVYZxeBya7L1OsZwTEFXpEjxJOkzqtGgRg==","signatures":[{"sig":"MEYCIQCduzOmf65OArnnSYNljc6/sDN8Wm3qhf6d2m9XXhf6HgIhALIYKk1ZTqWdNv9DTbe3sbVuVCmaAi0CFMJtV8EjGAwQ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgg09DCRA9TVsSAnZWagAAUfIP/j0n57JnrgCg919fUxaV\n8JlJBSijnH/p8WsGanqDyaMhP4lbqwpus5Al6KAo5RY9H++ntO/IKMr4SkoM\nol6B5noed4nWqYHKKGXHohD4rTVuU6mK8OYqK9OqWHWXC+o7IW5hj/DaBWxI\nxlxUeUXzLU2Rqun8+B7MGyR+Bz9ONeGSffSVM7Uath27J2TwFq+qgT1PL8EG\nMCv2pOtr3uVp7nlreP3trsxNSSfdiJ1CLk29mdtlb0SbhTkJAwRA0746LoNy\nOKRJ/rg48YO/oNKr4/6T11ajPir9iVKImJBx4y10wNEVIn/uRvxlBWEhzjIk\nokAaOxkTNxJYkkoboaGuHxwaRSqLXKNV2+mlCcGy29n0WzMPZ10WGkXrOlyO\nKPv7HsjZu1Z1plQo6I+wpuHTNbVskErV//dR9tsLlkJKv9h35W8VCvJMqisw\nLI+zmz2N7jMFyb1KJlBDtepLn4uvgKcu+GCKD1rGL2C5uoDMdlx+nv3HLL4f\nnOfOTShpmIhvySkaZ5rqvyF3+kNRT5AeJL1IrwgO/f1J9O1pVm55aMkHOOWO\nVs5xj5PWhipouHLklhYtiryPXZNQCQrMIhqM61wNRXN7d8WglG1MKhRUo0i+\nsTy6he32ajf7zlYEQvR/utgW96FHSqJ/WMuhDgahFVg8woA0Kx2NM/6KC7ZT\nNa/N\r\n=Xioa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"274e254f53c28284a4c9eb2a82042467eb842b1e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.22","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f2c6cdc-1619218187727_1619218242970_0.8786960499412326","host":"s3://npm-registry-packages"}},"1.1.1-canary-3bd01b5-1619552767457":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-3bd01b5-1619552767457","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-3bd01b5-1619552767457","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e3b3de6fb411e76d013dfe2e20b2e84b5af66286","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-3bd01b5-1619552767457.tgz","fileCount":8,"integrity":"sha512-ZpkUcZqbf0UnWsQDn094upJvMBoPKOQoUUaHiizf6FE11pH8hxQA8zjFo5QCrx1Z9u/xWG+L9+RoAZb/7XhkSw==","signatures":[{"sig":"MEUCIQDp5yTe+a0PVyOoSe5xlm/wWF3OChEYWJCrKY+idWYgdgIgS5eogKM2jz7g/Qe3THiF5Vle1lmDuHM4mD1lZYWsR2A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgiGozCRA9TVsSAnZWagAAzQcP/12PMzLzzUJTlJvmw5A5\nDzkG5EcWBr7mQeXQscnMP2LaMyFLau8QWQfCn1/cwPBnLbTaQf/JLOs8qBv9\nNea6/dIGTONWhPvvRsw58/10geU/fyRa5HnmK8/zgOokfedbkYy1xyTuktxa\nP+9EtXiVyEBzQ2NXdEJ41ztJwelSNxdUIrxrWmZ+gNVOwLixOIyb5lGiceix\nitOOxveW+soSBcs1J/Agl214FZSrhmMHlhkhc/Dr5HDyD2EbD6E9RqTv5NDo\nXM/Ysyc+Kj9fWA6Zw5k1pZrzYu2dXwkTJZKs9R2QcOTxPf6ehJ/h7/Qsx1c8\nQwUDLlog4WqH6KRHIuCZ+yKxTElYsdvt87qSc6jgkBDjyk9lM34Xf9IchtrX\nnVh3olHUXY/hTklXZztb4qKma5xjsbLtIQcD9rCSF3kCmgY7+K9CZmTjnPkC\n0XPGRJ6/Igat4QiTKvZLW779b3vLtFLSrJPkS5ASqp53fZyw1PkM5t60dtjO\nPA0Ugh9Cuh09DGrP7bku4fw650pD5Dpy/shOyU8A/p+QsOh/PfoNueMgeKj8\n+OHL3i4Bpxg7Tyxyc8vjRqR7mw+R4748NJKaQxzBzpDvnZazTOjg2VXrUnv7\ndFCsgno5pb1uFxnkGiiiJGiXjLG31KScwnrIVb7qaD5MX1ds78SJLx9JPTXo\nu6nB\r\n=mUF9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d72ef0f3aa1383eca9938a3d15bcc817fd24be06","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.45.2","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-3bd01b5-1619552767457_1619552819453_0.8663554025140479","host":"s3://npm-registry-packages"}},"1.1.1-canary-417a824-1619674717323":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-417a824-1619674717323","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-417a824-1619674717323","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a8731909082474d9630ea3e20cd7f83b359197a7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-417a824-1619674717323.tgz","fileCount":8,"integrity":"sha512-DPnrqTML7hbTFKRYxn2EmHOulkQi0pZpXhlP5P61gQRpjI1bmKWAan1UJyQ2j/OFsULiIhFoHMr2mn1jtyY3uA==","signatures":[{"sig":"MEQCIG/BlI82Q/LgvWMoIYllCG7TrjtzTQLW/ePfaVeELE1HAiBbxDeJyhlA+LrZkyIXZZZ2w4BPw5dt1hL32/mhy/9yJA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgikaPCRA9TVsSAnZWagAA1swQAJDCV1Abj6rwYzwg7yng\nGLMrWn9vaYRHZy9E4x5Il/mD1labXIeHMZmZb9JbjI6tAOVCgeilvFVuXqoJ\nMC4XMibc1LYPq7YWl66kv532iA9TtBggOrtX8p567+NPIsvm3QVH1qVgkDQ5\nB/4dpdKIW1l9OOQju0QasroZVilhfEiJAWMYyeb0M3ioJcxXF1Fz8BvsItBN\nbMcI4EqNcCzvd6M/ZL/ePwxciVo0bL7QmrSZ4hTmEpt9KHNHZcY+mwt7wSP6\nc65Jh4tZYtaQ42FyYRv7shS5g6gcgFKSDTEroeSGdulxj8bo/M+tJlQ6o7Hz\n3uJ82nQN/GLpfEUTDNS6mT8yhtrCY8B+RNQ6DGbQEjF4NGs9BOkBMwjNS8eg\nqlCo/TWgLGbOTII+sMgFjl4Zaq46XRDgDL3odpRkyldpHEik/fA8e4hznG06\n6lpUl+RtoXZeOTYpy/EFzCzK9RsK1J9iccV5/ERV7IsrCivLJ6rUY3zpjhj6\nvzOIQDr5fP149pMmzDOlelD/Wbq0v53kTRUYF2Ger+L2bGfW+qG7nyXSBR0S\nvOIQALQ8cPDzfjvmBPAR9B11lC8nKKmM29EpS+Zk6tAhoU9NfqRo83agiip7\nJWqMemPi9KI/3ecgM2bdzKITYzPaxr8DtxUhQrFMFpjiRssf/sGdzVgU55sb\nYRPz\r\n=f/Rp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"46e5f25c31effcb45de4723f90a65ef1720e3d44","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.46.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-417a824-1619674717323_1619674766885_0.5897201072480565","host":"s3://npm-registry-packages"}},"1.1.1-canary-e8eebb9-1619710294921":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-e8eebb9-1619710294921","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-e8eebb9-1619710294921","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0609c69b84f23315ab1cf039faa859fb52377f0a","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-e8eebb9-1619710294921.tgz","fileCount":8,"integrity":"sha512-s9I6j++g0vRMMpY6a9ss5dCpNYP/amEDLybSdqObqa/iVMQjt9sGtB0Qcib5tmMH8eZZerjyxSqHZ3Ubg30jvg==","signatures":[{"sig":"MEUCIQDmaJo/qPwDhZtAZ4MMf7zLuNrY2KleSluNNbfGuJg9FwIgMKGcqPU9scBr+AwaY0vN/l8ljjDvFguOAc07oKFENHs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgitGhCRA9TVsSAnZWagAA3REP/jHd+4m9Ag5lJNOewADc\ntt73Q47A46jLu8JBKiJMWd1G5yM5JbHSaLYdWUQKorB4wpe3oIsLIp6O5XV/\ne/0uHfiK3Ve6yJ9b6oumuIxgzS202oA1Hm93yArLSovUCDwrflYhRZE8+wUi\nvZUYl6u5oXJSMlg+v1CEuYwlJZBZ7YOO/6qn4h/SQrpKJES6FEr0fBqCD1LB\n1ab+FzqRZWqf3uwZ4P7fvUdWtMfBoj4+wzvYcM6g0u/0E+kx9Laszax7KVSo\nFf4cGb+NUe4YTo9O09HFW+XnfPTovoMJJNOT0BeJjV4wjssdFL8JUiws9Cfq\n9ApAAdOg+V4mceUNYsTcA9SOPgOaxLNpC77krdZUGO8EHSRkMLvTD9/n3t1Q\nRTH9sM400xJj23Xq0KMZWfnI6K9NsQmo5UchaWwPx9FHlYU95Fa+2jujJpbQ\n7UZ67cKfNu89i/xJQ778/od6jeayQQOjamh3I3khMYMiQjCIqII1lv3QAUYc\n1pJrKxyqvdPvj/VvuoD1qX6dzCUwKQh2wAfObwoxmH4vnL8ZawFv7ifOXli1\nqiKLd5f18aYhtngrSz5P9T+OLx5y1RPpJhGkgk9O4wBJJDFOW3pCG7DGZgs9\n/lvNsWXPwfIuXU8ZEn1KC/E0ZFHjbEYo3iZ/wyPbefEnEgnoIx5Ls4Q8FXtd\nKb2y\r\n=pDHY\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7bb5a0693842fd733e8158678c190e0a0b31518d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.46.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-e8eebb9-1619710294921_1619710368637_0.2704836557687609","host":"s3://npm-registry-packages"}},"1.1.1-canary-8501666-1619994079111":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8501666-1619994079111","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8501666-1619994079111","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"1db348aa65cd8c8cb4e0d2940a2f4567c4b92692","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8501666-1619994079111.tgz","fileCount":8,"integrity":"sha512-gPyEiFcTLhlqzVDoNeeSYj2qR2hmxBRS45C0KBFhVmPrwJr05Dn4/W+ErKN3HRN7Htii/kcafqCb8wN8Xrhb0g==","signatures":[{"sig":"MEUCIHvIvbRxYmrW0nvECuzA55lW0UqJD9/r6bJzlSxOFP71AiEA7Y1298uJClVfgkgoFTLQaDgl82Et7/5ClUOX8pEJsa0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgjyYTCRA9TVsSAnZWagAAOmkP/jKE7VBcb/wTQGGVRHWt\ntOUPyNfWPVUUz/9zeXzpPLOEnzZso3i9Au4Wa/7yndsIgE/E/fDa5rK2vrDp\nGepj8Dd4d+j+eIXjITzpjrEnfxtzYy7VdUgOXcA6fVTlLgHqqjBbvxi2hagN\nylgl963wqEfUg15asc8C4Gq1XR6QDozfaN5r2VvzsNG3S28MKc1a05oQW4qQ\n4gdDhBh/BqC+mnkzQx1g+2wx3GNxmbWVEoLzcKJ0R921eKUKXcU1LQzCpoIZ\niplKTUO71XPpetyovaNaGGF+I3jr8Kiop2noqWoiWLs0bvgsd3BGBUYtm49K\n8DypCIcjIXkhjUyIuBFexKgc8vliu95avxhMw1tuVmV/EXztNeHrSwMMxfJu\njCJif5p8Td53BErAZE7N5j5+Jmot+u1ZKQIfgQleuFzgMglz0LIWAi6wYvwZ\njvoqlfaZ5cxC6wtsmNHntBsFvd6hsEmKtokBZvUGwM4S2aU1YzEScK8bgOFs\nLVX/813SEGJWYa0z+VNrJcSOp+UHrqMKuCjVkB81cP7JSopbekdUrNuo5Zeh\n2juk5DwdNREl6mSiFPXSoLs6jRnSdKlBAv1RbGBbisN5f406UbWu7ry6dxvd\n+URo/BO7jojqpeCE7bf85csnF29UwCMA0o1ce9yM5fPrAyN2ILZyAiJLcSYW\nEHr0\r\n=AhVx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7e1db1f3dba25cc485452258872f72831a70c616","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.46.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8501666-1619994079111_1619994131328_0.23000850002433726","host":"s3://npm-registry-packages"}},"1.1.1-canary-dc34773-1620106081964":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-dc34773-1620106081964","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-dc34773-1620106081964","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"a0c8547f9afcb3b75799c0bc0967d9135e7e0b5e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-dc34773-1620106081964.tgz","fileCount":8,"integrity":"sha512-T0JX5RssBP7zr6ONgHQeCNIbta8iwyhBb+3Ssa7oLPP9lS2agQMc5abnqtlV2HGdXroJt+iOLwh+ZPOQaoU9YQ==","signatures":[{"sig":"MEQCIDnAF4el/64/HLf9kzWYUJYSP2U0OWwpm4+MBTsHJjaGAiBn+oBzrUsAPwnbqWG3xKnDNhm8e4w44s2YBmpZQcGA3w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkNuVCRA9TVsSAnZWagAA4rAQAIkteLgAe1ero/0Av8PC\neSwkYspASpJ0u2OTb8H5I7oPbVKO89+OuWKDlaGNzAN8r2wJkhmXB32UXyJH\n3MyeDNQ2PzUTgHgVfD1r73R6c0a/nLJizegtmKTI8gGj5VdTXOhRmYu8YpUQ\nti1/iwrsMR84A1AJGhRoyv+84NeWXT0a8VEs80HBbz7dxLOiHwYM19uFrqjy\nAtiv9W+c+Ua9NTEk/D472erZidNWOh0QRZ8cuTx2fmvWJiaBVPyb2zpvdQIH\nhgQ4MEIchqt336gwEVW49TfSmj2P3QGcc7nKY6K2LD6GSJAQSg92A/YzcOkN\ndiNVBaZmFwjLO79uhhqp2tiDZoW61KTvjBFqR9A6UId9JYwzkPZLVoJVRjVY\nIAof7dgDy1hANGET3JjhQhDJeEnft2pcMKkU+1lK3yOg2Hn8ye3DDCPDHTM4\nsrFhj/SmLSjKfEerybxFJM2Pf0Joqq5PWvT3FcFzi0tOpskmPT2iNMYHh1MT\nP+s+175n8VhigIBPwvGYfAYSsca4a9qHRZsTf9IanOVoJyiFKHhaaBoexPp6\ngpaD5lyEDnxolO4bP/aKov+jPKlt87r4JINkHu8WEAs+gsZdKTCOj0RjfoBr\nkQQmBnXvjqQr05Yow+4mh+y+ggHrj8uOAfzm2JM24lXwXZrn+3K7NbuFioSC\nJoih\r\n=9cw0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"4d26b1adba80c17db0e4800ca5c6b6a79609d8bf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.4","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-dc34773-1620106081964_1620106132971_0.18715460465200273","host":"s3://npm-registry-packages"}},"1.1.1-canary-4603cb0-1620222311178":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4603cb0-1620222311178","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4603cb0-1620222311178","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"05185464c77b842bc1d54136d76033b09bdb74d7","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4603cb0-1620222311178.tgz","fileCount":8,"integrity":"sha512-HRdEM+SkHLJsm8xqGDXDu+wdeCRkPEBHZID9KCgBb4pnzspWshpUNE70rrOX8e94m5oKVwIy4m2lPAPFdAtRqg==","signatures":[{"sig":"MEUCIH2TALOtmV0aTImKobtMPKbRp6L340WqqZwTpAE9w+/iAiEAwSvTcNYoN7Kj1GntZH1QfOXh+D/ahLJ0OMDP/lq7FyA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkqGqCRA9TVsSAnZWagAA3Q4P/3zQxs3ym1dAFKR9DqN8\nFRGRE2GDe4HchfimrD7F3onhv16Cq43GpYoor3MnIqdwdVJ1kzzEWAPdepyL\nXHdmj5xtLuQbKdUnmJgDuSRSVhBBYg1c3+KTeU1YW+r6DbI/N+6il+1viILf\njArUin7ySEaV1w9YmQfr9jbsCyt51Iz3dJT7yEjDB5qim7xLQg030kG2oSUc\nwOKsQHoPXVImvok9W2se9Ci+VIJLnGNjRISCumyeDYBXodjX5dBKX8R/vhkq\nWW01mD2jfMNo0wXfqPO6+zk5EjMRAOvY7Li6PJ3DN6hLzxm+YBDn8UV/875V\ndd/71r32+SWkzXoOGjG5k6nSdWuXJA3tNmm1lHhjHI++N9f9YpQBGocbIJLn\nGieRyeJ/5cg+veCaIM0sRT4MKHBHGnXOB+S9Dhi3N2tXcCV5sKLAKM+jkiBL\ngGyA3XVjXwWG/9QhRrgy+hpvUjDp3upGfnc8Mscoxpr1RIDv6rkW1Qo8gQWz\n9J4o3UVEAC9B9JLFyBrlZ1anXSIbMCwfpU87+VlquaE0imbp7XOjY/L4lejY\nBO7opjiD4hH8pdeGz5S3rtrP1oP8a27QzY1RB4plz7ectRrRxQSkfxmywRn+\nPaoe+MDtZi7KzglcBCYHTXUzAA51XAfZqK/AHj7Nc3i4rIFi9V1yH2E797BH\nWGbk\r\n=2bXe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"7cf1b2edfe75d54281299da55d127499c147a4bd","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4603cb0-1620222311178_1620222377563_0.5999644486947626","host":"s3://npm-registry-packages"}},"1.1.1-canary-6411ddf-1620252834422":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6411ddf-1620252834422","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6411ddf-1620252834422","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bb1b23724a3da2b236a626f94d42c292984137d6","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6411ddf-1620252834422.tgz","fileCount":8,"integrity":"sha512-Nb7rHw6lDbzedh/6jKghFtOrXwks+pb4eUNo+L2ilVPsDZ0v01Ml06kEUa+lsNQxdcfb0ktjY8a/HhGJWvWapQ==","signatures":[{"sig":"MEUCIG0fmT38ouBNG1P1Sk2SPc3hajNVcfMGZ5yqBo3okazYAiEAno41nPTNpSvd2bFNtxc+pLhpT5lN3qBX+TaMG7qPRlM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkxjNCRA9TVsSAnZWagAAuHwP/j6H0JUeaDbuI/WXXyI1\nXIfmNqTQgDvcV4TUwjzmOWNh73364/27DtC+LHv/hAGi5iT+RpxGnHM57MDH\nk5W03c0dexJAto/Djx6xVXk0FkgHeJ9mjebN6tWnCIe+Pntos2+b8Y4ndbz6\nYlX23fJKh0kVRkMyWINa+qLDckbzQkf6kNkQJMnq5LE5dXoKns2ix00pboSO\nd89LNO3pLzJKwh8P15WP0KY1WKrCX4XFaZ/EaVoGPp9fdBXnu1y9GrbplCpm\nMD0gGAphP8jB0dk7x7WYljldC69CB236WZZxl0exP4knrCSFJwvJUK5YV2MJ\nzgHXMTw/8EZBqnN1xDO01mqsUUCmBfVTncmBVZJ1Y0tl7JZFn1PI+CEkmya1\nbypRU7NYVsoirFMvN2YZ0OhueCg8xgphriiFRiPRFowLoNn7momQcHmMrvoP\ngxc1uXeoJP2A8idCbvycLbY7ewdRK3k49kEESDZhQcZh9Dspfp5U7WZgsRh1\nmt53a5xzg+2KbUBi5DOhAOGDvSOcLtg6m9KFchXGj/Cu0Xou+YWrJnVZbIb+\n+Bx6DDrHP2x0Fg4UdXddSYByvhk8NNsCHUPehn22fQXWGzEhECktDOZUp7V7\nMxapU3wYVMIDKHMYHbgp1ZwxQNuy/ePU3hjap5oHRfQ1kiPAbjipY3EeZBLx\nCY7z\r\n=hEvU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d7b2f254204b74def9e57148237aae2af863ef6c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.30.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6411ddf-1620252834422_1620252876650_0.160899356797773","host":"s3://npm-registry-packages"}},"1.1.1-canary-f3eb721-1620252831738":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-f3eb721-1620252831738","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-f3eb721-1620252831738","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"4d9c22d8b636d83c7b89b49a4c88523fbb00bfac","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-f3eb721-1620252831738.tgz","fileCount":8,"integrity":"sha512-i9fUzeO137koRdt9Fg2qi3eu+c2+l3eALgLS24m3K5t9OVhF0gmsrmhIT+MocEFcWClPG5UJ6wcXHuFsVWNYpA==","signatures":[{"sig":"MEUCIAikVKKphOE2JdPsmfKfn97A0PeCguqTYu8qCJMZxSHFAiEA3Hfe0QiDXVlp0oXEPPXhTTOoSVgKvEXv6/tgRgY7In8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkxjTCRA9TVsSAnZWagAA6o0P/2uYZ6uNDXIiKGsHzl1i\nenOvl7rEO6tBDYFq+Njv2J4kSnmopC9RFyKCarlEFPW5iVyGafTfrwNjRC7X\nxFc2MbLGAAlzr346vFKm+u+vLy0yrACcaEInPfoutttiaFySX9hztSorGLO4\nSrXk3yfNooUylIKqkmT3EL9Ve7WHl8OpZoHLm/A7FKmVkwHN1JUK9TDiI5ef\ntGMFhs0062ibpwTDcEoBz/+ysuf3/WTrc9x2fhbvAUxvbW/s8ae5k/o0sAlZ\nntXe65FBTGzsD65xMtPsC2jBdydcoqTeEveqY15GoAdQkej4Zg3Y/nn0+9yR\n8CrMeOQ4ob+oe6Vp5mU0XzX4d/51x8yrTlQHy2cFqvdBVc90j/fh1ckFcUcC\naJW5HPV3Lqg5Io+a4FYHFCau08pc4Vjr8Evo3dnmHZasgDg7/ZKsFslzUc4d\n9dbrgve9X+F/InhuIHi5AK5pkn4bjrkQX3jv6hGS8N4nQ52A6EJTWH/vxz/n\nEQaPH59OoK1g9h2X5ZIHKgzrs2JVY4PdmQWmpMRdVMLMnL1j4iAlAflKMQJO\naiy62KAivnyz4jj0PohWcF6gZGF+My5DCZScpxpJe2/inueq+ve8OjtUn1Jb\ns5f8knlraQguVqpai9Z4HQUIAyTV3uRwAsqOdGpq2qqMR5YCNh8w3i2K1dtM\nmCtd\r\n=xfEw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"602b849f5b9da964400405b4c6074cbede665105","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.36","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-f3eb721-1620252831738_1620252882724_0.3675765023420685","host":"s3://npm-registry-packages"}},"1.1.1-canary-9e1d8bf-1620317906335":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9e1d8bf-1620317906335","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9e1d8bf-1620317906335","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"ca6779f0ff278bd0a324b495b17ad598d185b5a1","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9e1d8bf-1620317906335.tgz","fileCount":8,"integrity":"sha512-EqWMmsoxlwc3JH+b3hBLacB0UhN4ZsAkqrYpXMokM/H61CXtItkfHIKf803jmgk/UTpMFpVaMoVoTwx3K7zrIA==","signatures":[{"sig":"MEQCIHMWpa5PVvuH/4puhB9qUrtPuqpf6jUOgdPYokbbIylYAiA4zSsrJj+KBZIuH63sLBkWnDUDEEU9Jzu7/ZAjS/FcDg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglBcICRA9TVsSAnZWagAARbcP/0L67F7fTgRvIdllgB6Z\n8bskRmNNR1tZGgXhCMPQV1QVJCIRRVEx4M5QTMMlkTpD+RONuCY8PNvkfrBa\nDcWFociEJNql5JA6MnStXJnimPZ+lB5tIzsTaSBvCj9XpEh/NlNI+iEeEfIA\nzSMtzGzk6zADbyIbQC1OxETp6LZx9jxtTbRS4YZ8BG8ENR2UxP3DwbuMfzNP\nMX4ybvvkYNPCQS/R1gb2m8BHdytURCxpKib1O3Px+9AIwVV2tXxdQhh08mf4\n58MJdchtkU4Lvy6Um3jFmcwd5RnMAeIgOPxJTiH6+YLAumDfqQVT9r4OdeZG\nXdbnu1gbg17zQpicaNe1Lpoe7Ah7qPkYExzTfs4CzmGXowdKaTsGF6EbxM0e\nY1akmfkiC7m1akXBsOCENA0Z9As5cUuTo412/gkKuxdIUtUCDB4WQ88p+YLS\nd1Xslw0LWevrDIZePdVzw77fAkTpVB/8Zh26RK6+Vc0zQlTd/wAdZVkYWkXu\ntVQapMFvg/I6XLRmfbBqJAqY47nVJClHIjnBKm7T7YYS6Qploh2+5zCsQbNO\nv+rR7XWKn7FyMU18ZuKSP25CG1+P+szYFBgdeN0KY9U/Fz83x1ZEmCljW45H\n5O2uoYCY6XoZtEkCl/bIKMj08SLEdi0s92pi+vauOhTJDCJmhKdzp4dpPGEZ\nj0D/\r\n=rqwr\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a1b7ca9dabd0ec01f806601e511c936dfa5efaf1","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9e1d8bf-1620317906335_1620317958723_0.1586023039684059","host":"s3://npm-registry-packages"}},"1.1.1-canary-6e44621-1620326942458":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-6e44621-1620326942458","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-6e44621-1620326942458","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"e5fafe930594049ea6dd7b8eeddad3d9ff56b5d2","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-6e44621-1620326942458.tgz","fileCount":8,"integrity":"sha512-IWX7t1d3FryOd3HV1E4ii3aK6n9bB1g+OWX1GwiSHV+IY/jZkTHr2TgY4WvVPmUW1KYKAU50+mJu51IS849TtQ==","signatures":[{"sig":"MEYCIQDi7Jxz24VKoLbd2LsbACjNjhQ1ERvannMdTp4n4aFluQIhAPltCSa0a5LTL4LZqkRfq513CKEsqEHgyGCaD+lR+VIn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglDpRCRA9TVsSAnZWagAAl/wP/iVVdkDP5iOiL8Lm5qW8\nbKeCZUP9sUf8cdMpn9K0bMwSWakEHs9knNJAOTZA0mOW3fT3DKLK+BpRZ3oH\n0AWmy2GcAxl4iO/cuDCSmQk4c5th7vTOGNBsjnJ0FXCxDqoCmUXB7czkm8pW\nGaDgfzMghGbj7HLJzyc6FXUPUb8pbIHo8uv6g84vfwwcmfwUEMpmM3z3s+DB\nRoRnswPgscvWx/MrUgj1utmdamVe7rVQ+G8nUZ+pn5clsZEvSpRxE6RynhVu\nAbV4GEOGgLEV0AR0Pwce5cmTdw/XOtSO4nm/zw3c5Z6Vu0IYJW9iPGc1xLIU\n6bvHxwM9kuwRSofTD+mg3gKTKmB+wsYIdkfqYorEv9tmIBORhYZd2oR/ACUO\nrC+Ei3qsX8WlVzHTEGhO3DCbtsYtHXQjkpv4zVpS0V2V/nZbxuwrPK0xoCon\nJbBp9SUVkwMV8eYpl8ystNg13wdGEOvUqH+oFuo4lqimtRWnM0sBBZrTZQuE\n+R/JJpiecehMifscTjy0XW6QbloLCLVgLOZUxqbDKVRkgOHSD4zZvjSRd50J\n3WLt8MGKRCD6Eh6uWn7P9eOzG7PgAkcnKIrA8x7L2BTd7yrsA6BwI5wC4jRq\n/TmLEaKug5dIwc+WTbeB8F0UquZz1jONhe9ljyTt0sE0AAOWi2U3IPtdksZi\nyneC\r\n=FIlw\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"d1d03d0ed6e51e4fdff0e37fc0a0f9238fd575f5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-6e44621-1620326942458_1620326993010_0.791822255795763","host":"s3://npm-registry-packages"}},"1.1.1-canary-89325e7-1620413505425":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-89325e7-1620413505425","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-89325e7-1620413505425","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f15ef126eac555f7196a76a50ca3a522af178a21","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-89325e7-1620413505425.tgz","fileCount":8,"integrity":"sha512-KdV68pJfnbWdqy7QSnIGUWNWq9Aiazd7oRqWBBfHApwBbKem0D60apAKnZwholGt1UR6fSmIgd77aMa4zKY/kQ==","signatures":[{"sig":"MEUCIQCI6M8T6ut+XfT1rMIbeMs07T+A+OeF4gS09TGqPJJo+gIgDpG4I45k2gkulZ34RjUpjfr7wQiq/zBqMYK8q612StQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJglYx2CRA9TVsSAnZWagAA700P/i0M2hGuwsA9kbkidq4H\nwkm9901cv/NISL6F6CjbnN5PNxq3tJbhLWB8/Dur6g9kHQQ8/C7oX77g08kD\nrW0mBl+28bcnKfCM0tm2sYP7w3NX1roLgw6TTzKa/jAFmmlezO0/u1LLxmWd\nO3h72pdBcnEQBla2KyhDN7bJfG0zCaqz753ULCWLy7fSW85kt4NoMa3sSJTK\ni2WMQ1LaD+641qkR3zBWXiP2ZNU20RNxRSnzjEJhuu6LWqoxG07zo3bWxQLp\nbRYJlMaiKfsaF7ArJEJhLiWp4secHN3jodK+Zur7BtAicuQ18Sq8wG/tFceI\nfTl/qXZApbPYow0HQPzwO6II4HRnekjcCo7IhgZd/6ZyL7gtL790f5RwWQFT\n1KSMrFca8tgx66t+E7G0K58HXfp8LY+nX5eg3DyG6ymlMairn9j83PumT0EN\nomkX87FngJNQ9d+EJo7ENHZ3NimjhYlYWcrYQw4F6/q4k+z/CJNXkFrHPSyz\nwYZyCTPBfqjtaz2VXGaXU4NsyNBHT8l9rCNQlRMZZlmfhlZhuhtEHKhNOgYT\nx1cvTiaVFoSWItl5ZoGt9AFSRxPeuIg1EtJD0g5g9OW9A8tyHAXIiXMGPKwD\nv954+bsabrk3ZrIuGTRfmGTIB5htjtFzrwsO3FxfrSeEEgDgOsv5GKb6fLRq\n3v/V\r\n=mPlQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"81524704d68d18a4a8dc54c1ef4b310556bf3aa0","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-89325e7-1620413505425_1620413558227_0.47617909153195237","host":"s3://npm-registry-packages"}},"1.1.1-canary-a665a4e-1622413500906":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a665a4e-1622413500906","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a665a4e-1622413500906","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"847da33f6c0b24a960d92b493ea47b867dbf38dd","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a665a4e-1622413500906.tgz","fileCount":8,"integrity":"sha512-w42TegkBO/vDaH9n6+HnZ9e97h2IKckS6S/FYT160gLW5vvvEpvFmnyowSzrquGjXBbOuYL3Vdvn4aZivbC5hw==","signatures":[{"sig":"MEUCIFWzm2qT6cHq8QzykCFelDVKaYzhxe04ifinVAiVkOJFAiEAld0Ztcmk8lEULLNCj/w+houoK8LvM0tdokHZNHi4yuc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtBDzCRA9TVsSAnZWagAAFngP/1dmk32k8Ke5n2aCiGZW\n7XhD0dK5Q400X6HhBCKgzWFBWA2DRrLJbhUphslAL7VLnlcD5W6KSOJ8i4LP\nMaIi2SW+EWN9H6r/FusYQ4x0hG3tQ7V6/24ctuABV//6SPz8cWKiAAzds2Gb\n0CupTv9OoOLYzGUBOSW2lYrYGkZ2bh5dY8rnUIN8aZm+P2uXBXiMj/J+A3Q6\nun3V1uBh0Gk6pt/g8wKYO2B+2C51u2wpEYiO0efE9Y7TvfAoRFujtfgHTkB2\nYu0Qi2t+kSBALphkPtczaCQtLLlBj6twAQ2N//tp7AW49gFK4l+5uH2sfbnb\nUkzzjdB8hzkDWQvduyLS+85T3qaBtJ06rs1pI7Mx1/LNnqGW5Aan416tq0Lc\nJgVvy9yi24ouqt3bm/ufCa0x3figdGd6hWy4CcIdaxAFvtNQE/a+Ma0eCDnf\nz7YThGDAplLru15HbZ/xGUfctWCgtRNvZauXwYsx2xo8wjKr5T+GdGnifgok\nARn5ictKw00MSS3jxtBv++Dc+hfvi0OqdlzLJD5I4I/YPHnzTFOF+ZTeXTbH\nVjaKIgA72WJesiyTLbKdlxyff/TegHkOd7cD5lsdZqxUd91BR386FWmUFQIc\noM4KSpdhGrHuk+W++jLaPmWBvxvweLfyfmzGuOjP7x+kGAy81SIsT9n1Xm6G\nk+zu\r\n=Yave\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"049044777bcf69f698f09adeac08ef5a45c7d3b4","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a665a4e-1622413500906_1622413554970_0.21007361448218842","host":"s3://npm-registry-packages"}},"1.1.1-canary-7662dad-1623104116345":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-7662dad-1623104116345","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-7662dad-1623104116345","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"7fd290fe60d0600d9961634ef9d41635e7d9214f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-7662dad-1623104116345.tgz","fileCount":8,"integrity":"sha512-wcpq4SVJVMEOVbjFsPNUIKZoDHIOAWZKpvUblGYCGQZswl3Ow/tF8I39mfYdAcbWZYKb0m//vyEuIqPIAhOaPQ==","signatures":[{"sig":"MEUCIQCCOR4s+YFcJvyQsKElPNS/0fwLT/N4exhJU9q+k5xcAQIgS07bxXaT8ZmdDei4Z2Ap2fZibJyW0flsp/AB+YCvgNI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgvpqsCRA9TVsSAnZWagAAXK0P/1ePYGGtiY4bbBJ7RGDI\nGZcPQGnEDpSlMOUH6ehAgPHQfNalptGFZyuoFbiSnnEmNH0sstAWKUfeX/9E\nRZruR/c7QCnmeUnYG+3sQyczWDAUrHZ+hRZmOGp41UIMAx9P1geEMXiSNyiR\nFW6rGgOgceqIf0wByvbJnFQfVGheCtJQQS4htoJgGOn8ob3PBqP++BbmyhLZ\nqlIBfapDCiYUlm/TkxXqNqFRLpci9YpzrXPsTBtVEtWNtBymTDvSIrYAkcwe\nPIPU9ezXXLA0DZ2vuUYJse8oHSfXkz2N1e6PMVMEQjvdb3sGGZxot4XAknrh\nVl3ISf0KEcvHnDnIaGGbUiCBouuDzfRxX0Tg2jgW+b46Rce9aRlelH7ji9Dh\nRVO4Bl4/hAnP/ZsZr/fczUlKSTrPziz/bT4IB5OZnwc6R+8Lbe1+ihz7S2az\nbTSCjOVqdIMds7yRx0jBXuf1+25o2hFVcwdsif3IEDcN/nW+GdAnZ03y8QTu\nWq7IplY2+CH20e9SdkPSYPxhSxWzTQmmwEW9OKsxd1T2g+a4HCRxBIVUQP+q\n7RLxhl0kCOnPvvrE03gUu9vzlg6RyZtA+YoZmBt5C3kacLhbBhHT00B5MaNQ\nNhIo9OApNkHnmyGQ7Rlj9TSdj9cdKmxS7ogP+ZZ3hk7YdImJ3jjRtldtThIt\nw9jR\r\n=Bsm1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"56180689c11476d1d92c413e8a638ef2fbb96cff","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-7662dad-1623104116345_1623104172658_0.8935941715871547","host":"s3://npm-registry-packages"}},"1.1.1-canary-8c70834-1623190559876":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8c70834-1623190559876","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8c70834-1623190559876","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"2f1104364f63e5affc9e51e46123c5fbadc88165","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8c70834-1623190559876.tgz","fileCount":8,"integrity":"sha512-gTJmnOt7MczzR5FdlIZi8y0xPyEA9BBa7Bmr4Xp7Mhjln8dh/V8NX8qstP9/TIq1ZAJf1Y1Ensw3a1bxdF0oXg==","signatures":[{"sig":"MEQCIEFYyan8DT+TmZbibUKBvrS1MPJFFRi5dXchmHVwv6SPAiBSR/LRee9/Fg4MksosGXgoJwf1qb0V9UxDd6u872P1qQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgv+xTCRA9TVsSAnZWagAAGcIQAJBZ3MABR+OAozV7i5IH\nhVWvlTUW9QhU73epqOlY9skOpIFLZgZVUP/pMMryvu75z9l4geAzBfMUZ9+A\n2LnSaWAYVcJtFLnOvYnGgwm2t2JmaYi4oLByzaFxv0kgEdHRfwyDfGpzhCNf\nEcA+xq93Gd7Om/ds9d4s8p3Oj0XJ6043zstTP6I5ADVyUVUKnZwzx0VexxkE\nfqbqKx02VQ3mYY1whPY+W/uza8sTAMqTO8f2vBT9t5r/Ox8iW8LOBb1grZYh\ntIkWk2TJvj0eSlnIDaGGGvHSTWZ6fJba7yAnpYgQ0Piw4480fpC2LrPzaUn6\n4pePDYYzkxJjmSnjGUh0Dtr8TBOJzrq413xIl5fa/NWGertm98hSC5/gg3UZ\ntlSrvihI4KHKYskCp2GvXCgDm8iFQjEMoeO9+HlJqiwKIB80+L1ZfBFfnVtb\nVS1XirTFsFE+gpm10GqUTAoPiFxs3X3pfVPyGrBX4AXkCJFxulfxbHr/6sDd\nu6tIHzJp0nXRnUTszhDLUfTOgyqj6+TQM5KN/cOPbLbkKYLkb8g61N3Z2h7N\n4umAheRF7xNEeK9el3dTEV+krTASaTqObO4Y4cHs84G8/FS/zmmmK41pwzZk\ns29YB97ll67VPaYEG+pGF0TXy/eCFGT+CMMb/XLwY3lNsLJnw6uFEfymymFS\nr7D3\r\n=i4Gk\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9314d7153aa0fe2a8b0f0e3d941ea4b3afd3b11f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8c70834-1623190559876_1623190611867_0.7523243027237965","host":"s3://npm-registry-packages"}},"1.1.1-canary-fe09311-1623276921257":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-fe09311-1623276921257","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-fe09311-1623276921257","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"c2b28af11a6fdaa6aa540f83139427f16f03bc1e","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-fe09311-1623276921257.tgz","fileCount":8,"integrity":"sha512-iKf+3PM2LFeYzumY+Xm1Pe3NVuXk4mUKcblR5gPjsSpFb4KCX5nluCt4MIbD/9t7eNKSD1CRQ/QYAn9N/3HVFQ==","signatures":[{"sig":"MEYCIQCuC/LUoCS7qZtqiQUegMEO9WHZyal20biwcicaa6BDvAIhAOOCnJeKrn4Hj5AXFTVGAH0ecSgvaEwG5dW70mxq9LBk","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgwT2yCRA9TVsSAnZWagAACGUP/iEzkn2bNnEL9+tOLEfi\nTJye5+zzFTdFdiuY4zkg55CuHSwK0SFUozJrh2laLsP5MlZQg2p/pdw9mbfI\njWIHECGb0irW+xHpNbIzLrcamN+536Y9oK0W5Na6IsfoQ483qohM4th+LAUb\nSnTmr/n3V+naunz6l9jtxm88Cxpekyj0E1CNs20Fc/1TG/FtIsHlqKxz1UT4\n5DBi3Nt9lTD4R9ZAEQUowJ6Sq1OaSEXUTb0c2yfe69k9rihqhFuz1fYH/wIN\nyaB742iV8HaUGqd2HVfxWNUPcIOP9vm6HU1i24g3eFPR6Iz1P0731ThVoMDv\n76z72uSVixun1CJHpebeP8GOdTy8D/royusKK+Z2krabVHacjRSJUzilbSX9\n36mEMj/y+/lJ7Pq7x5+TX74Qq/SGA/zkBx+saObEyCjpW1QSKnGG/1vUNON5\neWJbXzFNzOs6LMzK3Q3kbAm3znrVluhdNa+EpMbgAEXZZ/atarHL1Qt09Y5a\nZjFdoirIVQkSF1ubVufKT3fv4AYBc6DYh7/WMSWouKTvZY8/GD+aWYFv7XdC\nMKU4QHx6GFQGNHViOjgVQORpCS8KA5jReM9qOYlitFHnpTmS2ZBglfti5w6b\nza95MA3tr9C/eKqIN+ppQmaA/G7qF3Qiqmu4ZbfTyIAJ8hBSzC5sLvhZar9R\nisbI\r\n=rhVu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1c860d5ae1fa8a643bc1a74fedc52cefae6b1d75","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-fe09311-1623276921257_1623276978540_0.8981301398736801","host":"s3://npm-registry-packages"}},"1.1.1-canary-9b2ecc8-1623881836840":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9b2ecc8-1623881836840","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9b2ecc8-1623881836840","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"fdcf640972932515862514d8d3cab871d2e40c85","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9b2ecc8-1623881836840.tgz","fileCount":8,"integrity":"sha512-LP94qAgaRe8oz2NUQSGsrJC3cmVJVKsblwwV4xnqoxflWHDj+UfCl9Vbkbg6uNBXU1ByuZREoYkUPJNA6yiR/A==","signatures":[{"sig":"MEUCIQDdjVHCXrd4BdwPnPgskmF2AU9SJnz3r83QkgE81bVkyQIgFKfy7T9DyNbHrLzCdht8jfGviLaEXptqpivB1JP1eE4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgynicCRA9TVsSAnZWagAAlYAP/0s4qTAeWOsaiaoLXGxz\naBKDM1M2GC+cvDk9wNvyeEdYITSjCKrAmPgNFIwQs7L3ARD5gaD+ExFoTf+3\n51CAVWIad4srVVXcNPgmg8SUys+Ys8kyHUrJJAkE6FjKoU40CkLCIpxqiohR\nOENhaLDWLLN5KQ7cJGkv/q96+SCu3AY0YLb0pbmAqqA7JYW1Dnuy6OxJDje4\nmm87jwD6SigyFSH0NL9B6TjV1YzCJbm1ZpeTfgZ+pHoVjydww5LLi/b5aY1y\nh9brC5G+d1u6TY/iOjVpQctfkMTANIfjE1EMmg52qb4wFPlrTn0cLb+Rt7Ae\n1gukFXw4z0xrmNGDVHTTq9DYLW1SiMwSIvgQV/Go9uPMAZUhF6JC99aBxkAH\noO51xJ4hggMn4g0DL8rY2KlMKmng9TxN6NkblwiAQ+RANEQakSpYwMeQflnu\n/mN8NSLaZbf8NpKzM+yBJBYrpSX3X1KEHhAGsERMPSXJVLTKRgH9cMe2X/S+\npfCX/nOzSG6buHOfqQ0nk1IbnZTEhsg1piyAK+GpgpgX8EVjQJtxKsWo35Bo\nTzQpfxbYMTpPD8eHx6v/gnoeiAY285FZ7+FjpkyCCQtYwQoKokH2bBJ7gB+Y\nbBkmuzWd4usYmgLCCSEhf9buE6PJljI9G+hLeyupnReVpDCPsR+KoloOL2VB\nb1Xx\r\n=5iv2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"ad3b25e7f404a497161b92794c626af9697ca04d","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9b2ecc8-1623881836840_1623881883773_0.39129629144194134","host":"s3://npm-registry-packages"}},"1.1.1-canary-a14c73c-1623887116926":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-a14c73c-1623887116926","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-a14c73c-1623887116926","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"d15c292e7dffcb719679f1d22658269288f34b61","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-a14c73c-1623887116926.tgz","fileCount":8,"integrity":"sha512-qQuVjXI+7GpLwT6+yyQ7YK+E0hmmNM8ZXiiiqmQUwAV5hv6rj6Hz5rnSIoMfHjGaxHUI+yJSrusq6AONMwVMsg==","signatures":[{"sig":"MEUCIDfWzNkGSvrqYRGd5w0ACKc9Ovo6Tp2Ju4rQSC9ZpW+FAiEAnGH10UZnszx2GyiFHxH46/VsGQXT5yiRtMCqxoaXTKk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyo08CRA9TVsSAnZWagAApHwP/jLlDPEqCIAgDrm+RjpE\nzijKJ2YOnYfNxMgXUC/gaaj/xQSI4duFcfQXi/a329FM3Vr0w8E8fJ+LWbci\n+q+abI2vl3n/6ATxqzCHuhvbkX+DMXk4AZWhfT1Mezjiqg5s5bvNEJBAu4Rz\nMlA+pKRbXCbUZ+ArnX39qFDK4+1hFS2JxUOxYyn7ixpBjeX1ZEU4AdgOa+wL\nEYUwLMNcwVSQ+6g3L/kpLkvWvcTZQayQitR9jPOl7TGMnaA3JNeKkqYyk/zN\nR0qS4wNvPKCMBqqKao+rECPP2DwKum+OH09Qulrlv3KqOqUu2UkKei/45ONz\nNgIF9wIj2+ibwr2Ah/bl4Cg991CdwqiGfkQXr7GTzQBCHZ/KfBVqpDJkeGV6\nBxr4wGGbm7+sdGbg4BG/q6k1epByF2agGX3qPMfUXLK6Xxo9YMN5S9jWdwuZ\nVU1ETPt786r9NziK88tFACNiT7+c+LGCcC+Cy1ennZxu+fJtHjEJlGFVfWst\nPlj8am6n9hL1Ua67l8DnTUTE17QzsevgmemBV3DAnjhUjR5A+3Qp1DCNCMEn\nFY6eeDiQi4De22YEKT316g9LvdWZIO4vM90GP1hKlflh9h4xEN/mRhvutVyl\nGKvnqV89qXJGSwNtO5nMTalR3mohrrl5x7GAM+jTyysqxJToOszJtov8NNTU\nf2ld\r\n=6yaM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1acb746e8edea058f2febc555d475e2d74bd501e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.20.37","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-a14c73c-1623887116926_1623887163412_0.22084668192316848","host":"s3://npm-registry-packages"}},"1.1.1-canary-c461827-1623984712161":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-c461827-1623984712161","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-c461827-1623984712161","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"90dbb1ce5456435290baac679c49a8c0b7060cc3","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-c461827-1623984712161.tgz","fileCount":8,"integrity":"sha512-9PXO2GcQif7sa9YTW9f8r2mrDGqFzfNN9BNdj0CUBdj3bfblGkxZ42PifzTT7MPl3W1jgkeqLi9JO1Gh5YPuoA==","signatures":[{"sig":"MEQCIGw3dmqYtsRyS1OwEczXW8JP7B9xdM/15XExN2YQ+L9HAiBjs2u5HJ43KzJuG0K1fy5W2qI64kScmdEFKqOJwEBuAg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgzAp/CRA9TVsSAnZWagAAcZYP/175/CjtuKX8xYrDbxy/\nVPeDmR6Ql6PAzvVvKNrine/OOb3nGc0RJWN71a77/95DNrcgrD1Y2va6f+Jg\n75bpwDJXHeoifo6yuk6oWLZEgqqgK5J+vj/tZjbtbJv3jIhot6KZwM3MOtDS\nMK5QODWsLz+/7Hi7uuNEklDhRLc2s90t42gq/NbDpOKyuMCdwdglEN6PxmrS\n6bSpXE5JHsO+tnRSb+gEOVmlZlw1FIVs3jm040wC/RxU/mFjB9B6Xt+CKW7x\n3vM2jQsKF1/QlVkoCN3yrGt7TkPFTZa6evWsALhBo26CNQbBfpl8VMe8VBI0\nFbaEsDoiakGO1iVkZR7rpaPdoMnPR1Uek3v4A6L6dsWxJwVIZ3GSj+Rm2Gsn\nxVt9bTz33ZdVg6wwNdBCw54/Kb5TQ/5Y6E4DPRkAh5KGIsMVtChpVWGKmvVy\nkQJdMUF16GPnPjbjJS6jpIWTukO9ndyJSuM0VtCbSR54yeJy67GYDAduivr/\nv/kU2R88rZO9P61q+8OTK8pP8uPkML+7eROE16e0ud9ELiQdsUUgcLE2BswJ\nYDnjzGvLv5kEe8cUNsF/vdv2WbSa+6jM+G9jqHfD5RBV5DIGXTYlkSBOcuza\nBu8Ay55G2S26tAkiz56I7e7jmbRKuhRqxqqwr5MOFh43DjWKLuDspMIbxFH3\nPjD3\r\n=IEQE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b25c9023f72a125537cd7970ee9f4ca6a079790c","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.0","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-c461827-1623984712161_1623984766763_0.36572586768413085","host":"s3://npm-registry-packages"}},"1.1.1-canary-20e4972-1624591415859":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-20e4972-1624591415859","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-20e4972-1624591415859","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"f0eac8c3c3bbfb45a0fc672a2af7ad2cc338237f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-20e4972-1624591415859.tgz","fileCount":8,"integrity":"sha512-vfAxMn7P1TUHca4aJoXaYzgqCz49y/W0lSgNQ21XQW6v47kXfKWiFl9Yp2HWhLcuJRGGX9LYK1Ngvnc1ZOmyKw==","signatures":[{"sig":"MEUCICSrlCRr8X6Y27+LJLlaatVxQRAVd0cYUDA/Z3XzhEWIAiEA+IjmnnSGZGQUq9h0I+SU1+5xfHiJFjcSRHW3xLPfmbc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg1UxpCRA9TVsSAnZWagAAvGsP/3+3LYSaymclZikH62Gf\nEctadqGrw9u2WqB/1NE7qjBqbFNLe8ITh8WrD0qrS2137dAcPuaHFJ6sC5a7\nuBY3la2YzOL+x0xEIiqXQP2xUeZSbzP++glEVJiriA+uMyaxEy/lbqi9a0QE\n/hfDJzx8ZvIw8AsaIcvh9bgqyshXJMKUxtGfzaaQBoEdrrAzWWZ4LYvCfiSa\n+ImSS/LoPLn7KftH/oULKJOXHxOYUEOn7OkJPEagfsH55aYLTzo/8on8AUEf\nrRg9gM16UuMuvaO2Itl6n7wMiCqixuhVqfQpNSdicj6wM0VCmMOIxh6FxGHH\njAXLdA48tqCVzUbYllx5uYvJco7y8EA84jnGR31hFTfI/CflBRf0iWf7jDVO\njMUQOCf32NEhTwTm0C/4dpGf+GqFSp0jYeE7ET/eWfQsXZ16R2qRpYjHHIsz\nWGjG7Fx7BSQUSpYA1EhsPvI7beT2tEhWExaQGU4B62ttDZ29dK2bLiWscj3k\nofs0TPwoZyrAg1GASOwYkfnDlEwUVH6UrpjvlRegiIwwEEMwm4ef4ES5Frav\nQBeKDr6QKFDjTRYvO4Wuejo/Mm2FAOdFVv/MJs5MSwv1PV3qoZQfXXEoVF/J\nc6hlkYgJspof9Blh8OxkxFwS9teVGfk8DlF4RyAJDnDkhUAKwiIuxGzLeZm8\nJiaI\r\n=UXzi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"b41383891f389a1b8e3fe913b324d65595a1c530","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.1","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-20e4972-1624591415859_1624591464958_0.553669494483841","host":"s3://npm-registry-packages"}},"1.1.1-canary-9c6c5f1-1624761504598":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9c6c5f1-1624761504598","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9c6c5f1-1624761504598","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"bfd0e57abe8c7e6ad1a076ee6640ffad3a6940c9","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9c6c5f1-1624761504598.tgz","fileCount":8,"integrity":"sha512-JMB3bVfZ9ZzbZrkhgxTrOMiIqOIcJ4nfL43cjP+BMBHDc+REFPxHxhRwaYKQOYrDuFP5orGj0p1jymAPrW2j5Q==","signatures":[{"sig":"MEUCICHaBuipqQeSdGxtXdMN/ynQYylDDiTDrhwKXo0iiqIYAiEA+rV4TRU8wWipKrjnx4jqLVHWP64E8Ybbn6RxuVKIuLM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg1+TRCRA9TVsSAnZWagAA0GgP/ibuC3/283nwzl8hcAn+\numO1O9BnLFw4aL4B2uLpCACiGTomNSuG0W6Ew56/I09xiKST1JJryb6wVIGN\nvTZL12oeoPWM8vThWgbaHBEyJ3r5BdPNW+Ar8Mk22X7wa9m5+c8ZlrXzF2c1\ntr2U/uZd55Yu7e1HD9fAkNr3uo53qphl83KUUwkpfMbTf3UQai1HWBlxXfWB\nYLU/7k2rtCSh3TumkMJHbjLg66jJKUg3yrK2CDfhjcp1vqs9SGc/zR/mw67U\nSA22fWmHD6gBhNZ8Hzk2aK2NHPqJ9rReEtFn7UJha5GWfL3TufzlIfo1Y3NR\n5+DEzbZvFZ+rW7mvOwFZ+lygr3N4sqSbvO/Sht6FTSrvqMXirXq71Vt73wTT\n7btS2HF4JKFsAcJ0g65FKHA1P7k3z96R+weVrvxXoT7Yhzqyj+qMMz6kMM4x\n29ulxrOVlTGNFRSQAH81OipdjfNKRfVFnzQLbExFpFExMWPwuzLlubS07QaS\nElF2Xbmuj96xsqpRFJ/8pdrCauc9E14wpAJHNoBWeRZHBS+N+LUVX//NQIRL\nnmI6+7s7OgxVcJz3Q9aNZF2156NnYRLWb+9BdYSVnG80gehEImAjFred/MLp\nxkP//j37b3jwp1ZpKOMAgYrkZAZ/cU0BxAgO9vrjZZiD8WTW39FfcKi80rT2\nWXRV\r\n=uR4x\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"9bd8d0e3aab098c531f5dca6b8a710b8fb96614f","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9c6c5f1-1624761504598_1624761553135_0.8243652604098779","host":"s3://npm-registry-packages"}},"1.1.1-canary-1bf27d3-1625005362618":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-1bf27d3-1625005362618","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-1bf27d3-1625005362618","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"dee0ac3f3284be4e38799098224557ba8d317995","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-1bf27d3-1625005362618.tgz","fileCount":8,"integrity":"sha512-hhLL0sVtHuHNYqg674Tu0+41H3EKRjVLsyuhmGuJiQ36TmGzC/asQyQ3JwWW7FERxFrad79W13gHmZ07Kkplqg==","signatures":[{"sig":"MEUCIQC/fGP2VFvNVKMn2eXFW2+tSHbhFL9jggROgvWGcwPDUgIgM4dO6cWX206vRAQIvzoCb2ekPwiTwJXTnHlxuxxpJNo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg251lCRA9TVsSAnZWagAANwwP/RWsXSmJs9QeppbqOjO6\n8AxMWMernKLP1cO0Z9l8XHL6nqs3qoxwGufbRvaGzQgKoOBf4Gt0SYtG97Vk\nWODhYQT6U1OnCiAlgGmLzlMHgeGCw/kPD3UmFIOlWgYaBh62VVECg//bfNsL\nnMOfUUYE5AQZDs5/lqK8B2gZZT7Xiuyw5hnSZUqc7gx//yA28UxVVhfvpO5J\nH6XPgA4XNFqY4Q2Kh+r7WtEJkHzmIqTxiNq1Q1+beevmnK4nT015TRFPHDVR\nC7Z40ZmpFEDy0ySOSnXbrQ7Gb9OslO+7P6nfLQNlg6pLRS9dQE/4EZ6KBgzI\n0vhvNjdbwNW5oNyoEg5oGvOkopiCoJC5FqQhrSanK9HB89l6XrNfnRH206Dj\nM7FsXNy15rlYf/0AcUWU0Qn854UDsfYYxVEz9yOJDCe7GsvGFmgdfhtePRnN\nG3toELciz1o/RX2ck6h5KLPfSn0ZDH4LCsc+MSVqbBQrlmopMJ4VorJZHtkQ\nS9BGj22oOlVnvOWRhstpeUY4TTBt8LFDUNsM8pswXwdfB7VO2iubaejzAakf\nkJEii/c5VRD/Wdvl4z2HHzCvPLV6tqY+R+h2K9qdoIB0BdOqzqsG5xYHc/Zj\n8I3udvQD2rHuwnVscy/JR7uH2SBhzQekiufyULQHgiq2TNdkqsONvDnGRVpd\nl5ld\r\n=hLyf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"12d008924451eea6e8cbb5f38929e2df0a3c5dbf","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-1bf27d3-1625005362618_1625005412630_0.20955534613056925","host":"s3://npm-registry-packages"}},"1.1.1-canary-8ba43f3-1625442419084":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-8ba43f3-1625442419084","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-8ba43f3-1625442419084","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"610a334593bd0014ddb6dbf9a33a17e9290cf521","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-8ba43f3-1625442419084.tgz","fileCount":8,"integrity":"sha512-h72gpVWiLzGhdSm+X3WyirdPjeYBiAtHqiqMsewlx9L6gev65bNXx+IY4PBmJ39dDfSEXdxJW0/FW+hTf5W+ow==","signatures":[{"sig":"MEYCIQCbt+VCdgV9kMtJ6mpEpQjXhs+vwcSeOqaJGMY7snv/0QIhALMuh3WWbIQ/Q2mgxxeO0WEkoXzNGK1PRZPJ57Lkvp3b","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4kiiCRA9TVsSAnZWagAAE/gP/09o1mtgG8oC8La5fGWp\nAPiWgWlAjlsjdCZWa4oLVtZn/DojLZXJymaqLjZL6LIyg95VbGy7hy2ugBYE\nG9+Ai8qdCC92vr/tooiVCK2RMqbYhKw9yPNGSbkmfvAlW9JXn4i9beqByy7z\n5U9ZOy5ldJDj5EYunaoDTVm5qKNp2ZD/36ps/f8UyOXB9FzO4RGbwNDcTERn\ncOSc/697GoXwHAvnT12XdMu7d3FTvv7RKauXsjROHY5SdFtOsFbopxzaavfy\nqDv9VwHUEyJAEhoPPGo8FnhFbbkZR22TJvzX7nm08dz0GNiPJ/2ahseTitOD\nBldRE2NJOJfCMrzhBJQoKwwJE0ZVeMhmNooyd8SZ/bayAlKZ7bocXNgwXGjV\ndcafuXeYoQqntsF2e6jNhxqtb9ci6IzmKTH8fyGWPOO+4lgwP5y/rpgrRL+1\n/Rhnz9R0b8y0vDw9kfDdRBs2pvyFVyV7Lxz2K2zI9cv6QzSgDRI/F5hFOzRQ\nXPYPCA3Qw1qx0zq842Oz2FFUyoUuEtpY+burCOyEtuS9K494Lj8QUizRUIk3\nuzOujyigSAF5ao0EqYtKoZN/k633P+DhPslddyQhIan9G4L9sZmMluxsqjCp\n8nH6SXTbkDF+ZYCgLBaM/HzPQx2UaKl2k+BE/omMItu2BWwzXtMIiA5Croa3\nNnYh\r\n=YBMD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"55c16a514e881c31b086e7629d61be623068c0c5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-8ba43f3-1625442419084_1625442465542_0.08766164189902059","host":"s3://npm-registry-packages"}},"1.1.1-canary-0ee5b15-1625946553376":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-0ee5b15-1625946553376","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-0ee5b15-1625946553376","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"963cfb55910a96adc2e36235f1933936e7c1c4fa","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-0ee5b15-1625946553376.tgz","fileCount":8,"integrity":"sha512-qT9HY5/jaqe9ATBqG/Zc4eCfdOPWWjAebwKsur73QTP1V9cB5tEvyl8bFmm4jSn0Rkv1FjFH3P23kIBPojzlfA==","signatures":[{"sig":"MEUCIDwjNQpTX5IAxjbYnsHW5qJfu8xT/CBipVdFKOT5Oly4AiEA+mCU7YOdlEfH2pcQ7xCar7pMXXtlhG+4EBiV0TRcWzE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg6fnsCRA9TVsSAnZWagAA+2cP+wZwDyHFEqkMqBMfeMHT\nCeq7HRjZFT/TY+eEobBu2kwaZkQD57knOIN2Cc2KXFUx5i5p5BRYAga8JZiI\nxXwdWnaiwJulIBXAy8SJNE2rc3YzbEuEjuIfDwqmHpyL/hCA5zWhDrFdqnnc\nhh9LcXdRBXd31ZpGVYVi1iG+JrnyYV52qIAY56Dj6hH0WXNRx2YCerHXcdaO\nNUrCj9pVrTg/Pu1YWVZvWP0b8UAAtN1OTIFDdTws59bgw3vbYBPAzPWtoxyv\nGJOEfLR4blPeQCv8t4I/3wBFjzwx6aAFmEAeXgKseEQml5FAFRqJzaHitVh7\nPflSmYYnv4ka4dLAM5ll78xPe1ofRAi0W9Z5d6Wg7cKEWkYVSNMSD2QSMgpP\nP9DSu3in7prsl/g8X9p8gMOeCz613JaS/gfM2/UP3sqrC6iUR29mmXAjz4qb\ncHKmLGLpsaj7qXwNzDqA3ZpvYSGKemQ47epy3rOziNV0y+wLg8eMbTJqx5RD\nqfoS4Cbaaomxx4crLSXZOii2tyeoeZJA+TVHQSCB02mPUnFsaxQGT+pdUyN/\nZ+ppGUIYWXlzZT25Mx3rUQXu1SB+EYqeLG6lz9WBQScm7H/JACfCKdh+x0ZG\nDXTm1kGny+sFvVmAHMfh/P8adWI0ZQm3Wmqz3WWZTq38fbdaqIX4ZVPrWrps\nRcrv\r\n=ZNbh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"1f1e766149946ef2f2ae6c364a931d10b3178fab","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.3","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-0ee5b15-1625946553376_1625946603868_0.9283443536145672","host":"s3://npm-registry-packages"}},"1.1.1-canary-63eb4b3-1626046828782":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-63eb4b3-1626046828782","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-63eb4b3-1626046828782","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"6eb31835531cd6469894cc161b5ddcdbe6aac6db","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-63eb4b3-1626046828782.tgz","fileCount":8,"integrity":"sha512-1WTnD5Y/fd8gHsYSVXskkGJ0Ucjdop9NPB+tY/8YKJ7qbHY/p6Xrd+Dwt0l4ZngACQDg+v3WAbe+k0tc5v8t4g==","signatures":[{"sig":"MEUCIB8kL8jldif/ofiWx1Gw4mOFbs/521R3p7u3WNxCApG/AiEApMVteaprXdRcQW5D8cm+1fdSApQ9H5BYEUlOH3CYFig=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg64GgCRA9TVsSAnZWagAA0xIQAIH9YbZS7V4984W2neoM\ntfG4PW/sucGpx1uz99xBIBQRw7D1caqjlv7D9/uMsbxP8/tqLHTyvRJyUilc\n8xgL0FNAPsh+yc63V2GXrFP1UzxfAftfDvo3YBnR37MmrtGFjnI089h4wXUm\nz0TdKH92NfyAfqnSa/JSw3rg+y5QUVtG/waodwkmBMlEtkMLDdurgPB0PboC\nO019XxLYW3+eH8QgqgkaG98P31mcoPQWqb28QF217VqQkD0t4wQdpgpPolBk\nP6RwWSrsKMpZR6IfSLbQOFgmoOVc7Ox56vsDwSMpwdOoo2IB1ALn2IYaADwe\nZxcJf+uvHwBzNvB5/JhyliH8dGUr+lcS0+JQJjTjjzwaAcYGwhsMVZui9Eo4\nwrSwLuGCFm9/48+5pXmlCs5D/5SegzSdKzAjC9ORjwx3kuKAskKyFVwG5SdK\nn7jsNQx4kMRQ2wbRjKiEa4tkafOL2XGxIcC/3XpeZQ+Ziu5NFXfx5v7piCZ/\nC4hC0n3KDEm5hP1Rrh0TRzAz5IQ9rYbD2YKEzEC3nFn0wk22hJAyBM6bltjX\n85CrRkuYSDAZu6W48dGmk1YwWpYa7BYXGmVvBvRW4LXaxdHQpBxsmNZpRTox\n14UmBrwgw53dYUcCwdNXGSxo0Q/9U+c4g4CITt3jREpxcb757veC7bF9alZe\ndQZH\r\n=fpM4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"da4b005008f95debfb20208c06c564ab23372fa5","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.19.2","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-63eb4b3-1626046828782_1626046879952_0.22438114216370075","host":"s3://npm-registry-packages"}},"1.1.1-canary-4223a85-1626053020164":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-4223a85-1626053020164","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-4223a85-1626053020164","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"0f8a7bd3c147ea726087f77e0773b7d1891c4f28","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-4223a85-1626053020164.tgz","fileCount":8,"integrity":"sha512-M/x2aDIRD9a8PrKxM+K4eOdjwAM6q491k8M4Nnq1qLFFqBH+sJQMOs1CfOSEVDUX+vkF/PW0fvd/+TfXXvIfxw==","signatures":[{"sig":"MEUCIFaIIrcpxVfoKUdxEvUrpymYeKB0X85qiElrQViJaOVpAiEAoOWxZuNmqFjxWdxE2fnsc2UqBRAauEybvsKlybYr0yM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg65nTCRA9TVsSAnZWagAAL+sQAJXumwFGWjgbBbmsOh3K\nNpyHqkktDv+6A0pdhwyIZeW6hExfHL6tBucEOBF9Gf+Dw5TFzvnQllKEDCTl\nosZ6f0OoGiCg5ou2rqGw6DTTpTFIRbTXA1TZOvBscLEMexap4Gr2loVPgilL\ncfKO98uK5PytzZiuBRq4qbtBzXYUgD4tqAwEF+O3Ldxbhid+AOAXJ1ZfVKvp\nWN/oUI1IM18xFzHGhgc83gjbWu8rU/RqdkUk+DJuo+2S0cP914r4FAigpvqF\nwdKgKUJ5TC0l6BLK+pjK82FOaHiJpVKQhAYuIRuMD3eynkRCb2vGOQZKLQKW\nzCGRUQMR+aui69T82LljmM3BZbORKvvrzcUQviV03L5/9cbWGu/wpwOS4k+l\nRmDRMYSBHbJkfHVnuvpuWSUCtmZS7KZesyxNWIJx1H6hHc8Kv2SkdeS9SraF\nJSTM1Ty98nrG+HEs0+DA4QrY3qW/bVo4Roh7NkEjRjVnuhN4h6Nv6V3dNm1M\n3QijD+vdIwfXIT59LwVLfqN9hmXHswAU2vsUxMTTll2pYhRZujw7VxvcEwtp\njPOb9zo1rLyWuUfPGSopLx+f+ssViHH1EfeaTts9KzjCIRApkWIK8+1O50r6\n8/+jK01MMrQjsLJQpSyj7IlH55GQsjj8KHvt0fu0QiPA6Uom6t2FeRPkwLBg\n2+NX\r\n=0/Ih\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"a166bd30f7bae390d3f4eb2e790f8b4a58525140","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.4","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-4223a85-1626053020164_1626053074463_0.5449233645431313","host":"s3://npm-registry-packages"}},"1.1.1-canary-9778786-1627751226724":{"name":"@iadvize-oss/opaque-type","version":"1.1.1-canary-9778786-1627751226724","keywords":["iAdvize"],"author":{"name":"iAdvize developers"},"license":"MIT","_id":"@iadvize-oss/opaque-type@1.1.1-canary-9778786-1627751226724","maintainers":[{"name":"guillaumewuip","email":"clochard.guillaume@gmail.com"},{"name":"brajalu","email":"benoit.rajalu@iadvize.com"},{"name":"wandroll","email":"wandrille.verlut@gmail.com"},{"name":"ltaloc","email":"loic.taloc@iadvize.com"},{"name":"cateland","email":"acateland@talend.com"},{"name":"pagury","email":"pagury@live.com"},{"name":"md4","email":"contact@martin-dequatremare.fr"},{"name":"mguihal.iadvize","email":"maxime.guihal@iadvize.com"},{"name":"miaxos","email":"an.griffon@gmail.com"},{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},{"name":"euphocat","email":"nicolas.baptiste@gmail.com"},{"name":"tgenissel","email":"thomas.genissel@iadvize.com"}],"homepage":"https://github.com/iadvize/opaque-type-library#readme","bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"tsd":{"directory":"test-types"},"dist":{"shasum":"eef6747195d5a26935e8f01cacc8e9f15349412f","tarball":"https://registry.npmjs.org/@iadvize-oss/opaque-type/-/opaque-type-1.1.1-canary-9778786-1627751226724.tgz","fileCount":8,"integrity":"sha512-OHuqSmRYXO58O3x6FnTnrpfwNK72zt2eUFkxQxO976hPiJOHJ0VLK+fLJTXZsLY8pU72ydt9VYSlXqblED+F0Q==","signatures":[{"sig":"MEUCICkW18HzNmIh7Ob44AfRztQ0TIxxw2zm7q+fiUIprQArAiEAgL0ehtoel6NpjmZP9yRHiTbrXi7xfZ5WUHz4UYCp150=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13910,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhBYN/CRA9TVsSAnZWagAA21MP/i/wlzj2ZILPPCJ7BuDE\nuimvnFTwyipwXeJGpiLS/ePUYTL5xXwTZt6xr7DhLAJGEDgF6cduIsoN3RXJ\npHhSUDi/ZAu+AJDDRLeOtiWAb98+6ccSlm3WwRUclzw6/EQwgNFB0aSAoO4z\nBAA3KlGAasvisN1XMdiW7c2ExIEGrQ5N0iKP0KncCqIU/nm3tbc8r+kNBgZK\nexIh4e6X/3RtOwQP7ADjWzu/YaQRPWU74NTzJp/1j2AQMdrW6vwWCMX7UB8k\nBudB2Hhp0rndEEL9n7yx0vy6Lcw4/emGrJSz9wHfOqs3Ki9CxHAf4wxva+rY\nDzlic/uz9Mj7qiMj2z11soT37YfMSYrDX9j5NVT2UlpGUtk2yvJFKU+5Qzh1\nlDqXUQyQLPpNVuGf86GQBIOTmF66Veq6AHOGFr63Ge5EzelGEV2yr3fjhgSh\n6M9RuwVkp3KdGArRa+vkNG2G4/mlfq63dDj630BvRlBNEOYI1br6OqBqPcNQ\n5mtUuFuvml46UqlAPfgPZK24HDZUk0yv/cF2FCa4GR8R3oAOy0xWkxlA8o3c\nitNzz0eGOdUV9IWPJsMM7T/oY8S+j/ZcPZmvpUqrZutrIERdTXkWwFdwk3qa\nSZkx9dIrzPDRAhiEQpzahPIBb6K6zfMkUaqLfXoY/IBMfDUtHZncrwHQV3Fq\nzXi2\r\n=HpTu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","types":"dist/index.d.ts","module":"esm/index.js","readme":"@iadvize/opaque-types\n====================\n![Continuous integration](https://github.com/iadvize/opaque-type-library/workflows/Continuous%20integration/badge.svg)\n\n\nInspired from https://codemix.com/opaque-types-in-javascript/\n\n# Usage\n\n```\nnpm add @iadvize-oss/opaque-type\n```\n\n[📖 Documentation](https://iadvize.github.io/opaque-type-library/)\n\n# Why ? \n\n## Semantic type checking\n\nThe following naive code will compile properly, except that if you mix\n`createRoom` parameters you will introduce a nasty bug at runtime.\n\n```typescript\ntype RoomID = string;\ntype UserID = string;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\ncreateRoom(userId, roomId);\n```\n\nOpaque at rescue !\n\nThis following code won't compile, because `Opaque` add more specificty to\n`RoomId` and `UserId`, so typescript wont think they are compatible because they\nare built uppon a `string`;\n\n```typescript\nimport { Opaque } from \"@iadvize-oss/opaque-type\";\n\ntype RoomID = Opaque<\"RoomId\">;\ntype UserID = Opaque<\"UserId\">;\n\nfunction createRoom(roomId: RoomID, userId: UserID) {\n  // something\n}\n\nconst roomId: RoomID = ...;\nconst userId: UserID = ...;\n\ncreateRoom(userId, roomId); // TypeError\n```\n\nHere the error message you will get in your editor or when you will try to build\nyour application\n\n```\nArgument of type 'Opaque<\"UserId\">' is not assignable to parameter of type 'Opaque<\"RoomId\">'.\n  ...\n```\n\n\n## Type opacification (hence the name)\n\nLet say you built a nice piece of code:\n\n```typescript\n// message.ts\ntype Message = {\n  userId: string,\n  text: string,\n};\n\nexport function clearMessageText(message: Message) : Message {\n  return message.text = '';\n}\n\nexport function getMessage():Message {\n  return ...\n}\n```\n\nYou user can endup writting the following code:\n\n```typescript\nimport { clearMessageText, getMessage } from './message';\n\nconst message = { userId: 'userId', text: 'mytext' };\n\nclearMessageText(message); \n\n```\n\nor\n\n```typescript\nimport { getMessage } from '..'\n\nconst message2 = getMessage();\n\nmessage2.userId = 'whatever';\n```\n\nThose two pieces of code are problematic, because in these the inner structure\nof your types are exposed and manipulated.\n\nIf you make any change to the `Message` structure it will be a breaking change\nfor your code user. Meaning that he could find himself to edit dozen or hundreds\nof line of code.\n\nHow can we avoid this protecting our user from creating a code strongly tied to\nyour library internals ?\n\n```typescript\n// message.ts\nimport { createOpaqueAPI } from '../index';\n\ntype $Message = {\n  userId: string,\n  text: string,\n};\n\nconst { toOpaque, fromOpaque } = createOpaqueAPI<\n  'Message',\n  $Message,\n>('Message');\n\ntype Message = ReturnType<typeof toOpaque>;\n\nexport function getMessage(): Message {\n  return toOpaque({ userId: 'userId', text: 'text' });\n}\n\nexport function clearMessageText(message: Message): Message {\n  const $message = fromOpaque(message)\n\n  return toOpaque({\n    ...$message,\n    text: '',\n  });\n}\n```\n\nYour user won't be able to write code in same fashion, he will have to ignore\nthe internals of your code.\n\n```typescript\nimport { getMessage, clearMessageText } from '../index';\n\nconst message = getMessage();\n\nconst messageCleared = clearMessageText(message); \n```\n\nThis is especially usefull when creating a reusable a library:\n\n- It does protect the user of your code from himself\n- It does protect you the maintainer by allowing you to break type structure\n  behind the scène without creating a breaking change.\n","gitHead":"eebbee529d721da73f6feaa9e811e93c01dc107e","private":false,"scripts":{"docs":"typedoc","build":"rm -rf dist esm && rollup -c","lint:js":"eslint . --ext .js,.jsx,.ts,.tsx,.json,.d.ts --cache","test:js":"npm run test:types && npm run test:api","test:api":"jest --coverage","test:types":"tsd"},"_npmUser":{"name":"iadvize-bot","email":"npm-iadvize-oss@iadvize.com"},"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"_npmVersion":"6.14.12","description":"Functional opaque type api for Typescript and Javascript","directories":{},"sideEffects":false,"_nodeVersion":"10.24.1","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsd":"^0.14.0","jest":"^26.6.3","tslib":"^2.2.0","eslint":"^7.25.0","rollup":"^2.47.0","ts-jest":"^26.5.5","typedoc":"^0.21.5","typescript":"^4.0.7","@types/jest":"^26.0.23","rollup-plugin-terser":"^7.0.2","rollup-plugin-typescript2":"^0.29.0","@iadvize-oss/eslint-config":"^2.2.0","@iadvize-oss/eslint-config-jest":"^1.2.1"},"_npmOperationalInternal":{"tmp":"tmp/opaque-type_1.1.1-canary-9778786-1627751226724_1627751295692_0.2258669429503437","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-02-01T21:01:41.659Z","modified":"2025-10-22T09:22:07.873Z","0.0.0-canary-95ae99c383f3f95e1d093499755b870af2cebb08":"2020-02-01T21:01:42.022Z","0.0.1-beta.0-canary-370244ea5d454999736dcfcc97c611e23726b404":"2020-02-02T08:50:07.164Z","0.0.1-beta.1-canary-1c82bb730c9f1d6147437c2d47c5b53b6b99a072":"2020-02-02T09:32:07.108Z","0.0.1-beta.1-canary-e871f6dd2ae24e2e939b9ce8bc574036568fde1d":"2020-02-02T09:34:48.224Z","0.0.1-beta.2-canary-c2145b0333101f18e828be6c8996a58a850d7082":"2020-02-03T20:08:34.226Z","0.0.1-beta.2-canary-7d64d1123b420e58390347c8af1d5834707277ac":"2020-02-03T23:14:46.197Z","0.0.1-beta.2-canary-ad1884a11d4462cdda4c674ec8155c2c413366ce":"2020-02-05T08:13:40.055Z","0.0.1-beta.2-canary-2a742d3330877d5d6abb3bc9f0b8326c03e55374":"2020-02-05T08:16:33.781Z","0.0.1-beta.4-canary-77abaf423812f531f89cb827edb878a8889b6577":"2020-02-09T15:41:46.439Z","0.0.1-beta.5-canary-ca1373821fe5c964cb7b01abaa9a00aadc1d399a":"2020-02-10T17:39:01.810Z","0.0.1-beta.6":"2020-02-10T17:42:12.677Z","0.0.1-beta.6-canary-45aa3549bd7b58b1f2e3b1337e7c01804fada3cc":"2020-02-12T00:34:37.154Z","0.0.1-beta.6-canary-2c331d0f79095c9d8aae26b7b7f7fe3de3cbc54d":"2020-02-12T00:34:54.071Z","0.0.1":"2020-02-12T07:52:09.319Z","0.0.1-canary-5588a797258d790bbea3d67d116fbe816f5a3a4f":"2020-02-12T20:33:19.145Z","1.0.0":"2020-02-12T20:36:00.826Z","1.0.0-canary-6357056ea6ccd0613ca0aeb5720d3136e780370e":"2020-02-14T07:38:29.147Z","1.0.0-canary-b7ebc49d30046bbdf5d509503fc1d66760eff050":"2020-02-14T07:38:46.928Z","1.0.0-canary-06385ab657e2d0960ed236b532b1e39a421ac96f":"2020-02-16T05:14:47.120Z","1.0.0-canary-86184fe7989b6b19d327ea4514a3deff0b58d156":"2020-02-16T05:15:10.871Z","1.0.0-canary-194406ac7ead697b5373e1e7b7dd9290257ca36a":"2020-02-17T08:50:17.780Z","1.0.1":"2020-02-17T08:53:17.842Z","1.0.1-canary-91b8646-1582100771471":"2020-02-19T08:27:03.181Z","1.0.1-canary-93ccbe7-1582100793815":"2020-02-19T08:27:20.583Z","1.0.2-beta.0":"2020-02-19T10:10:54.840Z","1.0.2-beta.0-canary-1a2f75b-1582141821114":"2020-02-19T19:51:11.156Z","1.0.2-beta.0-canary-c439b76-1582141844980":"2020-02-19T19:51:34.589Z","1.0.2-beta.1":"2020-02-20T07:12:56.803Z","1.0.2-beta.1-canary-3a5a0cc-1582234187251":"2020-02-20T21:30:42.557Z","1.0.2-beta.1-canary-9a9837f-1582239111238":"2020-02-20T22:52:42.820Z","1.0.2-beta.1-canary-e2f7616-1582239148334":"2020-02-20T22:53:25.061Z","1.0.2-beta.2":"2020-02-21T09:00:45.857Z","1.0.2-beta.2-canary-29297b9-1582276849355":"2020-02-21T09:21:51.387Z","1.0.2-beta.2-canary-8a7967b-1582533367835":"2020-02-24T08:36:58.578Z","1.0.2-beta.3":"2020-02-24T08:39:18.198Z","1.0.2-beta.3-canary-aa25177-1582577707123":"2020-02-24T20:56:29.252Z","1.0.2-beta.3-canary-b7e2f15-1582578385877":"2020-02-24T21:07:21.849Z","1.0.2-beta.3-canary-9e65889-1582578704239":"2020-02-24T21:12:45.016Z","1.0.2-beta.3-canary-29cc612-1582615963044":"2020-02-25T07:33:51.487Z","1.0.2-beta.3-canary-5773226-1582616158710":"2020-02-25T07:36:52.377Z","1.0.2-beta.4":"2020-02-25T07:40:33.024Z","1.0.2-beta.4-canary-b588baa-1582618324422":"2020-02-25T08:13:02.635Z","1.0.2-beta.4-canary-f3baa1d-1582618348828":"2020-02-25T08:13:59.544Z","1.0.2-beta.4-canary-fccf77b-1582663254431":"2020-02-25T20:41:48.319Z","1.0.2-beta.4-canary-9680a22-1582713795612":"2020-02-26T10:44:09.104Z","1.0.2-beta.4-canary-66f1691-1582714072420":"2020-02-26T10:48:49.310Z","1.0.2-beta.4-canary-f261b22-1582716244261":"2020-02-26T11:25:02.058Z","1.0.2-beta.4-canary-cec2caf-1582790970733":"2020-02-27T08:10:21.254Z","1.0.2-beta.4-canary-be25631-1582806431978":"2020-02-27T12:28:04.516Z","1.0.2-beta.4-canary-28b4ee4-1582806433549":"2020-02-27T12:28:12.917Z","1.0.2-beta.4-canary-973c20b-1582806446205":"2020-02-27T12:28:20.290Z","1.0.2-beta.4-canary-9f13efa-1582806711779":"2020-02-27T12:32:40.737Z","1.0.2-beta.4-canary-fcf1c67-1582806840760":"2020-02-27T12:34:54.619Z","1.0.2-beta.4-canary-3027e21-1582832223725":"2020-02-27T19:37:52.408Z","1.0.2-beta.4-canary-bc6bf3f-1582866476413":"2020-02-28T05:08:44.512Z","1.0.2-beta.4-canary-9bd64d4-1582877000927":"2020-02-28T08:04:17.459Z","1.0.2-beta.4-canary-9e008dc-1582928488626":"2020-02-28T22:22:35.185Z","1.0.2-beta.4-canary-61701b9-1583141015960":"2020-03-02T09:24:31.063Z","1.0.2-beta.4-canary-c3c8d4c-1583223011922":"2020-03-03T08:11:08.981Z","1.0.2-beta.4-canary-5d9f1d8-1583373815517":"2020-03-05T02:04:28.486Z","1.0.2-beta.4-canary-0ebe9de-1583373927689":"2020-03-05T02:06:25.874Z","1.0.2-beta.4-canary-b3511f8-1583397702323":"2020-03-05T08:42:32.667Z","1.0.2-beta.4-canary-5822793-1583487565496":"2020-03-06T09:40:26.113Z","1.0.2-beta.4-canary-1a6ef57-1583546259677":"2020-03-07T01:58:32.889Z","1.0.2-beta.4-canary-67f56a3-1583782697351":"2020-03-09T19:39:11.440Z","1.0.2-beta.4-canary-c03e7bc-1583796076250":"2020-03-09T23:22:04.819Z","1.0.2-beta.5":"2020-03-10T07:40:27.291Z","1.0.2-beta.5-canary-073ecc0-1583827567037":"2020-03-10T08:07:14.076Z","1.0.2-beta.5-canary-70d8677-1583989794731":"2020-03-12T05:10:40.745Z","1.0.2-beta.5-canary-3121565-1584002949437":"2020-03-12T08:50:07.848Z","1.0.2-beta.5-canary-ded2299-1584025903922":"2020-03-12T15:12:44.433Z","1.0.2-beta.5-canary-29a0797-1584085771246":"2020-03-13T07:50:23.719Z","1.0.2-beta.5-canary-9c44638-1584133638444":"2020-03-13T21:08:16.965Z","1.0.2-beta.5-canary-e82e35b-1584314543180":"2020-03-15T23:23:13.254Z","1.0.2-beta.5-canary-b340863-1584504499281":"2020-03-18T04:09:14.902Z","1.0.2-beta.5-canary-29c8eba-1584518489585":"2020-03-18T08:02:27.126Z","1.0.2-beta.5-canary-a7adb04-1584719250948":"2020-03-20T15:48:39.242Z","1.0.2-beta.5-canary-c875153-1584719510030":"2020-03-20T15:52:44.734Z","1.0.2-beta.5-canary-09c327e-1584831868407":"2020-03-21T23:05:26.686Z","1.0.2-beta.5-canary-024cc3a-1584852484945":"2020-03-22T04:48:56.765Z","1.0.2-beta.5-canary-a2a8e1b-1584876898818":"2020-03-22T11:35:51.377Z","1.0.2-beta.5-canary-7dad17d-1585065999095":"2020-03-24T16:07:37.201Z","1.0.2-beta.5-canary-58883d0-1585159380708":"2020-03-25T18:04:03.644Z","1.0.2-beta.5-canary-33fd1f2-1585160147428":"2020-03-25T18:16:41.741Z","1.0.2-beta.5-canary-64628a4-1585215564804":"2020-03-26T09:40:27.633Z","1.0.2-beta.5-canary-f85fe06-1585215584641":"2020-03-26T09:40:36.327Z","1.0.2-beta.5-canary-5b50d3a-1585239960903":"2020-03-26T16:27:05.548Z","1.0.2-beta.5-canary-4f85072-1585255148983":"2020-03-26T20:40:09.264Z","1.0.2-beta.5-canary-9956bbb-1585255171123":"2020-03-26T20:40:28.942Z","1.0.2-beta.5-canary-a350247-1585296748232":"2020-03-27T08:13:23.143Z","1.0.2-beta.5-canary-df43901-1585510987354":"2020-03-29T19:44:00.652Z","1.0.2-beta.5-canary-93332d4-1585511177742":"2020-03-29T19:47:15.925Z","1.0.2-beta.5-canary-efc3428-1585513774336":"2020-03-29T20:30:38.363Z","1.0.2-beta.5-canary-87f5d3e-1585549622185":"2020-03-30T06:27:58.924Z","1.0.2-beta.5-canary-78da5e2-1585560770677":"2020-03-30T09:33:54.971Z","1.0.2-beta.5-canary-8d68c0a-1585565474369":"2020-03-30T10:52:15.663Z","1.0.2-beta.5-canary-16cbc82-1585597646849":"2020-03-30T19:48:23.208Z","1.0.2-beta.5-canary-233cdfc-1585687816372":"2020-03-31T20:51:11.737Z","1.0.2-beta.5-canary-dc20aec-1585824246940":"2020-04-02T10:45:11.384Z","1.0.2-beta.5-canary-494caea-1585824454592":"2020-04-02T10:48:34.729Z","1.0.2-beta.5-canary-6ad0f06-1585847004845":"2020-04-02T17:04:30.986Z","1.0.2-beta.5-canary-00da276-1585903938133":"2020-04-03T08:53:17.577Z","1.0.2-beta.5-canary-07c03e8-1585926926584":"2020-04-03T15:16:25.348Z","1.0.2-beta.5-canary-2e3cd2c-1585947765082":"2020-04-03T21:03:50.065Z","1.0.2-beta.5-canary-a46d0e4-1585949290385":"2020-04-03T21:29:08.472Z","1.0.2-beta.5-canary-59298c4-1586040691809":"2020-04-04T22:52:29.001Z","1.0.2-beta.5-canary-2e5733f-1586141282355":"2020-04-06T02:52:19.281Z","1.0.2-beta.5-canary-aeff84a-1586289027384":"2020-04-07T19:51:23.269Z","1.0.2-beta.5-canary-f03835f-1586293426880":"2020-04-07T21:05:13.861Z","1.0.2-beta.5-canary-d7db17f-1586352724252":"2020-04-08T13:32:57.839Z","1.0.2-beta.5-canary-1a36d61-1586352745971":"2020-04-08T13:33:26.240Z","1.0.2-beta.5-canary-12acd7f-1586467458366":"2020-04-09T21:25:16.352Z","1.0.2-beta.5-canary-03c8e78-1586468958211":"2020-04-09T21:50:22.151Z","1.0.2-beta.5-canary-b9273bf-1586551421684":"2020-04-10T20:44:42.232Z","1.0.2-beta.5-canary-e76d25f-1586552014658":"2020-04-10T20:54:39.788Z","1.0.2-beta.5-canary-b067bac-1586727799253":"2020-04-12T21:44:25.558Z","1.0.2-beta.5-canary-ef529f9-1587112302340":"2020-04-17T08:32:45.302Z","1.0.2-beta.5-canary-d397330-1587333301668":"2020-04-19T21:56:01.036Z","1.0.2-beta.5-canary-e9cf1dc-1587334338587":"2020-04-19T22:13:10.905Z","1.0.2-beta.5-canary-d75adb4-1587498012278":"2020-04-21T19:41:12.199Z","1.0.2-beta.5-canary-f12c956-1587502643213":"2020-04-21T20:58:33.204Z","1.0.2-beta.5-canary-a7f94bd-1587582397601":"2020-04-22T19:07:45.854Z","1.0.2-beta.5-canary-65fd91c-1587919873189":"2020-04-26T16:52:10.604Z","1.0.2-beta.5-canary-9ef441a-1587949973107":"2020-04-27T01:13:56.346Z","1.0.2-beta.5-canary-b231473-1588012900301":"2020-04-27T18:42:44.812Z","1.0.2-beta.5-canary-2c17e3b-1588103412645":"2020-04-28T19:51:07.506Z","1.0.2-beta.5-canary-0f84c9d-1588103466646":"2020-04-28T19:52:12.573Z","1.0.2-beta.5-canary-2c1627e-1588157983350":"2020-04-29T11:00:42.964Z","1.0.2-beta.5-canary-c424596-1588158013144":"2020-04-29T11:01:33.605Z","1.0.2-beta.5-canary-79bfa68-1588185892953":"2020-04-29T18:45:46.372Z","1.0.2-beta.5-canary-15e7976-1588186715813":"2020-04-29T18:59:40.978Z","1.0.2-beta.5-canary-8179d1d-1588187147368":"2020-04-29T19:07:01.506Z","1.0.2-beta.5-canary-efe0053-1588190101851":"2020-04-29T19:56:10.756Z","1.0.2-beta.5-canary-992f400-1588197333350":"2020-04-29T21:56:38.080Z","1.0.2-beta.5-canary-1f9fb09-1588273271465":"2020-04-30T19:02:14.022Z","1.0.2-beta.5-canary-a5513b9-1588285015103":"2020-04-30T22:18:01.213Z","1.0.2-beta.5-canary-889992d-1588407679745":"2020-05-02T08:25:04.204Z","1.0.2-beta.5-canary-ecbddb2-1588615076695":"2020-05-04T17:58:52.152Z","1.0.2-beta.5-canary-19cce0a-1588675647653":"2020-05-05T10:48:37.487Z","1.0.2-beta.5-canary-52169e8-1588721273741":"2020-05-05T23:28:53.001Z","1.0.2-beta.5-canary-0055846-1588748538997":"2020-05-06T07:03:22.110Z","1.0.2-beta.5-canary-244d597-1588755806680":"2020-05-06T09:04:37.675Z","1.0.2-beta.5-canary-37986c1-1588828986179":"2020-05-07T05:24:05.971Z","1.0.2-beta.5-canary-0f6ff6f-1588841434488":"2020-05-07T08:51:28.948Z","1.0.2-beta.5-canary-b7cc680-1589014630167":"2020-05-09T08:58:16.267Z","1.0.2-beta.5-canary-1478730-1589108142075":"2020-05-10T10:56:40.358Z","1.0.2-beta.5-canary-6f53112-1589190833506":"2020-05-11T09:54:50.203Z","1.0.2-beta.5-canary-56d1eba-1589307147434":"2020-05-12T18:13:25.806Z","1.0.2-beta.5-canary-1bd0d03-1589312259435":"2020-05-12T19:38:52.134Z","1.0.2-beta.5-canary-344fe6b-1589318878356":"2020-05-12T21:28:57.843Z","1.0.2-beta.5-canary-8020112-1589347820274":"2020-05-13T05:31:25.398Z","1.0.2-beta.5-canary-ee56d70-1589352647665":"2020-05-13T06:51:46.015Z","1.0.2-beta.5-canary-a5f43c8-1589353590846":"2020-05-13T07:07:36.347Z","1.0.2-beta.5-canary-4993fa1-1589395986518":"2020-05-13T18:54:41.467Z","1.0.2-beta.5-canary-615f6d2-1589411502969":"2020-05-13T23:12:40.207Z","1.0.2-beta.5-canary-adf58ed-1589523511339":"2020-05-15T06:19:47.778Z","1.0.2-beta.5-canary-80d3baa-1589687934188":"2020-05-17T04:00:20.170Z","1.0.2-beta.5-canary-6f46f4a-1589842476806":"2020-05-18T22:55:28.053Z","1.0.2-beta.5-canary-3b59d34-1589843950138":"2020-05-18T23:19:59.711Z","1.0.2-beta.5-canary-4cb1b65-1589870044852":"2020-05-19T06:35:01.578Z","1.0.2-beta.5-canary-e72c8bc-1589922341260":"2020-05-19T21:06:43.226Z","1.0.2-beta.5-canary-8590bed-1589956040845":"2020-05-20T06:28:22.467Z","1.0.2-beta.5-canary-0f5d3ef-1589958814757":"2020-05-20T07:14:28.518Z","1.0.2-beta.5-canary-6bf94e0-1590127697800":"2020-05-22T06:09:16.404Z","1.0.2-beta.5-canary-eee8d3b-1590213645497":"2020-05-23T06:01:49.731Z","1.0.2-beta.5-canary-a8f684e-1590228899568":"2020-05-23T10:16:01.877Z","1.0.2-beta.5-canary-d887954-1590232693016":"2020-05-23T11:19:24.379Z","1.0.2-beta.5-canary-3de3e1c-1590302819712":"2020-05-24T06:48:01.841Z","1.0.2-beta.5-canary-6866f6f-1590358852675":"2020-05-24T22:22:01.994Z","1.0.2-beta.5-canary-dddd665-1590388038222":"2020-05-25T06:28:11.502Z","1.0.2-beta.5-canary-932ef46-1590388249417":"2020-05-25T06:33:00.632Z","1.0.2-beta.5-canary-280615b-1590477704162":"2020-05-26T07:22:37.999Z","1.1.0":"2020-05-26T07:25:14.582Z","1.1.0-canary-be49305-1590530930008":"2020-05-26T22:09:43.117Z","1.1.0-canary-e894cb9-1590531655438":"2020-05-26T22:21:49.483Z","1.1.0-canary-843a022-1590610125425":"2020-05-27T20:09:41.497Z","1.1.0-canary-f7e9ea3-1590622926924":"2020-05-27T23:42:58.720Z","1.1.0-canary-6153d68-1590623623619":"2020-05-27T23:54:44.634Z","1.1.0-canary-bb524af-1590646959609":"2020-05-28T06:23:41.683Z","1.1.0-canary-dbbeba6-1590870373720":"2020-05-30T20:27:16.357Z","1.1.0-canary-8bcc443-1590871135457":"2020-05-30T20:40:38.699Z","1.1.0-canary-cfcb72b-1590900349309":"2020-05-31T04:46:49.023Z","1.1.0-canary-af2c380-1591132026664":"2020-06-02T21:08:04.339Z","1.1.0-canary-d27fdb3-1591216500836":"2020-06-03T20:36:05.544Z","1.1.0-canary-c0e2c2d-1591250949476":"2020-06-04T06:10:14.249Z","1.1.0-canary-4f0596f-1591305030945":"2020-06-04T21:11:38.696Z","1.1.0-canary-d890821-1591569709557":"2020-06-07T22:42:47.929Z","1.1.0-canary-04b04b7-1591658231490":"2020-06-08T23:18:08.625Z","1.1.0-canary-ae2e3f2-1591741234969":"2020-06-09T22:21:52.413Z","1.1.0-canary-2520b7e-1592175902594":"2020-06-14T23:06:16.138Z","1.1.0-canary-e44ecae-1592430687157":"2020-06-17T21:52:34.219Z","1.1.0-canary-48f3c2f-1592678994388":"2020-06-20T18:50:46.705Z","1.1.1":"2020-06-20T18:54:18.342Z","1.1.1-canary-2835045-1592861953392":"2020-06-22T21:40:14.736Z","1.1.1-canary-9f5ddd3-1592863004027":"2020-06-22T21:57:37.225Z","1.1.1-canary-315c2b7-1592963825365":"2020-06-24T01:57:52.228Z","1.1.1-canary-9ac4336-1593026141405":"2020-06-24T19:16:37.499Z","1.1.1-canary-2dcb984-1593193095672":"2020-06-26T17:39:28.081Z","1.1.1-canary-0e0453a-1593200935579":"2020-06-26T19:49:42.334Z","1.1.1-canary-28381e5-1593348286133":"2020-06-28T12:45:34.351Z","1.1.1-canary-02214be-1593394297099":"2020-06-29T01:34:00.353Z","1.1.1-canary-b4e7f51-1593435350066":"2020-06-29T12:56:55.778Z","1.1.1-canary-30cf674-1593438454258":"2020-06-29T13:48:20.075Z","1.1.1-canary-a143360-1593454105193":"2020-06-29T18:09:13.473Z","1.1.1-canary-b234752-1593469078439":"2020-06-29T22:18:42.976Z","1.1.1-canary-59e8c5c-1593636922345":"2020-07-01T20:56:18.014Z","1.1.1-canary-9048baa-1593664043026":"2020-07-02T04:28:11.175Z","1.1.1-canary-e235d2e-1593710139329":"2020-07-02T17:16:56.031Z","1.1.1-canary-89d55f2-1593808150498":"2020-07-03T20:30:03.249Z","1.1.1-canary-13ce33b-1593860332468":"2020-07-04T10:59:40.205Z","1.1.1-canary-ddbf940-1593865597717":"2020-07-04T12:27:33.554Z","1.1.1-canary-b290deb-1593928066513":"2020-07-05T05:48:34.573Z","1.1.1-canary-eeb26b7-1594080074979":"2020-07-07T00:02:13.743Z","1.1.1-canary-bd11d0c-1594085260830":"2020-07-07T01:28:25.581Z","1.1.1-canary-f45a7ff-1594165990895":"2020-07-07T23:53:54.356Z","1.1.1-canary-0f25678-1594663692687":"2020-07-13T18:09:14.096Z","1.1.1-canary-c5aaeb5-1594857810973":"2020-07-16T00:04:34.788Z","1.1.1-canary-97e0dd6-1594930378573":"2020-07-16T20:13:48.693Z","1.1.1-canary-ef3ebd9-1594967039662":"2020-07-17T06:25:00.956Z","1.1.1-canary-df4352d-1595047577310":"2020-07-18T04:47:03.058Z","1.1.1-canary-95b8ff8-1595088595024":"2020-07-18T16:10:51.361Z","1.1.1-canary-1aff06a-1595101006498":"2020-07-18T19:37:51.923Z","1.1.1-canary-13a1f8b-1595101739339":"2020-07-18T19:49:45.563Z","1.1.1-canary-f22df89-1595398538126":"2020-07-22T06:16:29.169Z","1.1.1-canary-9b5608a-1595527860204":"2020-07-23T18:11:52.199Z","1.1.1-canary-29ba22a-1595536520777":"2020-07-23T20:36:10.295Z","1.1.1-canary-6ab07e5-1595550278146":"2020-07-24T00:25:24.753Z","1.1.1-canary-4b015aa-1595947718763":"2020-07-28T14:49:47.098Z","1.1.1-canary-8f9789f-1596139189833":"2020-07-30T20:01:16.372Z","1.1.1-canary-8a52c06-1596178764805":"2020-07-31T07:00:18.437Z","1.1.1-canary-a09240b-1596249252055":"2020-08-01T02:35:15.122Z","1.1.1-canary-11cb359-1596279455934":"2020-08-01T10:58:26.934Z","1.1.1-canary-bdf5814-1596677952836":"2020-08-06T01:40:01.408Z","1.1.1-canary-0de0a23-1596756645961":"2020-08-06T23:31:46.345Z","1.1.1-canary-59df1ec-1596828276128":"2020-08-07T19:25:25.360Z","1.1.1-canary-d94387b-1596832372333":"2020-08-07T20:33:42.744Z","1.1.1-canary-d125172-1596934252991":"2020-08-09T00:51:53.580Z","1.1.1-canary-fadce8c-1596978679443":"2020-08-09T13:12:13.103Z","1.1.1-canary-6a1a741-1597096056568":"2020-08-10T21:48:59.008Z","1.1.1-canary-9602310-1597180556145":"2020-08-11T21:16:42.870Z","1.1.1-canary-84e1414-1597288691922":"2020-08-13T03:19:00.260Z","1.1.1-canary-a7ae075-1597369520429":"2020-08-14T01:46:10.552Z","1.1.1-canary-c57466b-1597400116052":"2020-08-14T10:16:35.764Z","1.1.1-canary-cdde177-1597449664369":"2020-08-15T00:01:51.311Z","1.1.1-canary-bb41975-1597453968183":"2020-08-15T01:14:40.749Z","1.1.1-canary-0ef57e9-1597467249834":"2020-08-15T04:54:55.761Z","1.1.1-canary-9fdc7af-1597553784580":"2020-08-16T04:57:08.373Z","1.1.1-canary-2c57508-1597557839436":"2020-08-16T06:05:02.934Z","1.1.1-canary-131940f-1597607682619":"2020-08-16T19:55:32.958Z","1.1.1-canary-beb9192-1598079882939":"2020-08-22T07:05:40.634Z","1.1.1-canary-9cbd1e4-1598101965119":"2020-08-22T13:13:41.927Z","1.1.1-canary-d8b7da5-1598508090877":"2020-08-27T06:02:22.921Z","1.1.1-canary-eab086a-1598510892902":"2020-08-27T06:49:14.349Z","1.1.1-canary-5ba4aa3-1598592636521":"2020-08-28T05:31:33.583Z","1.1.1-canary-9f75988-1598708164906":"2020-08-29T13:37:09.884Z","1.1.1-canary-2fd4c5d-1598710337660":"2020-08-29T14:13:14.924Z","1.1.1-canary-a428f46-1598712094514":"2020-08-29T14:42:21.754Z","1.1.1-canary-4eed585-1598969492986":"2020-09-01T14:12:32.879Z","1.1.1-canary-ffc7f1e-1598974390531":"2020-09-01T15:34:19.136Z","1.1.1-canary-2652c98-1599031351178":"2020-09-02T07:23:23.513Z","1.1.1-canary-2e25b95-1599067290644":"2020-09-02T17:22:20.331Z","1.1.1-canary-719a459-1599145407024":"2020-09-03T15:04:26.088Z","1.1.1-canary-3f954b2-1599330115651":"2020-09-05T18:22:51.300Z","1.1.1-canary-344952a-1599339415860":"2020-09-05T20:57:50.355Z","1.1.1-canary-d2d2065-1599936663488":"2020-09-12T18:51:56.223Z","1.1.1-canary-5bc165f-1600350589390":"2020-09-17T13:50:55.837Z","1.1.1-canary-c26570b-1600526192934":"2020-09-19T14:37:26.950Z","1.1.1-canary-a485ced-1600599378560":"2020-09-20T10:57:11.084Z","1.1.1-canary-581d2eb-1600653941457":"2020-09-21T02:06:31.049Z","1.1.1-canary-463482c-1601096460246":"2020-09-26T05:01:56.350Z","1.1.1-canary-367c1df-1601158677167":"2020-09-26T22:18:51.251Z","1.1.1-canary-72f737a-1601460787398":"2020-09-30T10:14:11.648Z","1.1.1-canary-c2b6182-1601950934300":"2020-10-06T02:23:05.110Z","1.1.1-canary-717db69-1602085514502":"2020-10-07T15:46:13.917Z","1.1.1-canary-566bb76-1602101761936":"2020-10-07T20:16:51.628Z","1.1.1-canary-a1076f1-1602243255147":"2020-10-09T11:35:20.585Z","1.1.1-canary-9a45251-1602417604212":"2020-10-11T12:01:09.691Z","1.1.1-canary-9bf30f9-1602424126921":"2020-10-11T13:49:45.881Z","1.1.1-canary-3e06e5c-1602439546186":"2020-10-11T18:06:41.088Z","1.1.1-canary-0139810-1602694620675":"2020-10-14T16:58:03.812Z","1.1.1-canary-775b394-1602796683028":"2020-10-15T21:18:54.320Z","1.1.1-canary-3f79eea-1602798093608":"2020-10-15T21:42:30.561Z","1.1.1-canary-9e16b46-1602916777734":"2020-10-17T06:40:35.966Z","1.1.1-canary-552fedd-1603031024483":"2020-10-18T14:24:32.551Z","1.1.1-canary-1f85529-1603179184054":"2020-10-20T07:33:59.591Z","1.1.1-canary-58602c5-1603290660780":"2020-10-21T14:32:21.428Z","1.1.1-canary-4350e75-1603354976299":"2020-10-22T08:24:06.585Z","1.1.1-canary-500ea59-1603548577843":"2020-10-24T14:10:48.536Z","1.1.1-canary-4a84501-1603616456186":"2020-10-25T09:02:02.903Z","1.1.1-canary-fc6ff88-1603633945478":"2020-10-25T13:53:14.350Z","1.1.1-canary-58148e8-1603650080917":"2020-10-25T18:22:16.132Z","1.1.1-canary-3c0bbb2-1603830483772":"2020-10-27T20:28:58.725Z","1.1.1-canary-4208134-1603838712674":"2020-10-27T22:46:09.131Z","1.1.1-canary-fd85ee5-1603848458948":"2020-10-28T01:28:27.700Z","1.1.1-canary-2d316d4-1604107225974":"2020-10-31T01:21:16.580Z","1.1.1-canary-fa5a7a0-1604213890306":"2020-11-01T06:59:13.167Z","1.1.1-canary-6f09247-1604273054807":"2020-11-01T23:25:09.501Z","1.1.1-canary-c6cd4cc-1604309954011":"2020-11-02T09:40:04.211Z","1.1.1-canary-48ad75f-1604310764637":"2020-11-02T09:53:37.222Z","1.1.1-canary-32880a9-1604315402892":"2020-11-02T11:10:55.605Z","1.1.1-canary-cb5aa41-1604316908580":"2020-11-02T11:35:55.961Z","1.1.1-canary-bbdf5c9-1604322483523":"2020-11-02T13:09:13.538Z","1.1.1-canary-fd0081b-1604480585015":"2020-11-04T09:04:11.134Z","1.1.1-canary-b5953b6-1604714929475":"2020-11-07T02:09:38.227Z","1.1.1-canary-eabb900-1604848093339":"2020-11-08T15:09:12.741Z","1.1.1-canary-8f30d8c-1605363766533":"2020-11-14T14:23:52.720Z","1.1.1-canary-4ac3da0-1605687302992":"2020-11-18T08:15:59.514Z","1.1.1-canary-d7ffeef-1605912871554":"2020-11-20T22:55:23.281Z","1.1.1-canary-5e05e71-1606630494127":"2020-11-29T06:15:48.561Z","1.1.1-canary-d5e13ca-1606854733107":"2020-12-01T21:05:27.986Z","1.1.1-canary-4cfd792-1606983962877":"2020-12-03T08:26:56.005Z","1.1.1-canary-774e651-1606987469439":"2020-12-03T09:25:33.259Z","1.1.1-canary-ff08777-1607101017117":"2020-12-04T16:57:46.002Z","1.1.1-canary-7c136c2-1607110934970":"2020-12-04T19:43:04.636Z","1.1.1-canary-8238b81-1607156225697":"2020-12-05T08:18:06.947Z","1.1.1-canary-22c6067-1607234650807":"2020-12-06T06:05:01.536Z","1.1.1-canary-f83296a-1607405497156":"2020-12-08T05:32:53.497Z","1.1.1-canary-7d44b6a-1607461201724":"2020-12-08T21:00:54.392Z","1.1.1-canary-3acb49a-1607621541645":"2020-12-10T17:33:09.416Z","1.1.1-canary-652729a-1607640204628":"2020-12-10T22:44:16.242Z","1.1.1-canary-3e02efc-1607945336112":"2020-12-14T11:29:52.379Z","1.1.1-canary-79a8292-1607957934328":"2020-12-14T14:59:46.619Z","1.1.1-canary-a4fd5dc-1608328910278":"2020-12-18T22:02:59.948Z","1.1.1-canary-75fe0c1-1608570061628":"2020-12-21T17:01:54.032Z","1.1.1-canary-2f89a18-1608640866496":"2020-12-22T12:41:55.444Z","1.1.1-canary-6b8a2d3-1609181466168":"2020-12-28T18:51:57.566Z","1.1.1-canary-a6e6695-1609219825812":"2020-12-29T05:31:17.465Z","1.1.1-canary-51f8eb4-1609264766305":"2020-12-29T18:00:21.930Z","1.1.1-canary-fba59a0-1609272409690":"2020-12-29T20:07:44.434Z","1.1.1-canary-a0004b7-1609286724879":"2020-12-30T00:06:13.602Z","1.1.1-canary-afe8853-1609363184528":"2020-12-30T21:20:34.863Z","1.1.1-canary-8b153c0-1609465237167":"2021-01-01T01:41:30.973Z","1.1.1-canary-d47ed33-1609492725302":"2021-01-01T09:19:37.109Z","1.1.1-canary-affe1f5-1609541251553":"2021-01-01T22:48:17.230Z","1.1.1-canary-a9dedf6-1609557112742":"2021-01-02T03:12:44.673Z","1.1.1-canary-dbc1218-1609564277611":"2021-01-02T05:12:07.087Z","1.1.1-canary-a249b82-1609638840018":"2021-01-03T01:54:43.989Z","1.1.1-canary-61ca8f3-1609791587354":"2021-01-04T20:20:42.772Z","1.1.1-canary-d422dc1-1609806748199":"2021-01-05T00:33:12.789Z","1.1.1-canary-b25f9b1-1609854132044":"2021-01-05T13:43:13.265Z","1.1.1-canary-6374da9-1609889788878":"2021-01-05T23:37:14.936Z","1.1.1-canary-f0df008-1609910674239":"2021-01-06T05:25:21.893Z","1.1.1-canary-fc1a98f-1609943997655":"2021-01-06T14:40:47.818Z","1.1.1-canary-15f1e9b-1610012151794":"2021-01-07T09:36:40.709Z","1.1.1-canary-acbb560-1610223837845":"2021-01-09T20:24:43.556Z","1.1.1-canary-0686096-1610752507981":"2021-01-15T23:15:57.917Z","1.1.1-canary-c8f8911-1610778862290":"2021-01-16T06:35:13.243Z","1.1.1-canary-73f3416-1610820725580":"2021-01-16T18:12:56.147Z","1.1.1-canary-0309f44-1610851051898":"2021-01-17T02:38:43.034Z","1.1.1-canary-3256e81-1611046173496":"2021-01-19T08:51:08.198Z","1.1.1-canary-778e11d-1611145531555":"2021-01-20T12:26:28.551Z","1.1.1-canary-414eefc-1611333153071":"2021-01-22T16:33:28.745Z","1.1.1-canary-cfa9ea5-1611433264189":"2021-01-23T20:21:53.655Z","1.1.1-canary-9fed8de-1611517256217":"2021-01-24T19:41:54.657Z","1.1.1-canary-0304477-1611586331477":"2021-01-25T14:53:01.444Z","1.1.1-canary-a15c19c-1611591136534":"2021-01-25T16:13:17.728Z","1.1.1-canary-3439db2-1611843817632":"2021-01-28T14:24:39.252Z","1.1.1-canary-d9183a0-1611928497358":"2021-01-29T13:55:56.802Z","1.1.1-canary-f9eb947-1612069309929":"2021-01-31T05:02:35.506Z","1.1.1-canary-107b5bc-1612079718340":"2021-01-31T07:56:17.854Z","1.1.1-canary-c1d109b-1612125291569":"2021-01-31T20:35:42.564Z","1.1.1-canary-8cd500e-1612178933536":"2021-02-01T11:29:43.438Z","1.1.1-canary-0e76662-1612253867131":"2021-02-02T08:18:49.071Z","1.1.1-canary-4b2e5cc-1612515107644":"2021-02-05T08:52:36.658Z","1.1.1-canary-b4fd7b5-1612548402699":"2021-02-05T18:07:34.333Z","1.1.1-canary-f9bf579-1612628824041":"2021-02-06T16:28:05.673Z","1.1.1-canary-37845ab-1612652123711":"2021-02-06T22:56:10.274Z","1.1.1-canary-6cc5ff4-1612873622470":"2021-02-09T12:27:58.244Z","1.1.1-canary-f87888c-1612897009877":"2021-02-09T18:57:44.089Z","1.1.1-canary-e3929a3-1612990047524":"2021-02-10T20:48:22.418Z","1.1.1-canary-826aa25-1613014643612":"2021-02-11T03:38:24.488Z","1.1.1-canary-58b9699-1613146062073":"2021-02-12T16:08:37.910Z","1.1.1-canary-bc1da82-1613170002290":"2021-02-12T22:47:34.811Z","1.1.1-canary-0dd7fac-1613360741891":"2021-02-15T03:46:37.227Z","1.1.1-canary-4a2fc73-1613666253390":"2021-02-18T16:38:27.309Z","1.1.1-canary-4499200-1613791330979":"2021-02-20T03:22:58.269Z","1.1.1-canary-c64be92-1613865688568":"2021-02-21T00:02:20.731Z","1.1.1-canary-e6abd72-1614045959458":"2021-02-23T02:06:48.855Z","1.1.1-canary-9a898df-1614075665360":"2021-02-23T10:22:02.119Z","1.1.1-canary-7b1e798-1614118965986":"2021-02-23T22:23:41.235Z","1.1.1-canary-fbec41c-1614122191378":"2021-02-23T23:17:20.866Z","1.1.1-canary-69c5888-1614208467710":"2021-02-24T23:15:15.855Z","1.1.1-canary-e2a2fda-1614350809006":"2021-02-26T14:47:44.402Z","1.1.1-canary-557da4e-1614464576863":"2021-02-27T22:23:44.470Z","1.1.1-canary-29eb579-1614554908052":"2021-02-28T23:29:15.084Z","1.1.1-canary-7d30d56-1614835170404":"2021-03-04T05:20:26.493Z","1.1.1-canary-dade30c-1614846763103":"2021-03-04T08:33:35.220Z","1.1.1-canary-5d81b81-1615048197914":"2021-03-06T16:31:01.646Z","1.1.1-canary-d6d292c-1615159271182":"2021-03-07T23:21:55.726Z","1.1.1-canary-97b22c4-1615279991651":"2021-03-09T08:54:10.723Z","1.1.1-canary-1822da7-1615418103314":"2021-03-10T23:16:00.887Z","1.1.1-canary-eafa57e-1615439907923":"2021-03-11T05:19:18.613Z","1.1.1-canary-5ee4803-1615504510954":"2021-03-11T23:16:03.440Z","1.1.1-canary-7c52b3b-1615560023836":"2021-03-12T14:41:43.020Z","1.1.1-canary-a35b410-1615585902465":"2021-03-12T21:52:40.609Z","1.1.1-canary-d8e39ec-1615694045382":"2021-03-14T03:54:59.255Z","1.1.1-canary-b550c60-1615752338803":"2021-03-14T20:06:27.452Z","1.1.1-canary-b538b7d-1615850164778":"2021-03-15T23:17:04.215Z","1.1.1-canary-9e46d0a-1615883131543":"2021-03-16T08:26:28.723Z","1.1.1-canary-98af860-1615905150272":"2021-03-16T14:33:26.751Z","1.1.1-canary-8bfc8cb-1615988155338":"2021-03-17T13:36:54.840Z","1.1.1-canary-94ac0d8-1615997123234":"2021-03-17T16:06:21.510Z","1.1.1-canary-d033a6d-1616044880033":"2021-03-18T05:22:15.867Z","1.1.1-canary-e2243c1-1616109354245":"2021-03-18T23:16:48.047Z","1.1.1-canary-e9d7d61-1616109361245":"2021-03-18T23:17:04.119Z","1.1.1-canary-68c0300-1616142237901":"2021-03-19T08:24:49.195Z","1.1.1-canary-a3e0d5d-1616220452205":"2021-03-20T06:08:24.359Z","1.1.1-canary-e3c083b-1616369072757":"2021-03-21T23:25:19.040Z","1.1.1-canary-3b39a81-1616376520844":"2021-03-22T01:29:42.694Z","1.1.1-canary-0aeb522-1616393828933":"2021-03-22T06:18:08.515Z","1.1.1-canary-7d49358-1616424988972":"2021-03-22T14:57:33.269Z","1.1.1-canary-9e8da5c-1616541306562":"2021-03-23T23:15:56.258Z","1.1.1-canary-d9b6be6-1616596890182":"2021-03-24T14:42:31.929Z","1.1.1-canary-d312191-1616643438682":"2021-03-25T03:38:17.420Z","1.1.1-canary-c6a9f50-1616695706194":"2021-03-25T18:09:17.650Z","1.1.1-canary-0cf9796-1616792841962":"2021-03-26T21:08:23.384Z","1.1.1-canary-d4ce30f-1616823863898":"2021-03-27T05:45:23.751Z","1.1.1-canary-d0a4ebb-1616913025554":"2021-03-28T06:31:21.847Z","1.1.1-canary-cef6442-1617031481510":"2021-03-29T15:25:37.656Z","1.1.1-canary-1dc550b-1617038482209":"2021-03-29T17:22:14.985Z","1.1.1-canary-36a6d8e-1617142438959":"2021-03-30T22:14:48.484Z","1.1.1-canary-fb9608c-1617481017009":"2021-04-03T20:17:53.665Z","1.1.1-canary-8cf98e6-1617647342641":"2021-04-05T18:30:07.752Z","1.1.1-canary-4849cbe-1617747227075":"2021-04-06T22:14:38.935Z","1.1.1-canary-d849564-1617833694213":"2021-04-07T22:15:52.240Z","1.1.1-canary-0bba690-1617945900927":"2021-04-09T05:25:52.918Z","1.1.1-canary-2bb2c8d-1618006766393":"2021-04-09T22:20:22.515Z","1.1.1-canary-1f15451-1618031968125":"2021-04-10T05:20:09.474Z","1.1.1-canary-d15e54c-1618265739056":"2021-04-12T22:16:29.641Z","1.1.1-canary-4e82c16-1618292263250":"2021-04-13T05:38:34.818Z","1.1.1-canary-65dadd4-1618438532691":"2021-04-14T22:16:27.351Z","1.1.1-canary-daad75a-1619146307841":"2021-04-23T02:52:47.868Z","1.1.1-canary-f2c6cdc-1619218187727":"2021-04-23T22:50:43.084Z","1.1.1-canary-3bd01b5-1619552767457":"2021-04-27T19:46:59.609Z","1.1.1-canary-417a824-1619674717323":"2021-04-29T05:39:27.043Z","1.1.1-canary-e8eebb9-1619710294921":"2021-04-29T15:32:48.759Z","1.1.1-canary-8501666-1619994079111":"2021-05-02T22:22:11.463Z","1.1.1-canary-dc34773-1620106081964":"2021-05-04T05:28:53.074Z","1.1.1-canary-4603cb0-1620222311178":"2021-05-05T13:46:17.708Z","1.1.1-canary-6411ddf-1620252834422":"2021-05-05T22:14:36.823Z","1.1.1-canary-f3eb721-1620252831738":"2021-05-05T22:14:42.880Z","1.1.1-canary-9e1d8bf-1620317906335":"2021-05-06T16:19:18.866Z","1.1.1-canary-6e44621-1620326942458":"2021-05-06T18:49:53.128Z","1.1.1-canary-89325e7-1620413505425":"2021-05-07T18:52:38.339Z","1.1.1-canary-a665a4e-1622413500906":"2021-05-30T22:25:55.077Z","1.1.1-canary-7662dad-1623104116345":"2021-06-07T22:16:12.796Z","1.1.1-canary-8c70834-1623190559876":"2021-06-08T22:16:51.970Z","1.1.1-canary-fe09311-1623276921257":"2021-06-09T22:16:18.650Z","1.1.1-canary-9b2ecc8-1623881836840":"2021-06-16T22:18:03.920Z","1.1.1-canary-a14c73c-1623887116926":"2021-06-16T23:46:03.539Z","1.1.1-canary-c461827-1623984712161":"2021-06-18T02:52:46.874Z","1.1.1-canary-20e4972-1624591415859":"2021-06-25T03:24:25.083Z","1.1.1-canary-9c6c5f1-1624761504598":"2021-06-27T02:39:13.260Z","1.1.1-canary-1bf27d3-1625005362618":"2021-06-29T22:23:32.764Z","1.1.1-canary-8ba43f3-1625442419084":"2021-07-04T23:47:45.697Z","1.1.1-canary-0ee5b15-1625946553376":"2021-07-10T19:50:04.041Z","1.1.1-canary-63eb4b3-1626046828782":"2021-07-11T23:41:20.061Z","1.1.1-canary-4223a85-1626053020164":"2021-07-12T01:24:34.702Z","1.1.1-canary-9778786-1627751226724":"2021-07-31T17:08:15.850Z"},"bugs":{"url":"https://github.com/iadvize/opaque-type-library/issues"},"author":{"name":"iAdvize developers"},"license":"MIT","homepage":"https://github.com/iadvize/opaque-type-library#readme","keywords":["iAdvize"],"repository":{"url":"git+https://github.com/iadvize/opaque-type-library.git","type":"git"},"description":"Functional opaque type api for Typescript and Javascript","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":""}