{"name":"newtype-ts","version":"0.1.3-rc","description":"Implementation of newtypes in TypeScript","files":["lib"],"main":"lib/index.js","typings":"lib/index.d.ts","scripts":{"lint":"tslint src/**/*.ts test/**/*.ts","typings-checker":"typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts","mocha":"TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts","prettier":"prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"","fix-prettier":"prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test}/**/*.ts\"","test":"npm run prettier && npm run lint && npm run typings-checker && npm run mocha","clean":"rm -rf lib/*","build":"npm run clean && tsc"},"repository":{"type":"git","url":"git+https://github.com/gcanti/newtype-ts.git"},"author":{"name":"Giulio Canti","email":"giulio.canti@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/gcanti/newtype-ts/issues"},"homepage":"https://github.com/gcanti/newtype-ts","dependencies":{"fp-ts":"^1.0.0-rc","monocle-ts":"^0.5.3-rc"},"devDependencies":{"@types/benchmark":"^1.0.31","@types/mocha":"2.2.38","@types/node":"8.0.19","benchmark":"^2.1.4","mocha":"3.2.0","prettier":"1.9.2","ts-node":"3.3.0","tslint":"4.4.2","tslint-config-standard":"4.0.0","typescript":"2.6.2","typings-checker":"1.1.2"},"tags":["typescript","newtype","functional-programming"],"keywords":["typescript","newtype","functional-programming"],"readme":"# Usage\n\n```ts\nimport { Newtype, iso } from 'newtype-ts'\n\ninterface EUR extends Newtype<'EUR', number> {}\n\n// eurIso: Iso<EUR, number>\nconst eurIso = iso<EUR>()\n\n// eur: EUR\nconst eur = eurIso.wrap(2)\n\n// n: number\nexport const n = eurIso.unwrap(eur)\n\ndeclare function f(eur: EUR): void\n\nf(2) // Argument of type '2' is not assignable to parameter of type 'EUR'\nf(eur) // ok\n```\n\nFor the `Iso` type, see [monocle-ts](https://github.com/gcanti/monocle-ts) documentation.\n\n## Lift a function\n\n```ts\nconst double = (n: number): number => n * 2\n\n// doubleEUR: (s: EUR) => EUR\nconst doubleEUR = eurIso.modify(double)\n```\n\n## Operate over newtypes\n\n```ts\nimport { over } from 'newtype-ts'\n\ninterface USD extends Newtype<'USD', number> {}\n\nconst USDFromEUR = (n: number): number => n * 1.18\n\n// getter: Getter<EUR, USD>\nconst getter = over<EUR, USD>(USDFromEUR)\n\n// usd: USD\nconst usd = getter.get(eur)\n```\n\nFor the `Getter` type, see [monocle-ts](https://github.com/gcanti/monocle-ts) documentation.\n","readmeFilename":"README.md","gitHead":"3837eba38d96bfd427cf4c35a4315f8622a1b62d","_id":"newtype-ts@0.1.3-rc","_npmVersion":"5.5.1","_nodeVersion":"8.9.3","_npmUser":{"name":"gcanti","email":"giulio.canti@gmail.com"},"dist":{"integrity":"sha512-ijN5ifWjCoshQ2ZWXq5Ne9qjB//ymPEyZZuOIk5GhmEWW09YFu2eEqEVxXtcB3GrZ5f/tA/Vk6AneKGMbeMlzA==","shasum":"4c824531b2ecf3f84fba4f01d343a425924d1184","tarball":"http://registry-npm.ywwl.com/newtype-ts/download/newtype-ts-0.1.3-rc.tgz","fileCount":7,"unpackedSize":7567,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFjRZ2JB/dKNHZF/D+SWNCevg5O5vJtZGjEnnzRUY8vqAiEA3/izsfsA2wq5hZavXG+qEJMkiTKlmtWD3wGbWScNfgk="}],"size":3229,"noattachment":false,"key":"/newtype-ts/-/newtype-ts-0.1.3-rc.tgz"},"maintainers":[{"name":"gcanti","email":"giulio.canti@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/newtype-ts_0.1.3-rc_1518015442701_0.5856711687714566"},"_hasShrinkwrap":false,"publish_time":1518015443398,"_cnpm_publish_time":1518015443398,"dist-tags":{"latest":"0.3.5","next":"0.1.3-rc"}}