{"_id":"optics-ts","_rev":"21-6266a192fd257a311f4d0b3f5541689f","name":"optics-ts","dist-tags":{"latest":"2.4.1","next":"2.2.0-pre.0"},"versions":{"0.1.0":{"name":"optics-ts","version":"0.1.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","license":"MIT","main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents'"},"devDependencies":{"@babel/types":"^7.7.4","@types/jest":"^24.0.23","doctoc":"^1.4.0","jest":"^24.9.0","prettier":"^1.19.1","ts-jest":"^24.1.0","ts-node":"^8.5.2","typescript":"^3.7.2"},"_id":"optics-ts@0.1.0","dist":{"shasum":"392e17d8577ced0a8d0d5593e9c6ae43a9c9c33e","integrity":"sha512-wg0CYwMYZPPjnmEQqs+R6MKqqNyzsSxIkQ9ygDoY1jfR7v1tjL/9Z8AeQE6t33udIQDlfr3iirQ/Q7kJdK3V9g==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-0.1.0.tgz","fileCount":18,"unpackedSize":66615,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeF4OwCRA9TVsSAnZWagAAeMgP/RMsr8U3Rkw4iF8qo3Qu\nd6smBPxcOtGL6vP/uRlTIaTUDqFQOQMsCwlQgF4KzNRwFWGMFNagpPeNSbtu\neu1IpeAITycPBC4sM3vEJbVDHu5iaDcEyuiAr7KIM2vz7MgVjxzNBfQrUrI6\n4jDo6cZ9gRaAMjd8yncJs515fdPc8xikXg9gP49btfTFblaKDb3jnrISDVqu\nGHQtSdZxz3469FfS9jpWAMG8/9rjHxuTNGrCMJZXQjn+F5wQfWbBrr/R4S4p\npWhPIWUTNf1hUcGwvw2fjoeOK+UukYMfzHXFF/Y6yZ/Zt4NwZezfvEQmVaev\nbHL66aH+TvH/3ygonLhAeB7pv42JdjcEzCkFMn2dZmS2J2exzLefHksy114/\nleIMR5yNuIS01VyLcxVO9dYPyN8O0MyNLTpR+Dg4ZcKYVtqQuKZUKkP08fLy\n8QBZc757GD3ohiYpC+afpFVLuujeUkvumv+YqvgQp5jXYb7wRHoxwqwSKHig\nfiXQLk9geQaQixlseV/tlsN6k+a9gAiwKo1brTLsa+dJp38oz1L/yjJA4Iin\n863cHbx0p5R1zEqwYOpY0ksWc/QnrK91diiJ1CEw2KNifRWxX/WTcHNWjYcS\nsF3q6El1HeY/ncYDma/51xd0rV798r/dCfdgyj0WkOw7xrieFWiT9LNBHEVw\n6xRn\r\n=Sllp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCXNvR+/Sl5/PncZuAvSjvyZjIPu3HNJGVyoO0A8Hk12wIhAKXTOWA8Era5jK0Li9ZFcZmGTeg24Pps6bf+x5lnFgL6"}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_0.1.0_1578599343823_0.3371930014829423"},"_hasShrinkwrap":false},"1.0.0-rc1":{"name":"optics-ts","version":"1.0.0-rc1","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents'","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"readmeFilename":"README.md","readme":"# optics-ts\n\n[![CircleCI](https://circleci.com/gh/akheron/optics-ts.svg?style=shield)](https://circleci.com/gh/akheron/optics-ts)\n\n`optics-ts` provides type-safe, ergonomic, polymorphic optics for\nTypeScript:\n\n- **Optics** allow you to read or modify values from deeply nested\n  data structures, while keeping all data immutable.\n- **Ergonomic**: Optics are composed with method chaining, making it\n  easy and fun!\n- **Polymorphic**: When writing through the optics, you can change the\n  data types in the nested structure.\n- **Type-safe**: The compiler will type check all operations you do.\n  No `any`, ever.\n\n`optics-ts` supports equivalences, isomorphisms, lenses, prisms,\ntraversals, getters, affine folds and folds.\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Tutorial](#tutorial)\n  - [Lens](#lens)\n  - [Prism](#prism)\n  - [Traversal](#traversal)\n  - [Other types of optics](#other-types-of-optics)\n  - [Polymorphism](#polymorphism)\n- [API reference](#api-reference)\n  - [Types of optics](#types-of-optics)\n  - [Method chaining](#method-chaining)\n  - [Type parameters](#type-parameters)\n  - [Top-level functions](#top-level-functions)\n    - [`optic<S>(): Equivalence<S, _, S>`](#optics-equivalences-_-s)\n    - [`optic_<S>(): Equivalence<S, _, S>`](#optic_s-equivalences-_-s)\n    - [`get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`](#gets-aoptic-optics-_-a--source-s--a)\n    - [`preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`](#previews-aoptic-optics-_-a--source-s--a--undefined)\n    - [`collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`](#collects-aoptic-optics-_-a--source-s--a)\n    - [`modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`](#modifys-t-aoptic-optics-t-a--bf-a-a--b--source-s--tb)\n    - [`set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`](#sets-t-aoptic-optics-t-a--bvalue-b--source-s--tb)\n    - [`compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`](#composes-a1-a2optic1-optics-_-a1-optic2-optica1-_-a2-optics-_-a2)\n  - [Creating optics](#creating-optics)\n  - [Isomorphisms](#isomorphisms)\n    - [`iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`](#isouthere-a-a--u-back-u-u--a-isos-_-u)\n  - [Lenses](#lenses)\n    - [`prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`](#propk-extends-keyof-akey-k-lenss-_-ak)\n    - [`path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`](#pathk1-k2-keys-k1-k2--lenss-_-ak1k2)\n    - [`pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`](#pickk-extends-keyof-akeys-k-lenss-_-picka-k)\n  - [Prisms](#prisms)\n    - [`optional(): Prism<S, _, Exclude<A, undefined>>`](#optional-prisms-_-excludea-undefined)\n    - [`guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`](#guardu-extends-ag-a-a--a-is-u-prisms-_-u)\n    - [`guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`](#guard_f-extends-hkt-u-extends-ag-a-a--a-is-u--prisms-t-%C2%B7-f-u)\n    - [`index(i: number): Prism<S, _, ElemType<A>>`](#indexi-number-prisms-_-elemtypea)\n    - [`find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`](#findp-e-elemtypea--boolean-prisms-_-elemtypea)\n    - [`when(f: (a: A) => boolean): Prism<S, _, A>`](#whenf-a-a--boolean-prisms-_-a)\n  - [Traversals](#traversals)\n    - [`elems(): Traversal<S, _, ElemType<A>>`](#elems-traversals-_-elemtypea)\n  - [Getters](#getters)\n    - [`to<B>(f: (a: A) => B): Getter<S, B>`](#tobf-a-a--b-getters-b)\n  - [Composing](#composing)\n    - [`compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`](#composebother-optica-_-b-optics-_-b)\n- [Prior art](#prior-art)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Installation\n\n```\nnpm install --save optics-ts\n```\n\nor\n\n```\nyarn add optics-ts\n```\n\n## Tutorial\n\nThe following import is assumed in all the examples below:\n\n```typescript\nimport * as O from 'optics-ts'\n```\n\n### Lens\n\nLens is the most common optic you're going to use. You can create an\noptic for a data structure by calling `O.optic()`, and turn in into a\nlens that focuses on a property of an object with `.prop()`:\n\n```typescript\ntype Data = {\n  foo: { bar: number }\n  other: string\n}\nconst foo = O.optic<Data>().prop('foo')\n```\n\n`foo` is now a lens that focuses on `Data.foo`.\n\nTo dig deeper, just call `.prop()` again:\n\n```typescript\nconst bar = O.optic<Data>().prop('foo').prop('bar')\n// or from the `foo` lens we defined above\nconst bar = foo.prop('bar')\n// or use .path() to compose multiple prop lenses with a single call\nconst bar = O.optic<Data>().path(['foo', 'bar'])\n```\n\nUse `get()` to read a value through the lens:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 42 },\n  other: 'stuff',\n}\n\nO.get(lens)(data)\n// => 42\n```\n\nUse `set()` or `modify()` to write the focused value through the lens:\n\n```typescript\nO.set(lens)(99)(data)\n// => {\n//   foo: { bar: 99 },\n//   other: 'stuff'\n// }\n\nO.modify(lens)(x => x * 100)(data)\n// => {\n//   foo: { bar: 4200 },\n//   other: 'stuff'\n// }\n```\n\nWriting through optics always creates a new data structure instead of\nmodifying the existing one. In other words, data is immutable.\n\n### Prism\n\nLenses are great for focusing to a part of a larger structure. Prisms\nare much like lenses, but they don't necessarily match anything, i.e.\nthey can have zero focuses.\n\nA practical example is focusing on a branch of a union type. Here, the\n`User.age` field can be `number` or `undefined`. With the `.optional()`\nprism we can focus only when the value is a `number`, and do nothing\nwhen it's `undefined`:\n\n```typescript\ntype User = {\n  name: string\n  age?: number | undefined\n}\n\nconst age = O.optic<User>().prop('age').optional()\n```\n\nYou read through a prism using the `preview()` function. When the prism\ndoesn't match, it returns `undefined`.\n\n```typescript\nconst userWithAge: User = {\n  name: 'Betty',\n  age: 42,\n}\nO.preview(age)(userWithAge)\n// ==> 42\n\nconst userWithoutAge: User = {\n  name: 'Max',\n  age: undefined,\n}\nO.preview(age)(userWithoutAge)\n// ==> undefined\n```\n\nIf the prism doesn't match, `preview()` returns undefined, as seen above.\n\nYou can write through a prism normally with `set()` and `modify()`. If\nthe prism doesn't match, the value is unchanged:\n\n```typescript\nO.modify(age)(n => n + 1)(userWithAge)\n// ==> {\n//   name: 'Betty',\n//   age: 43,\n// }\n\nO.set(age)(60)(userWithoutAge)\n// ==> {\n//   name: 'Max',\n//   age: undefined,\n// }\n```\n\n`.guard()` is another method that creates a prism. It's a generalization\nof `.optional()` in the sense that you can match on any branch of a\nunion type instead of just the non-`undefined` part:\n\n```typescript\ninterface Square {\n  kind: 'square'\n  size: number\n}\ninterface Rectangle {\n  kind: 'rectangle'\n  width: number\n  height: number\n}\ntype Shape = Square | Rectangle\n\nfunction isRectangle(s: Shape): s is Rectangle {\n  return s.kind === 'rectangle'\n}\n\nconst rectWidth = O.optic<Shape>().guard(isRectangle).prop('width')\n\nO.preview(rectWidth)({ kind: 'square', size: 10 })\n// ==> undefined\n\nO.preview(rectWidth)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> 5\n\nO.modify(rectWidth)(w => w * 2)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> { kind: 'rectangle', width: 10, height: 7 })\n```\n\nNotice how above we used `.guard(...).prop(...)`, composing a prism with\na lens. This yields a prism, so we used `preview()` to read through it.\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Traversal\n\nThe next optic type is the traversal. While lenses have 1 focus and\nprisms have 0 or 1 focus (no match or match), traversals have 0 or\nmore focuses.\n\nThe simplest example of a traversal is to focus on the elements of an\narray. To create such a traversal, use `.elems()`:\n\n```typescript\ntype Person {\n  name: string\n  friends: Person[]\n}\n\nconst friendsNames = O.optic<Person>()\n  .prop('friends')\n  .elems()\n  .prop('name')\n```\n\nTo read through a traversal, call `collect()` to collect all focused\nelements into an array:\n\n```typescript\nconst john = { name: 'John', friends: [] }\nconst bruce = { name: 'Bruce', friends: [] }\nconst amy = { name: 'Amy', friends: [john, bruce] }\n\nO.collect(friendsNames)(amy)\n// ==> [ 'John', 'Bruce' ]\n```\n\nWriting through a traversal writes to all focused values:\n\n```typescript\nO.modify(friendsNames)(name => `${name} Wayne`)(amy)\n// ==> {\n//   name: 'Amy',\n//   friends: [\n//     { name: 'John Wayne', friends: [] },\n//     { name: 'Bruce Wayne', friends: [] },\n//   ],\n// }\n```\n\nNote again how we used `.prop(...).elems(...).prop(...)`, composing a\nlens with a traversal, and then with a lens again. This yields a\ntraversal. See [Types of optics](#types-of-optics) for more info.\n\nIt's sometimes useful to further focus on certain elements of a\ntraversal. This can be done by composing a traversal with a prism like\n`.when()` that skips items that don't match a predicate:\n\n```typescript\nconst even = O.optic<number[]>()\n  .elems()\n  .when(n => n % 2 === 0)\n\nO.modify(even)(n => -n)([1, 2, 3, 4, 5])\n// ==> [1, -2, 3, -4, 5]\n```\n\n### Other types of optics\n\nIn fact, calling `O.optic()` also yields an optic, but instead of\nbeing a lens, prism or traversal, it's an equivalence. As the name\nsuggests, equivalence keeps the value equal, in both reading and\nwriting directions:\n\n```typescript\nconst str = O.optic<string>()\n\nO.get(str)('original')\n// ==> 'original'\n\nO.set(str)('new')('original')\n// ==> 'new' ('original' is discarded)\n```\n\nSupported optic types also include _isomorphism_, which can be used to\ndo 2-way data transformations. Furthermore, there are read-only optics\nanaloguous to isomorphism, prism, and traversal. While isomorphism is\n2-way transformation (a mapping function and its inverse), _getter_ is a\none-way transformation (just a mapping function). _Affine fold_ and\n_fold_ are read-only variants of prism and traversal.\n\n### Polymorphism\n\nOptics can be polymorphic, which means you can change the type of the\nfocus when you write through an optic. Since this is a relatively rare\nuse case, and may be confusing if done by accident, polymorphic optics\nare created with `optic_()` (note the underscore):\n\n```typescript\ntype Data = {\n  foo: { bar: string }\n  other: boolean\n}\nconst bar = O.optic_<Data>().path(['foo', 'bar'])\n```\n\nLet's modify `bar` to contain the length of the original string instead:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 'hello there' },\n  other: true,\n}\n\nconst updated = O.modify(bar)(str => str.length)(data)\n// ==> {\n//   foo: { bar: 11 },\n//   other: true\n// }\n```\n\nThis is a type-safe operation, i.e. the compiler knows that the type of\n`updated.foo.bar` is `number`, editor autocomplete works correctly, etc.\n\nIf you ever see a `DisallowedTypeChange` type being returned from an\n`optics-ts` function, it means that you tried to change the type when\nwriting through a non-polymorphic (monomorphic) optic.\n\n## API reference\n\n### Types of optics\n\nThe supported optic classes are Equivalence, Iso (isomorphism), Lens,\nPrism, Traversal, Getter, AffineFold and Fold.\n\nEquivalence, Iso, Lens, Prism and Traversal are read-write, i.e. you can\nread and write through them. Getter, AffineFold and Fold are read-only.\n\nEquivalence, Iso, Lens and Getter have one focus, i.e. you can\nalways read and write through them (Getter doesn't support writing).\nPrism and AffineFold have zero or one focus, i.e. reading may yield no\nvalue and writing may have no effect if there's no focus. Traversal and\nFold have zero or more focuses, meaning that reading yields zero or more\nvalues, and writing modifies zero or more values.\n\nAny optic can be composed with another optic. The type of the resulting\noptic can be determined from this diagram:\n\n```\nEquivalence -> Iso -> Lens ---> Prism ------> Traversal\n                      |         |             |\n                      v         v             v\n                      Getter -> AffineFold -> Fold\n```\n\nWhen you compose two optics A and B, the result is the nearest optic\nthat you get by following the arrows starting from both A and B.\n\nFor example, composing a Getter with a Traversal yields a Fold.\nComposing an Iso with a Prism yields a Prism.\n\nThe naming of the optic classes is taken from\n[Glassery](http://oleg.fi/gists/posts/2017-04-18-glassery.html) by Oleg\nGrenrus.\n\n### Method chaining\n\nOptics are composed with method chaining. This means that each optic\ntype has all the methods documented below, regardless of the type of the\noptic that the method creates. The only difference is the return type,\nwhich is determined by the composition rules above.\n\nFor example, assume we have a variable `myLens` that holds a `Lens`, and\ncall `.optional()` on it:\n\n```typescript\nconst newOptic = myLens.optional()\n```\n\n`.optional()` creates a prism, so `newOptic` will be a composition of\nlens and prism, i.e. a prism.\n\n### Type parameters\n\nAll read-write optics have 3 type parameters: `<S, T, A>`, and all\nread-only optics have 2 type parameters: `<S, A>`:\n\n- `S` is the source on which the optic operates\n\n- `A` is the type of the focus or focuses\n\n- `T` is a \"higher-kinded type\" or a \"partially applied type operator\"\n  that yields the output type when applied to some type `B`.\n\nConceptually, when you write a value of type `B`, the output type will\nbe `S` with `A` replaced by `B` at the focus(es) of the optic. `T` is\nthe mechanism that transforms `B` to the output type. This construct\nmakes it possible for the optics to be polymorphic on the type level.\nThe read-only optics don't need `T` because you cannot write through\nthem.\n\nIn the following, we leave the exact definition of `T` for each optic\nout for clarity, writing just `_` in its place. It's usually clear fom\nhow the optic works what will come out if you put a different type in.\n\nIn the documentation of functions that can be used to write through an\noptic, the return type is denoted by `T<B>`. While not valid TypeScript\nsyntax (because `T` is a type parameter instead of a concrete type),\nthis captures the meaning quite well: `B` is applied to the\nhigher-kinded type `T`, yielding the output type.\n\nInterested readers can refer to [hkt.ts](src/hkt.ts) to see how the\nhigher-kinded types / partially applied type operators are actually\nimplemented.\n\n### Top-level functions\n\nThese functions are available as top level exports of the `optics-ts`\nmodule.\n\nMost functions have `Optic` in their signature. It means that multiple\noptics work with the function. The optic classes that are actually\napplicable are documented in the function description.\n\n#### `optic<S>(): Equivalence<S, _, S>`\n\nCreate a monomorphic equivalence for `S`. If you ever see the type\n`DisallowedTypeChange`, it means that you have attempted to change a\ntype with a monomorphic optic.\n\n#### `optic_<S>(): Equivalence<S, _, S>`\n\nCreate a polymorphic equivalence for `S`.\n\n#### `get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`\n\nRead a value through an `Equivalence`, `Iso`, `Lens` or `Getter`.\n\n#### `preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`\n\nRead a value through a `Prism`, `Traversal`, `AffineFold` or `Fold`. For\n`Prism` and `AffineFold`, return `undefined` if the optic doesn't match\n(has zero focuses). For `Traversal` and `Fold`, returns the value of the\nfirst focus, or `undefined` if there are no focuses.\n\n#### `collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`\n\nRead all focused values through a `Prism`, `Traversal`, `AffineFold` or\n`Fold`. For `Prism` and `AffineFold`, the return value is an array of 0\nor 1 elements. For `Traversal` and `Fold`, the return value is an array\nof zero or more elements.\n\n#### `modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`\n\nModify the focused value(s) through an `Equivalence`, `Iso`, `Lens`,\n`Prism` or `Traversal`. Returns an updated copy of `source` with all\nfocuses modified by mapping them through the function `f`.\n\n#### `set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`\n\nWrite a constant value through an `Equivalence`, `Iso`, `Lens`, `Prism`\nor `Traversal`. Returns an updated copy of `source` with all focuses\nreplaced by `value`.\n\n#### `compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`\n\nCompose two optics. If the first optic is from `S` to `A1`, and the\nsecond optic is from `A1` to `A2`, the result is from `S` to `A2`.\n\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Creating optics\n\nThe methods documented below are available on all optics types:\n`Equivalence`, `Iso`, `Lens`, `Prism`, `Traversal`, `Getter`,\n`AffineFold` and `Fold`. The documented return type is the type of the\noptic that these methods create. The actual return type is the\ncomposition of the optic on which the method is called and on the optic\nthat the method creates.\n\nNote that there are no functions to create `AffineFold` or `Fold`\noptics. You can only get these by composing other types of optics.\n`Equivalence` can be created by calling the top-level `optic()`\nfunction.\n\n### Isomorphisms\n\nIsomorphisms have the type `Iso<S, T, A>`. In the following, we omit\nthe exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`\n\nCreate an isomorphism from functions `there` and `back`. `there` takes\nthe focus and transforms it to another value. `back` is the inverse of\n`there`.\n\nNote that `iso` is monomorphic. There's no polymorphic alternative\n(yet).\n\n### Lenses\n\nLenses have the type `Lens<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`\n\nCreate a lens that focuses on the property `K` of `A`.\n\n**Note:** `prop()` only works for string properties, even though\nTypeScript's type system also allows array's numeric indices when using\n`keyof`. Use the `index()` prism to focus on an array element at a given\nindex.\n\n#### `path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`\n\nA shortcut for focusing on chain of properties.\n\n```typescript\nfoo.path(['a', 'b', 'c'])\n```\n\nis equal to\n\n```typescript\nfoo.prop('a').prop('b').prop('c')\n```\n\n#### `pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`\n\nCreate a lens that focuses on a sub-object of `A` with the given\nproperties. When writing through a polymorphic `.pick()` lens, you can\nadd or remove properties.\n\nExample:\n\n```typescript\nconst data = {\n  foo: 'something',\n  bar: 42,\n  baz: true,\n}\nconst lens = O.optic_<typeof data>().pick(['foo', 'bar'])\n\nO.get(lens)(data)\n// ==> {\n//  foo: 'something',\n//  baz: true,\n// }\n\nO.set(lens)({ quux: null })(data)\n// ==> {\n//   quux: null,\n//   baz: true,\n// }\n\n// monomorphic version of the same lens\nconst monoLens = O.optic<typeof data>().compose(lens)\n\nO.set(monoLens)({ quux: null })(data)\n// ==> DisallowedTypeChange\n```\n\n### Prisms\n\nPrisms have the type `Prism<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `optional(): Prism<S, _, Exclude<A, undefined>>`\n\nCreate a prism that focuses on the non-`undefined` subtype of `A`.\n\n#### `guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`\n\nCreate a prism that focuses on the subtype `U` of `A` that matches the\ntype guard `g`.\n\nNote that `guard()` is monomorphic. Use `guard_` if you want a\npolymorphic guard.\n\n#### `guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`\n\nCreate a prism that focuses on the subtype of `A` that matches the type\nguard `g`. When written to, uses the higher-kinded type `F` to construct\nthe output type.\n\n#### `index(i: number): Prism<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nCreate a prism that focuses on index `i` of the focus array.\n\nWhen a different type `B` is written through this optic, the resulting\narray will have the type `Array<A | B>`.\n\n#### `find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nLike `.index()`, but the index to be focused on is determined by\nfinding the first element that matches the given predicate.\n\nWhen a different type `B` is written through this optic, the resulting\narray will have the type `Array<A | B>`.\n\n#### `when(f: (a: A) => boolean): Prism<S, _, A>`\n\nCreate a prism that skips the focus if it doesn't match the given\npredicate. Especially useful for filtering the focuses of a travesal.\n\nWhen a different type `B` is written through this optic, the resulting\nvalue will have the type `A | B`.\n\n### Traversals\n\nTraversals have the type `Traversal<S, T, A>`. In the following, we\nomit the exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `elems(): Traversal<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nCreate a traversal that focuses on all the elements of the array.\n\n### Getters\n\nGetters have the type `Getter<S, A>`.\n\n#### `to<B>(f: (a: A) => B): Getter<S, B>`\n\nCreate a getter that applies the function `f` to its focus.\n\n### Composing\n\n#### `compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`\n\n`optic.compose(other)` is equivalent to `compose(optic, other)`.\n\n## Prior art\n\nThere are many existing optics libraries of varying degree for\nJavaScript, but only few for TypeScript. It's generally hard to create\ngood typings for optics in TypeScript, and the task becomes impossible\nif one tried to retrofit types on an existing JavaScript implementation.\n\n[monocle-ts](https://github.com/gcanti/monocle-ts) is probably the most\npopular TypeScript optics library. It lacks polymorphism, and creating\noptics is verbose and cumbersome. You first create optics for each level\nof the data structure, and then compose them with separate function\ncalls. This also often requires you to declare many unnecessary\nintermediate types for your data.\n\n[@grammarly/focal](https://github.com/grammarly/focal) is not an optics\nlibrary per se, rather an UI framework. Its optics are very limited.\n","licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.0.0-rc1","dist":{"shasum":"eea205eb5dc3256cedbe549613e942a71b0bb8cb","integrity":"sha512-bP9UFCaftqTxOtvtWwrNxzzRara4NTNzsXiGvLNZyrXnTGKU7cgJtSutG+L5bdLFE/LXKZODY2Kg8z9YW1NfKQ==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.0.0-rc1.tgz","fileCount":20,"unpackedSize":85310,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJemoUWCRA9TVsSAnZWagAAabYP/0e53jhAGtkG0fRqVaOj\n2KwlqUiYl6GHUZtNWheDv8UC1guKlCPAM8KQc9301vHr8TVsJvcH1H8jmrM2\nklm0Cja6P0rrd6TKWmdh3WusQmxhIXAqsZQRZEZbxBJ2YSg44T7/xcKxHyMW\nLzOlzBpd1h1xxSRang4Cf4FLID5cQ2RcDE8Tb94X4HPtdIcLSmPdSqRxuJ/c\n/JpF917/ct2pztVZHePJDgExgXRxuF1eUttCa/tf1daHwIuJ116lVtrigF3M\n4p2x9x0NFf8rItG9wvH7/cIgk7bO2Ua6k5duYVutqOsGM0c/d0A5lV2JPIiK\nnl3KHXN8Jx/C61hvhXVZXuZWFCIIy6u4tisAD9VGXxnex9VElSFxOAc7QVB0\nd3qqKL1AeS2umrjvKUP9YalALy61WSREVP42VyLrLUNgJWUo6gcBV3DMkBr2\nzjGG15j9l3WQdKJ/NEpKzyLmR2tE5BBrRXxPqINtVZO9XeNtybAbEofkne28\nIMcwCl++sjLo6SwZ7DEXOhCaKe+fefsItumWlhhXDXZ6KcVv7av2BDmwiqmp\nvL8QPqgLp9Y2xlifGwFSl4E/7H2cdd2KSssSC2SnbPoL6ghRep0mXtdhJWHt\nkI6vDb8S5JrdzctFPmxzvpn6OcD7cLJftyDKzKRdVTnByDYQA3GFA5R3iU2c\n3cfj\r\n=+TCw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAiokqUOTxjbzO52HfCys0duniLFCma3LLiyL9/FT07QAiBA4i36YJerO+YdqAc7j/qyWiWpLFFRbqGtHbpXaSN+DA=="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.0.0-rc1_1587184917945_0.9693073399882783"},"_hasShrinkwrap":false},"1.0.0":{"name":"optics-ts","version":"1.0.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents'","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.0.0","dist":{"shasum":"88cb2d493721b05025e7460dd96f20b974ae095d","integrity":"sha512-YuV7TQqV1Ojy/s60Yxl7AJbUSLZHO8AMF7xXV1zYSknvQtdP/qEcqaiAo26VPNorvgKKBzOPnjSq9zlHEow6MA==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.0.0.tgz","fileCount":20,"unpackedSize":98815,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeodS5CRA9TVsSAnZWagAAx/kP/A5dGYwjPnmgOfy9S71U\nnVo9DGkwk1rrNdGqafPfLYoDokk8AhKcrBs+Ny2VWaf2zvFMQndPrjDZCAYA\nYG1N7EgUiYsTxEEXw0NMAxlrs8RgWachXkMJfGbBoy69VUgR6LVHZKfbgQc2\nST479rExSOsUfvF6qKSf9EKFu9FbNGINuiQeGYgbUi+osktfTrlBx5Fy9A+Z\njMxDgrI3K8CUvgAegGnsQ8I39k+DZnCAS1weRZ+JbwDya7KW+fmhDzpFIObr\nL4PhlRm/E9qoM61XE7yf4E/1k1vlr8c5ZsBoGqAHVtPbEan6NMXI7z/IP/al\n5czcEjpbNtB7vfi7f3QnH6JTA7FPXglAi0rY61x3qwfXA2swudg6VfSxcBVH\nYvPi8DrQv/MSlQP7beWJgkn1AIrwazovnApZy7OcvrDJvInCl4BstbtABw2v\nmcuVbde/I1wAo7CAhys72r47wWHzcwGRMEpfj1HqwhzHcn3RUl0k713Zz/pk\nBPA0VhhdLbtAlHn96ARPBTuEPQIaonKSC9K3Sxoj/FhlzqRQv6/hc+DnmlXE\nw98q70tNE4GzT3o8gEOSYZPAbHz4ZGIrMQ1q0kPSw5E3im9SLYkrThBYAx5u\nl5ofjWQQmgwQ9+ZtFejRQsbN1rwzlRcEILZPdCfXiFcXLIT4JCLxhrvzy+EQ\nB5aK\r\n=zFfF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSWifquEax9m2Smng0J2QgGNiwnFhI5DxEQ0RPNm7mDAIhAJaySVOSP8Su+MQlTFeotOc1q+7eFKKTHMsAZBzvrzoZ"}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.0.0_1587664057169_0.10214929450355181"},"_hasShrinkwrap":false},"1.1.0-pre.1":{"name":"optics-ts","version":"1.1.0-pre.1","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"readmeFilename":"README.md","readme":"# optics-ts\n\n[![CircleCI](https://circleci.com/gh/akheron/optics-ts.svg?style=shield)](https://circleci.com/gh/akheron/optics-ts)\n\n`optics-ts` provides type-safe, ergonomic, polymorphic optics for\nTypeScript:\n\n- **Optics** allow you to read or modify values from deeply nested\n  data structures, while keeping all data immutable.\n- **Ergonomic**: Optics are composed with method chaining, making it\n  easy and fun!\n- **Polymorphic**: When writing through the optics, you can change the\n  data types in the nested structure.\n- **Type-safe**: The compiler will type check all operations you do.\n  No `any`, ever.\n\n`optics-ts` supports equivalences, isomorphisms, lenses, prisms,\ntraversals, getters, affine folds and folds.\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Tutorial](#tutorial)\n  - [Lens](#lens)\n  - [Prism](#prism)\n  - [Traversal](#traversal)\n  - [Other types of optics](#other-types-of-optics)\n  - [Polymorphism](#polymorphism)\n- [API reference](#api-reference)\n  - [Types of optics](#types-of-optics)\n  - [Method chaining](#method-chaining)\n  - [Type parameters](#type-parameters)\n  - [Top-level functions](#top-level-functions)\n    - [`optic<S>(): Equivalence<S, _, S>`](#optics-equivalences-_-s)\n    - [`optic_<S>(): Equivalence<S, _, S>`](#optic_s-equivalences-_-s)\n    - [`get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`](#gets-aoptic-optics-_-a--source-s--a)\n    - [`preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`](#previews-aoptic-optics-_-a--source-s--a--undefined)\n    - [`collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`](#collects-aoptic-optics-_-a--source-s--a)\n    - [`modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`](#modifys-t-aoptic-optics-t-a--bf-a-a--b--source-s--tb)\n    - [`set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`](#sets-t-aoptic-optics-t-a--bvalue-b--source-s--tb)\n    - [`compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`](#composes-a1-a2optic1-optics-_-a1-optic2-optica1-_-a2-optics-_-a2)\n  - [Creating optics](#creating-optics)\n  - [Isomorphisms](#isomorphisms)\n    - [`iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`](#isouthere-a-a--u-back-u-u--a-isos-_-u)\n  - [Lenses](#lenses)\n    - [`prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`](#propk-extends-keyof-akey-k-lenss-_-ak)\n    - [`path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`](#pathk1-k2-keys-k1-k2--lenss-_-ak1k2)\n    - [`pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`](#pickk-extends-keyof-akeys-k-lenss-_-picka-k)\n  - [Prisms](#prisms)\n    - [`optional(): Prism<S, _, Exclude<A, undefined>>`](#optional-prisms-_-excludea-undefined)\n    - [`guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`](#guardu-extends-ag-a-a--a-is-u-prisms-_-u)\n    - [`guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`](#guard_f-extends-hkt-u-extends-ag-a-a--a-is-u--prisms-t-%C2%B7-f-u)\n    - [`index(i: number): Prism<S, _, ElemType<A>>`](#indexi-number-prisms-_-elemtypea)\n    - [`head(): Prism<S, _, ElemType<A>>`](#head-prisms-_-elemtypea)\n    - [`find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`](#findp-e-elemtypea--boolean-prisms-_-elemtypea)\n    - [`when(f: (a: A) => boolean): Prism<S, _, A>`](#whenf-a-a--boolean-prisms-_-a)\n  - [Traversals](#traversals)\n    - [`elems(): Traversal<S, _, ElemType<A>>`](#elems-traversals-_-elemtypea)\n  - [Getters](#getters)\n    - [`to<B>(f: (a: A) => B): Getter<S, B>`](#tobf-a-a--b-getters-b)\n  - [Composing](#composing)\n    - [`compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`](#composebother-optica-_-b-optics-_-b)\n  - [Strings](#strings)\n    - [`chars(): Traversal<S, _, string>`](#chars-traversals-_-string)\n    - [`words(): Traversal<S, _, string>`](#words-traversals-_-string)\n- [Prior art](#prior-art)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Installation\n\n```\nnpm install --save optics-ts\n```\n\nor\n\n```\nyarn add optics-ts\n```\n\n## Tutorial\n\nThe following import is assumed in all the examples below:\n\n```typescript\nimport * as O from 'optics-ts'\n```\n\n### Lens\n\nLens is the most common optic you're going to use. You can create an\noptic for a data structure by calling `O.optic()`, and turn in into a\nlens that focuses on a property of an object with `.prop()`:\n\n```typescript\ntype Data = {\n  foo: { bar: number }\n  other: string\n}\nconst foo = O.optic<Data>().prop('foo')\n```\n\n`foo` is now a lens that focuses on `Data.foo`.\n\nTo dig deeper, just call `.prop()` again:\n\n```typescript\nconst bar = O.optic<Data>().prop('foo').prop('bar')\n// or from the `foo` lens we defined above\nconst bar = foo.prop('bar')\n// or use .path() to compose multiple prop lenses with a single call\nconst bar = O.optic<Data>().path(['foo', 'bar'])\n```\n\nUse `get()` to read a value through the lens:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 42 },\n  other: 'stuff',\n}\n\nO.get(lens)(data)\n// => 42\n```\n\nUse `set()` or `modify()` to write the focused value through the lens:\n\n```typescript\nO.set(lens)(99)(data)\n// => {\n//   foo: { bar: 99 },\n//   other: 'stuff'\n// }\n\nO.modify(lens)(x => x * 100)(data)\n// => {\n//   foo: { bar: 4200 },\n//   other: 'stuff'\n// }\n```\n\nWriting through optics always creates a new data structure instead of\nmodifying the existing one. In other words, data is immutable.\n\n### Prism\n\nLenses are great for focusing to a part of a larger structure. Prisms\nare much like lenses, but they don't necessarily match anything, i.e.\nthey can have zero focuses.\n\nA practical example is focusing on a branch of a union type. Here, the\n`User.age` field can be `number` or `undefined`. With the `.optional()`\nprism we can focus only when the value is a `number`, and do nothing\nwhen it's `undefined`:\n\n```typescript\ntype User = {\n  name: string\n  age?: number | undefined\n}\n\nconst age = O.optic<User>().prop('age').optional()\n```\n\nYou read through a prism using the `preview()` function. When the prism\ndoesn't match, it returns `undefined`.\n\n```typescript\nconst userWithAge: User = {\n  name: 'Betty',\n  age: 42,\n}\nO.preview(age)(userWithAge)\n// ==> 42\n\nconst userWithoutAge: User = {\n  name: 'Max',\n  age: undefined,\n}\nO.preview(age)(userWithoutAge)\n// ==> undefined\n```\n\nIf the prism doesn't match, `preview()` returns undefined, as seen above.\n\nYou can write through a prism normally with `set()` and `modify()`. If\nthe prism doesn't match, the value is unchanged:\n\n```typescript\nO.modify(age)(n => n + 1)(userWithAge)\n// ==> {\n//   name: 'Betty',\n//   age: 43,\n// }\n\nO.set(age)(60)(userWithoutAge)\n// ==> {\n//   name: 'Max',\n//   age: undefined,\n// }\n```\n\n`.guard()` is another method that creates a prism. It's a generalization\nof `.optional()` in the sense that you can match on any branch of a\nunion type instead of just the non-`undefined` part:\n\n```typescript\ninterface Square {\n  kind: 'square'\n  size: number\n}\ninterface Rectangle {\n  kind: 'rectangle'\n  width: number\n  height: number\n}\ntype Shape = Square | Rectangle\n\nfunction isRectangle(s: Shape): s is Rectangle {\n  return s.kind === 'rectangle'\n}\n\nconst rectWidth = O.optic<Shape>().guard(isRectangle).prop('width')\n\nO.preview(rectWidth)({ kind: 'square', size: 10 })\n// ==> undefined\n\nO.preview(rectWidth)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> 5\n\nO.modify(rectWidth)(w => w * 2)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> { kind: 'rectangle', width: 10, height: 7 })\n```\n\nNotice how above we used `.guard(...).prop(...)`, composing a prism with\na lens. This yields a prism, so we used `preview()` to read through it.\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Traversal\n\nThe next optic type is the traversal. While lenses have 1 focus and\nprisms have 0 or 1 focus (no match or match), traversals have 0 or\nmore focuses.\n\nThe simplest example of a traversal is to focus on the elements of an\narray. To create such a traversal, use `.elems()`:\n\n```typescript\ntype Person {\n  name: string\n  friends: Person[]\n}\n\nconst friendsNames = O.optic<Person>()\n  .prop('friends')\n  .elems()\n  .prop('name')\n```\n\nTo read through a traversal, call `collect()` to collect all focused\nelements into an array:\n\n```typescript\nconst john = { name: 'John', friends: [] }\nconst bruce = { name: 'Bruce', friends: [] }\nconst amy = { name: 'Amy', friends: [john, bruce] }\n\nO.collect(friendsNames)(amy)\n// ==> [ 'John', 'Bruce' ]\n```\n\nWriting through a traversal writes to all focused values:\n\n```typescript\nO.modify(friendsNames)(name => `${name} Wayne`)(amy)\n// ==> {\n//   name: 'Amy',\n//   friends: [\n//     { name: 'John Wayne', friends: [] },\n//     { name: 'Bruce Wayne', friends: [] },\n//   ],\n// }\n```\n\nNote again how we used `.prop(...).elems(...).prop(...)`, composing a\nlens with a traversal, and then with a lens again. This yields a\ntraversal. See [Types of optics](#types-of-optics) for more info.\n\nIt's sometimes useful to further focus on certain elements of a\ntraversal. This can be done by composing a traversal with a prism like\n`.when()` that skips items that don't match a predicate:\n\n```typescript\nconst even = O.optic<number[]>()\n  .elems()\n  .when(n => n % 2 === 0)\n\nO.modify(even)(n => -n)([1, 2, 3, 4, 5])\n// ==> [1, -2, 3, -4, 5]\n```\n\n### Other types of optics\n\nIn fact, calling `O.optic()` also yields an optic, but instead of\nbeing a lens, prism or traversal, it's an equivalence. As the name\nsuggests, equivalence keeps the value equal, in both reading and\nwriting directions:\n\n```typescript\nconst str = O.optic<string>()\n\nO.get(str)('original')\n// ==> 'original'\n\nO.set(str)('new')('original')\n// ==> 'new' ('original' is discarded)\n```\n\nSupported optic types also include _isomorphism_, which can be used to\ndo 2-way data transformations. Furthermore, there are read-only optics\nanaloguous to isomorphism, prism, and traversal. While isomorphism is\n2-way transformation (a mapping function and its inverse), _getter_ is a\none-way transformation (just a mapping function). _Affine fold_ and\n_fold_ are read-only variants of prism and traversal.\n\n### Polymorphism\n\nOptics can be polymorphic, which means you can change the type of the\nfocus when you write through an optic. Since this is a relatively rare\nuse case, and may be confusing if done by accident, polymorphic optics\nare created with `optic_()` (note the underscore):\n\n```typescript\ntype Data = {\n  foo: { bar: string }\n  other: boolean\n}\nconst bar = O.optic_<Data>().path(['foo', 'bar'])\n```\n\nLet's modify `bar` to contain the length of the original string instead:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 'hello there' },\n  other: true,\n}\n\nconst updated = O.modify(bar)(str => str.length)(data)\n// ==> {\n//   foo: { bar: 11 },\n//   other: true\n// }\n```\n\nThis is a type-safe operation, i.e. the compiler knows that the type of\n`updated.foo.bar` is `number`, editor autocomplete works correctly, etc.\n\nIf you ever see a `DisallowedTypeChange` type being returned from an\n`optics-ts` function, it means that you tried to change the type when\nwriting through a non-polymorphic (monomorphic) optic.\n\n## API reference\n\n### Types of optics\n\nThe supported optic classes are Equivalence, Iso (isomorphism), Lens,\nPrism, Traversal, Getter, AffineFold and Fold.\n\nEquivalence, Iso, Lens, Prism and Traversal are read-write, i.e. you can\nread and write through them. Getter, AffineFold and Fold are read-only.\n\nEquivalence, Iso, Lens and Getter have one focus, i.e. you can\nalways read and write through them (Getter doesn't support writing).\nPrism and AffineFold have zero or one focus, i.e. reading may yield no\nvalue and writing may have no effect if there's no focus. Traversal and\nFold have zero or more focuses, meaning that reading yields zero or more\nvalues, and writing modifies zero or more values.\n\nAny optic can be composed with another optic. The type of the resulting\noptic can be determined from this diagram:\n\n```\nEquivalence -> Iso -> Lens ---> Prism ------> Traversal\n                      |         |             |\n                      v         v             v\n                      Getter -> AffineFold -> Fold\n```\n\nWhen you compose two optics A and B, the result is the nearest optic\nthat you get by following the arrows starting from both A and B.\n\nFor example, composing a Getter with a Traversal yields a Fold.\nComposing an Iso with a Prism yields a Prism.\n\nThe naming of the optic classes is taken from\n[Glassery](http://oleg.fi/gists/posts/2017-04-18-glassery.html) by Oleg\nGrenrus.\n\n### Method chaining\n\nOptics are composed with method chaining. This means that each optic\ntype has all the methods documented below, regardless of the type of the\noptic that the method creates. The only difference is the return type,\nwhich is determined by the composition rules above.\n\nFor example, assume we have a variable `myLens` that holds a `Lens`, and\ncall `.optional()` on it:\n\n```typescript\nconst newOptic = myLens.optional()\n```\n\n`.optional()` creates a prism, so `newOptic` will be a composition of\nlens and prism, i.e. a prism.\n\n### Type parameters\n\nAll read-write optics have 3 type parameters: `<S, T, A>`, and all\nread-only optics have 2 type parameters: `<S, A>`:\n\n- `S` is the source on which the optic operates\n\n- `A` is the type of the focus or focuses\n\n- `T` is a \"higher-kinded type\" or a \"partially applied type operator\"\n  that yields the output type when applied to some type `B`.\n\nConceptually, when you write a value of type `B`, the output type will\nbe `S` with `A` replaced by `B` at the focus(es) of the optic. `T` is\nthe mechanism that transforms `B` to the output type. This construct\nmakes it possible for the optics to be polymorphic on the type level.\nThe read-only optics don't need `T` because you cannot write through\nthem.\n\nIn the following, we leave the exact definition of `T` for each optic\nout for clarity, writing just `_` in its place. It's usually clear fom\nhow the optic works what will come out if you put a different type in.\n\nIn the documentation of functions that can be used to write through an\noptic, the return type is denoted by `T<B>`. While not valid TypeScript\nsyntax (because `T` is a type parameter instead of a concrete type),\nthis captures the meaning quite well: `B` is applied to the\nhigher-kinded type `T`, yielding the output type.\n\nInterested readers can refer to [hkt.ts](src/hkt.ts) to see how the\nhigher-kinded types / partially applied type operators are actually\nimplemented.\n\n### Top-level functions\n\nThese functions are available as top level exports of the `optics-ts`\nmodule.\n\nMost functions have `Optic` in their signature. It means that multiple\noptics work with the function. The optic classes that are actually\napplicable are documented in the function description.\n\n#### `optic<S>(): Equivalence<S, _, S>`\n\nCreate a monomorphic equivalence for `S`. If you ever see the type\n`DisallowedTypeChange`, it means that you have attempted to change a\ntype with a monomorphic optic.\n\n#### `optic_<S>(): Equivalence<S, _, S>`\n\nCreate a polymorphic equivalence for `S`.\n\n#### `get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`\n\nRead a value through an `Equivalence`, `Iso`, `Lens` or `Getter`.\n\n#### `preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`\n\nRead a value through a `Prism`, `Traversal`, `AffineFold` or `Fold`. For\n`Prism` and `AffineFold`, return `undefined` if the optic doesn't match\n(has zero focuses). For `Traversal` and `Fold`, returns the value of the\nfirst focus, or `undefined` if there are no focuses.\n\n#### `collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`\n\nRead all focused values through a `Prism`, `Traversal`, `AffineFold` or\n`Fold`. For `Prism` and `AffineFold`, the return value is an array of 0\nor 1 elements. For `Traversal` and `Fold`, the return value is an array\nof zero or more elements.\n\n#### `modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`\n\nModify the focused value(s) through an `Equivalence`, `Iso`, `Lens`,\n`Prism` or `Traversal`. Returns an updated copy of `source` with all\nfocuses modified by mapping them through the function `f`.\n\n#### `set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`\n\nWrite a constant value through an `Equivalence`, `Iso`, `Lens`, `Prism`\nor `Traversal`. Returns an updated copy of `source` with all focuses\nreplaced by `value`.\n\n#### `compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`\n\nCompose two optics. If the first optic is from `S` to `A1`, and the\nsecond optic is from `A1` to `A2`, the result is from `S` to `A2`.\n\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Creating optics\n\nThe methods documented below are available on all optics types:\n`Equivalence`, `Iso`, `Lens`, `Prism`, `Traversal`, `Getter`,\n`AffineFold` and `Fold`. The documented return type is the type of the\noptic that these methods create. The actual return type is the\ncomposition of the optic on which the method is called and on the optic\nthat the method creates.\n\nNote that there are no functions to create `AffineFold` or `Fold`\noptics. You can only get these by composing other types of optics.\n`Equivalence` can be created by calling the top-level `optic()`\nfunction.\n\n### Isomorphisms\n\nIsomorphisms have the type `Iso<S, T, A>`. In the following, we omit\nthe exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`\n\nCreate an isomorphism from functions `there` and `back`. `there` takes\nthe focus and transforms it to another value. `back` is the inverse of\n`there`.\n\nNote that `iso` is monomorphic. There's no polymorphic alternative\n(yet).\n\n### Lenses\n\nLenses have the type `Lens<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`\n\nCreate a lens that focuses on the property `K` of `A`.\n\n**Note:** `prop()` only works for string properties, even though\nTypeScript's type system also allows array's numeric indices when using\n`keyof`. Use the `index()` prism to focus on an array element at a given\nindex.\n\n#### `path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`\n\nA shortcut for focusing on chain of properties.\n\n```typescript\nfoo.path(['a', 'b', 'c'])\n```\n\nis equal to\n\n```typescript\nfoo.prop('a').prop('b').prop('c')\n```\n\n#### `pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`\n\nCreate a lens that focuses on a sub-object of `A` with the given\nproperties. When writing through a polymorphic `.pick()` lens, you can\nadd or remove properties.\n\nExample:\n\n```typescript\nconst data = {\n  foo: 'something',\n  bar: 42,\n  baz: true,\n}\nconst lens = O.optic_<typeof data>().pick(['foo', 'bar'])\n\nO.get(lens)(data)\n// ==> {\n//  foo: 'something',\n//  baz: true,\n// }\n\nO.set(lens)({ quux: null })(data)\n// ==> {\n//   quux: null,\n//   baz: true,\n// }\n\n// monomorphic version of the same lens\nconst monoLens = O.optic<typeof data>().compose(lens)\n\nO.set(monoLens)({ quux: null })(data)\n// ==> DisallowedTypeChange\n```\n\n#### `prependTo(): Lens<S, _, ElemType<A> | undefined>`\n\n#### `appendTo(): Lens<S, _, ElemType<A> | undefined>`\n\nOnly works on arrays.\n\nCreate a lens that focuses on the part _before the first element_ or\n_after the last element_ of the focus array. When written through,\nprepends or appends the value to the array. When read through, returns\nundefined (as there's nothing before or after the array).\n\nIf `undefined` is written, the array is not changed. When an element of\na different type `B` is written, the resulting array will have the type\n`Array<A | B>`.\n\n### Prisms\n\nPrisms have the type `Prism<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `optional(): Prism<S, _, Exclude<A, undefined>>`\n\nCreate a prism that focuses on the non-`undefined` subtype of `A`.\n\n#### `guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`\n\nCreate a prism that focuses on the subtype `U` of `A` that matches the\ntype guard `g`.\n\nNote that `guard()` is monomorphic. Use `guard_` if you want a\npolymorphic guard.\n\n#### `guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`\n\nCreate a prism that focuses on the subtype of `A` that matches the type\nguard `g`. When written to, uses the higher-kinded type `F` to construct\nthe output type.\n\n#### `index(i: number): Prism<S, _, ElemType<A>>`\n\nOnly works on arrays and strings.\n\nCreate a prism that focuses on the element type of the array `A`, or on\na substring of length 1 if `A` is `string`.\n\nWhen an element of a different type `B` is written to an array, the\nresulting array will have the type `Array<A | B>`.\n\nWhen writing to a string, only strings can be written. The length of the\nwritten string can be something else than 1.\n\n#### `head(): Prism<S, _, ElemType<A>>`\n\nShort for `index(0)`.\n\n#### `find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nLike `.index()`, but the index to be focused on is determined by\nfinding the first element that matches the given predicate.\n\nWhen a different type `B` is written through this optic, the resulting\narray will have the type `Array<A | B>`.\n\n#### `when(f: (a: A) => boolean): Prism<S, _, A>`\n\nCreate a prism that skips the focus if it doesn't match the given\npredicate. Especially useful for filtering the focuses of a travesal.\n\nWhen a different type `B` is written through this optic, the resulting\nvalue will have the type `A | B`.\n\n### Traversals\n\nTraversals have the type `Traversal<S, T, A>`. In the following, we\nomit the exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `elems(): Traversal<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nCreate a traversal that focuses on all the elements of the array.\n\n### Getters\n\nGetters have the type `Getter<S, A>`.\n\n#### `to<B>(f: (a: A) => B): Getter<S, B>`\n\nCreate a getter that applies the function `f` to its focus.\n\n### Composing\n\n#### `compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`\n\n### Strings\n\nThe following optics only work on strings.\n\n#### `chars(): Traversal<S, _, string>`\n\nCreate a traversal that focuses on all the characters of the current\nstring focus.\n\nWhen written through, characters can be removed by writing the empty\nstring, or changed to longer strings.\n\n#### `words(): Traversal<S, _, string>`\n\nCreate a traversal that focuses on all the words of the current string\nfocus. Words are substrings that are separated by whitespace.\n\nWhen written through, words can be removed by writing the empty string,\nor changed to longer or shorter strings.\n\n## Prior art\n\nThere are many existing optics libraries of varying degree for\nJavaScript, but only few for TypeScript. It's generally hard to create\ngood typings for optics in TypeScript, and the task becomes impossible\nif one tried to retrofit types on an existing JavaScript implementation.\n\n[monocle-ts](https://github.com/gcanti/monocle-ts) is probably the most\npopular TypeScript optics library. It lacks polymorphism, and creating\noptics is verbose and cumbersome. You first create optics for each level\nof the data structure, and then compose them with separate function\ncalls. This also often requires you to declare many unnecessary\nintermediate types for your data.\n\n[@grammarly/focal](https://github.com/grammarly/focal) is not an optics\nlibrary per se, rather an UI framework. Its optics are very limited.\n","licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.1.0-pre.1","dist":{"shasum":"8fb6ecf3ecbb2ff8df733926a356d643dd104f2d","integrity":"sha512-edojl0zfztNDptZ+51/T4s/1S1mzg6yUzqo5k4m13+QWrx8IKbfAlsbxspozG96knTMD7xk8BOF8h1evTjbBlg==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.1.0-pre.1.tgz","fileCount":20,"unpackedSize":95235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeqdWJCRA9TVsSAnZWagAAFpUP/2I8lYtUp2dEhr6esaof\nUbqoQLIk4v/Xco+0eDEPT2tlrE70bTdwERsQIdsG610wK2iy7ZXQCNxAppb/\nqXBK1rc2PCkzDX7CDANOqyGTA501leIYAGpYad/acvhYtwOO3fBdWahY1Z35\nxUujVZ9qqaG0b7VGxF2rruDXrrcdDj8dg1t+FIKl7DDcSc16e/H228gPHwNy\nKsgiVwVT539hjzA1hMpCMGLo4nPArL5ta7E7qh6ppmkskzwSz4ZV/YCMAT3n\nRJvFFKdtsTy4Ky32MtTcD9VPfD/dBSXviRbMsGLUgHdNZyDf5wSV3jSHShzz\nQIJ8L2oiZkKST+yFC7VaIkcRadAMiuIvI7JGt8ONo9p1VLLx7XIPOyTQAZB6\nxtNQEMeiTKRAE/HklMZq8snuG4mmHS4JU3UFsc6l2h7IrUThUN0f1J+TAr/E\nekSMFu6SVZfBRlmlG4Q9hXQeO2ZUQl/mseNn4yXSeWV6L09g0Qhd5LV1YbTB\ndr35EmqFOWXrlHmR7dvLYRIe84esDJ0wbK2d5GMemz96HkkwTunlpI4Sk4Ns\ndU2wcChkqfqOEJhKBA+WjD9Q4zsaNwDs2QChROSJNeJl3Zh6trwBNUH1iKwH\n2Awj+xEmqcY8ZZY0QT1Yw3M8Kn97pabPM1ZwZCAT5HKQ4m9zhBPup0EsP1Fr\n3DoX\r\n=7mv3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDS0A6WP8ZpabocGpd9JHJY1ZkMsV3F/Q4iaaVimiKOYgIgMgrh5Alt60ivC+dOhKSLhQgBcA7tZVdgid6Snw3s3k0="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.1.0-pre.1_1588188553255_0.34048600341329505"},"_hasShrinkwrap":false},"1.1.0-pre.2":{"name":"optics-ts","version":"1.1.0-pre.2","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"readmeFilename":"README.md","readme":"# optics-ts\n\n[![CircleCI](https://circleci.com/gh/akheron/optics-ts.svg?style=shield)](https://circleci.com/gh/akheron/optics-ts)\n\n`optics-ts` provides type-safe, ergonomic, polymorphic optics for\nTypeScript:\n\n- **Optics** allow you to read or modify values from deeply nested\n  data structures, while keeping all data immutable.\n- **Ergonomic**: Optics are composed with method chaining, making it\n  easy and fun!\n- **Polymorphic**: When writing through the optics, you can change the\n  data types in the nested structure.\n- **Type-safe**: The compiler will type check all operations you do.\n  No `any`, ever.\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Tutorial](#tutorial)\n  - [Lens](#lens)\n  - [Prism](#prism)\n  - [Traversal](#traversal)\n  - [Other types of optics](#other-types-of-optics)\n  - [Polymorphism](#polymorphism)\n- [API reference](#api-reference)\n  - [Types of optics](#types-of-optics)\n  - [Method chaining](#method-chaining)\n  - [Type parameters](#type-parameters)\n  - [Top-level functions](#top-level-functions)\n    - [`optic<S>(): Equivalence<S, _, S>`](#optics-equivalences-_-s)\n    - [`optic_<S>(): Equivalence<S, _, S>`](#optic_s-equivalences-_-s)\n    - [`get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`](#gets-aoptic-optics-_-a--source-s--a)\n    - [`preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`](#previews-aoptic-optics-_-a--source-s--a--undefined)\n    - [`collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`](#collects-aoptic-optics-_-a--source-s--a)\n    - [`modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`](#modifys-t-aoptic-optics-t-a--bf-a-a--b--source-s--tb)\n    - [`set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`](#sets-t-aoptic-optics-t-a--bvalue-b--source-s--tb)\n    - [`compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`](#composes-a1-a2optic1-optics-_-a1-optic2-optica1-_-a2-optics-_-a2)\n  - [Creating optics](#creating-optics)\n  - [Isomorphisms](#isomorphisms)\n    - [`iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`](#isouthere-a-a--u-back-u-u--a-isos-_-u)\n  - [Lenses](#lenses)\n    - [`prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`](#propk-extends-keyof-akey-k-lenss-_-ak)\n    - [`path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`](#pathk1-k2-keys-k1-k2--lenss-_-ak1k2)\n    - [`pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`](#pickk-extends-keyof-akeys-k-lenss-_-picka-k)\n  - [Prisms](#prisms)\n    - [`optional(): Prism<S, _, Exclude<A, undefined>>`](#optional-prisms-_-excludea-undefined)\n    - [`guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`](#guardu-extends-ag-a-a--a-is-u-prisms-_-u)\n    - [`guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`](#guard_f-extends-hkt-u-extends-ag-a-a--a-is-u--prisms-t-%C2%B7-f-u)\n    - [`index(i: number): Prism<S, _, ElemType<A>>`](#indexi-number-prisms-_-elemtypea)\n    - [`head(): Prism<S, _, ElemType<A>>`](#head-prisms-_-elemtypea)\n    - [`find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`](#findp-e-elemtypea--boolean-prisms-_-elemtypea)\n    - [`when(f: (a: A) => boolean): Prism<S, _, A>`](#whenf-a-a--boolean-prisms-_-a)\n  - [Traversals](#traversals)\n    - [`elems(): Traversal<S, _, ElemType<A>>`](#elems-traversals-_-elemtypea)\n  - [Getters](#getters)\n    - [`to<B>(f: (a: A) => B): Getter<S, B>`](#tobf-a-a--b-getters-b)\n  - [Composing](#composing)\n    - [`compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`](#composebother-optica-_-b-optics-_-b)\n  - [Strings](#strings)\n    - [`chars(): Traversal<S, _, string>`](#chars-traversals-_-string)\n    - [`words(): Traversal<S, _, string>`](#words-traversals-_-string)\n- [Prior art](#prior-art)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Installation\n\n```\nnpm install --save optics-ts\n```\n\nor\n\n```\nyarn add optics-ts\n```\n\n## Tutorial\n\nThe following import is assumed in all the examples below:\n\n```typescript\nimport * as O from 'optics-ts'\n```\n\n### Lens\n\nLens is the most common optic you're going to use. You can create an\noptic for a data structure by calling `O.optic()`, and turn in into a\nlens that focuses on a property of an object with `.prop()`:\n\n```typescript\ntype Data = {\n  foo: { bar: number }\n  other: string\n}\nconst foo = O.optic<Data>().prop('foo')\n```\n\n`foo` is now a lens that focuses on `Data.foo`.\n\nTo dig deeper, just call `.prop()` again:\n\n```typescript\nconst bar = O.optic<Data>().prop('foo').prop('bar')\n// or from the `foo` lens we defined above\nconst bar = foo.prop('bar')\n// or use .path() to compose multiple prop lenses with a single call\nconst bar = O.optic<Data>().path(['foo', 'bar'])\n```\n\nUse `get()` to read a value through the lens:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 42 },\n  other: 'stuff',\n}\n\nO.get(lens)(data)\n// => 42\n```\n\nUse `set()` or `modify()` to write the focused value through the lens:\n\n```typescript\nO.set(lens)(99)(data)\n// => {\n//   foo: { bar: 99 },\n//   other: 'stuff'\n// }\n\nO.modify(lens)(x => x * 100)(data)\n// => {\n//   foo: { bar: 4200 },\n//   other: 'stuff'\n// }\n```\n\nWriting through optics always creates a new data structure instead of\nmodifying the existing one. In other words, data is immutable.\n\n### Prism\n\nLenses are great for focusing to a part of a larger structure. Prisms\nare much like lenses, but they don't necessarily match anything, i.e.\nthey can have zero focuses.\n\nA practical example is focusing on a branch of a union type. Here, the\n`User.age` field can be `number` or `undefined`. With the `.optional()`\nprism we can focus only when the value is a `number`, and do nothing\nwhen it's `undefined`:\n\n```typescript\ntype User = {\n  name: string\n  age?: number | undefined\n}\n\nconst age = O.optic<User>().prop('age').optional()\n```\n\nYou read through a prism using the `preview()` function. When the prism\ndoesn't match, it returns `undefined`.\n\n```typescript\nconst userWithAge: User = {\n  name: 'Betty',\n  age: 42,\n}\nO.preview(age)(userWithAge)\n// ==> 42\n\nconst userWithoutAge: User = {\n  name: 'Max',\n  age: undefined,\n}\nO.preview(age)(userWithoutAge)\n// ==> undefined\n```\n\nIf the prism doesn't match, `preview()` returns undefined, as seen above.\n\nYou can write through a prism normally with `set()` and `modify()`. If\nthe prism doesn't match, the value is unchanged:\n\n```typescript\nO.modify(age)(n => n + 1)(userWithAge)\n// ==> {\n//   name: 'Betty',\n//   age: 43,\n// }\n\nO.set(age)(60)(userWithoutAge)\n// ==> {\n//   name: 'Max',\n//   age: undefined,\n// }\n```\n\n`.guard()` is another method that creates a prism. It's a generalization\nof `.optional()` in the sense that you can match on any branch of a\nunion type instead of just the non-`undefined` part:\n\n```typescript\ninterface Square {\n  kind: 'square'\n  size: number\n}\ninterface Rectangle {\n  kind: 'rectangle'\n  width: number\n  height: number\n}\ntype Shape = Square | Rectangle\n\nfunction isRectangle(s: Shape): s is Rectangle {\n  return s.kind === 'rectangle'\n}\n\nconst rectWidth = O.optic<Shape>().guard(isRectangle).prop('width')\n\nO.preview(rectWidth)({ kind: 'square', size: 10 })\n// ==> undefined\n\nO.preview(rectWidth)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> 5\n\nO.modify(rectWidth)(w => w * 2)({ kind: 'rectangle', width: 5, height: 7 })\n// ==> { kind: 'rectangle', width: 10, height: 7 })\n```\n\nNotice how above we used `.guard(...).prop(...)`, composing a prism with\na lens. This yields a prism, so we used `preview()` to read through it.\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Removable optics\n\nSome optics are removable. This means that they focus on an element of a\ncontainer (e.g. an array), and you can remove the element from the\ncontainer.\n\n`.index()` is a removable prism. It focuses on an index of an array, and\nlets you also remove that index:\n\n```typescript\ninterface User {\n  name: string\n}\n\nconst secondUser = O.optic<Users>().index(1)\n\nconst threeUsers: User[] = [\n  { name: 'Max' },\n  { name: 'Betty' },\n  { name: 'Alice' },\n]\nO.remove(secondUser)(threeUsers)\n// ==> [{ name: 'Max' }, { name: 'Alice' }]\n```\n\nIf the optic doesn't match, removing has no effect:\n\n```typescript\nconst oneUser: User[] = [{ name: 'Max' }]\n\nO.remove(secondUser)(oneUser)\n// ==> [{ name: 'Max' }]\n```\n\n### Traversal\n\nThe next optic type is the traversal. While lenses have 1 focus and\nprisms have 0 or 1 focus (no match or match), traversals have 0 or\nmore focuses.\n\nThe simplest example of a traversal is to focus on the elements of an\narray. To create such a traversal, use `.elems()`:\n\n```typescript\ntype Person {\n  name: string\n  friends: Person[]\n}\n\nconst friendsNames = O.optic<Person>()\n  .prop('friends')\n  .elems()\n  .prop('name')\n```\n\nTo read through a traversal, call `collect()` to collect all focused\nelements into an array:\n\n```typescript\nconst john = { name: 'John', friends: [] }\nconst bruce = { name: 'Bruce', friends: [] }\nconst amy = { name: 'Amy', friends: [john, bruce] }\n\nO.collect(friendsNames)(amy)\n// ==> [ 'John', 'Bruce' ]\n```\n\nWriting through a traversal writes to all focused values:\n\n```typescript\nO.modify(friendsNames)(name => `${name} Wayne`)(amy)\n// ==> {\n//   name: 'Amy',\n//   friends: [\n//     { name: 'John Wayne', friends: [] },\n//     { name: 'Bruce Wayne', friends: [] },\n//   ],\n// }\n```\n\nNote again how we used `.prop(...).elems(...).prop(...)`, composing a\nlens with a traversal, and then with a lens again. This yields a\ntraversal. See [Types of optics](#types-of-optics) for more info.\n\nIt's sometimes useful to further focus on certain elements of a\ntraversal. This can be done by composing a traversal with a prism like\n`.when()` that skips items that don't match a predicate:\n\n```typescript\nconst even = O.optic<number[]>()\n  .elems()\n  .when(n => n % 2 === 0)\n\nO.modify(even)(n => -n)([1, 2, 3, 4, 5])\n// ==> [1, -2, 3, -4, 5]\n```\n\n### Other types of optics\n\nIn fact, calling `O.optic()` also yields an optic, but instead of\nbeing a lens, prism or traversal, it's an equivalence. As the name\nsuggests, equivalence keeps the value equal, in both reading and\nwriting directions:\n\n```typescript\nconst str = O.optic<string>()\n\nO.get(str)('original')\n// ==> 'original'\n\nO.set(str)('new')('original')\n// ==> 'new' ('original' is discarded)\n```\n\nSupported optic types also include _isomorphism_, which can be used to\ndo 2-way data transformations. Furthermore, there are read-only optics\nanaloguous to isomorphism, prism, and traversal. While isomorphism is\n2-way transformation (a mapping function and its inverse), _getter_ is a\none-way transformation (just a mapping function). _Affine fold_ and\n_fold_ are read-only variants of prism and traversal.\n\n### Polymorphism\n\nOptics can be polymorphic, which means you can change the type of the\nfocus when you write through an optic. Since this is a relatively rare\nuse case, and may be confusing if done by accident, polymorphic optics\nare created with `optic_()` (note the underscore):\n\n```typescript\ntype Data = {\n  foo: { bar: string }\n  other: boolean\n}\nconst bar = O.optic_<Data>().path(['foo', 'bar'])\n```\n\nLet's modify `bar` to contain the length of the original string instead:\n\n```typescript\nconst data: Data = {\n  foo: { bar: 'hello there' },\n  other: true,\n}\n\nconst updated = O.modify(bar)(str => str.length)(data)\n// ==> {\n//   foo: { bar: 11 },\n//   other: true\n// }\n```\n\nThis is a type-safe operation, i.e. the compiler knows that the type of\n`updated.foo.bar` is `number`, editor autocomplete works correctly, etc.\n\nIf you ever see a `DisallowedTypeChange` type being returned from an\n`optics-ts` function, it means that you tried to change the type when\nwriting through a non-polymorphic (monomorphic) optic.\n\n## API reference\n\n### Types of optics\n\nThe supported optic classes are Equivalence, Iso (isomorphism), Lens,\nPrism, Traversal, Getter, AffineFold, Fold and Setter.\n\nEquivalence, Iso, Lens, Prism and Traversal are read-write, i.e. you can\nread and write through them. Getter, AffineFold and Fold are read-only.\nSetter is write-only.\n\nEquivalence, Iso, Lens and Getter have one focus, i.e. you can\nalways read and write through them (Getter doesn't support writing).\nPrism and AffineFold have zero or one focus, i.e. reading may yield no\nvalue and writing may have no effect if there's no focus. Traversal and\nFold have zero or more focuses, meaning that reading yields zero or more\nvalues, and writing modifies zero or more values.\n\nAny read-write and read-only optic can be composed with another\nread-write and read-only optic. The type of the resulting optic can be\ndetermined from this diagram:\n\n```\nEquivalence -> Iso -> Lens ---> Prism ------> Traversal\n                      |         |             |\n                      v         v             v\n                      Getter -> AffineFold -> Fold\n```\n\nWhen you compose two optics A and B, the result is the nearest optic\nthat you get by following the arrows starting from both A and B.\n\nFor example, composing a Getter with a Traversal yields a Fold.\nComposing an Iso with a Prism yields a Prism.\n\n```\nSetter\n```\n\nSetter is special. You can only compose writable optics with setters.\nSetters cannot be further composed with any other optic.\n\n```\nRemovablePrism\n```\n\nRemovablePrism behaves like a regular prism, but it can be removed from\nits containing container. When composed with other optics, composes like\na regular Prism.\n\nThe naming of the optic classes was inspired by\n[Glassery](http://oleg.fi/gists/posts/2017-04-18-glassery.html) by Oleg\nGrenrus.\n\n### Method chaining\n\nOptics are composed with method chaining. This means that each optic\ntype has most of the methods documented below, regardless of the type of\nthe optic that the method creates. The only difference is the return\ntype, which is determined by the composition rules above.\n\nFor example, assume we have a variable `myLens` that holds a `Lens`, and\ncall `.optional()` on it:\n\n```typescript\nconst newOptic = myLens.optional()\n```\n\n`.optional()` creates a prism, so `newOptic` will be a composition of\nlens and prism, i.e. a prism.\n\nWhich methods each optic type has depends on the composition rules\npresented in [Typef of optic](#types-of-optics). For example, the\n`.prop()` method creates a lens, so a getter has that method because you\ncan compose a getter and a lens. On the other hand, the `.appendTo()`\nmethod, which creates a setter, is not available in a getter, because\ngetters cannot be composed with setters.\n\n### Type parameters\n\nAll writable optics have 3 type parameters: `<S, T, A>`, and all\nread-only optics have 2 type parameters: `<S, A>`:\n\n- `S` is the source on which the optic operates\n\n- `A` is the type of the focus or focuses\n\n- `T` is a \"higher-kinded type\" or a \"partially applied type operator\"\n  that yields the output type when applied to some type `B`.\n\nConceptually, when you write a value of type `B`, the output type will\nbe `S` with `A` replaced by `B` at the focus(es) of the optic. `T` is\nthe mechanism that transforms `B` to the output type. This construct\nmakes it possible for the optics to be polymorphic on the type level.\nThe read-only optics don't need `T` because you cannot write through\nthem.\n\nIn the following, we leave the exact definition of `T` for each optic\nout for clarity, writing just `_` in its place. It's usually clear from\nhow the optic works what will come out if you put a different type in.\n\nIn the documentation of functions that can be used to write through an\noptic, the return type is denoted by `T<B>`. While not valid TypeScript\nsyntax (because `T` is a type parameter instead of a concrete type),\nthis captures the meaning quite well: `B` is applied to the\nhigher-kinded type `T`, yielding the output type.\n\nInterested readers can refer to [hkt.ts](src/hkt.ts) to see how the\nhigher-kinded types / partially applied type operators are actually\nimplemented.\n\n### Top-level functions\n\nThese functions are available as top level exports of the `optics-ts`\nmodule.\n\nMost functions have `Optic` in their signature. It means that multiple\noptics work with the function. The optic classes that are actually\napplicable are documented in the function description.\n\n#### `optic<S>(): Equivalence<S, _, S>`\n\nCreate a monomorphic equivalence for `S`. If you ever see the type\n`DisallowedTypeChange`, it means that you have attempted to change a\ntype with a monomorphic optic.\n\n#### `optic_<S>(): Equivalence<S, _, S>`\n\nCreate a polymorphic equivalence for `S`.\n\n#### `get<S, A>(optic: Optic<S, _, A>) => (source: S) => A`\n\nRead a value through an `Equivalence`, `Iso`, `Lens` or `Getter`.\n\n#### `preview<S, A>(optic: Optic<S, _, A>) => (source: S) => A | undefined`\n\nRead a value through a `Prism`, `Traversal`, `AffineFold` or `Fold`. For\n`Prism` and `AffineFold`, return `undefined` if the optic doesn't match\n(has zero focuses). For `Traversal` and `Fold`, returns the value of the\nfirst focus, or `undefined` if there are no focuses.\n\n#### `collect<S, A>(optic: Optic<S, _, A>) => (source: S) => A[]`\n\nRead all focused values through a `Prism`, `Traversal`, `AffineFold` or\n`Fold`. For `Prism` and `AffineFold`, the return value is an array of 0\nor 1 elements. For `Traversal` and `Fold`, the return value is an array\nof zero or more elements.\n\n#### `modify<S, T, A>(optic: Optic<S, T, A>) => <B>(f: (a: A) => B) => (source: S) => T<B>`\n\nModify the focused value(s) through an `Equivalence`, `Iso`, `Lens`,\n`Prism` or `Traversal`. Returns an updated copy of `source` with all\nfocuses modified by mapping them through the function `f`.\n\n#### `set<S, T, A>(optic: Optic<S, T, A>) => <B>(value: B) => (source: S) => T<B>`\n\nWrite a constant value through an `Equivalence`, `Iso`, `Lens`, `Prism`\nor `Traversal`. Returns an updated copy of `source` with all focuses\nreplaced by `value`.\n\n#### `remove<S, T, A>(optic: Optic<S, T, A>) => (source: S) => S`\n\nRemove the focus of a `RemovablePrism` from its containing container.\n\n#### `compose<S, A1, A2><optic1: Optic<S, _, A1>, optic2: Optic<A1, _, A2>): Optic<S, _, A2>`\n\nCompose two optics. If the first optic is from `S` to `A1`, and the\nsecond optic is from `A1` to `A2`, the result is from `S` to `A2`.\n\nSee [Types of optics](#types-of-optics) for the rules of composition.\n\n### Creating optics\n\nThe methods documented below are available on all optics types:\n`Equivalence`, `Iso`, `Lens`, `Prism`, `Traversal`, `Getter`,\n`AffineFold` and `Fold`. The documented return type is the type of the\noptic that these methods create. The actual return type is the\ncomposition of the optic on which the method is called and on the optic\nthat the method creates.\n\nNote that there are no functions to create `AffineFold` or `Fold`\noptics. You can only get these by composing other types of optics.\n`Equivalence` can be created by calling the top-level `optic()`\nfunction.\n\n### Isomorphisms\n\nIsomorphisms have the type `Iso<S, T, A>`. In the following, we omit\nthe exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `iso<U>(there: (a: A) => U, back: (u: U) => A): Iso<S, _, U>`\n\nCreate an isomorphism from functions `there` and `back`. `there` takes\nthe focus and transforms it to another value. `back` is the inverse of\n`there`.\n\nNote that `iso` is monomorphic. There's no polymorphic alternative\n(yet).\n\n### Lenses\n\nLenses have the type `Lens<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `prop<K extends keyof A>(key: K): Lens<S, _, A[K]>`\n\nCreate a lens that focuses on the property `K` of `A`.\n\n**Note:** `prop()` only works for string properties, even though\nTypeScript's type system also allows array's numeric indices when using\n`keyof`. Use the `index()` prism to focus on an array element at a given\nindex.\n\n#### `path<K1, K2, ...>(keys: [K1, K2, ...]): Lens<S, _, A[K1][K2]...>`\n\nA shortcut for focusing on chain of properties.\n\n```typescript\nfoo.path(['a', 'b', 'c'])\n```\n\nis equal to\n\n```typescript\nfoo.prop('a').prop('b').prop('c')\n```\n\n#### `pick<K extends keyof A>(keys: K[]): Lens<S, _, Pick<A, K>>`\n\nCreate a lens that focuses on a sub-object of `A` with the given\nproperties. When writing through a polymorphic `.pick()` lens, you can\nadd or remove properties.\n\nExample:\n\n```typescript\nconst data = {\n  foo: 'something',\n  bar: 42,\n  baz: true,\n}\nconst lens = O.optic_<typeof data>().pick(['foo', 'bar'])\n\nO.get(lens)(data)\n// ==> {\n//  foo: 'something',\n//  baz: true,\n// }\n\nO.set(lens)({ quux: null })(data)\n// ==> {\n//   quux: null,\n//   baz: true,\n// }\n\n// monomorphic version of the same lens\nconst monoLens = O.optic<typeof data>().compose(lens)\n\nO.set(monoLens)({ quux: null })(data)\n// ==> DisallowedTypeChange\n```\n\n### Prisms\n\nPrisms have the type `Prism<S, T, A>`. In the following, we omit the\nexact definition of `T` for clarity, and use `_` instead. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `optional(): Prism<S, _, Exclude<A, undefined>>`\n\nCreate a prism that focuses on the non-`undefined` subtype of `A`.\n\n#### `guard<U extends A>(g: (a: A) => a is U): Prism<S, _, U>`\n\nCreate a prism that focuses on the subtype `U` of `A` that matches the\ntype guard `g`.\n\nNote that `guard()` is monomorphic. Use `guard_` if you want a\npolymorphic guard.\n\n#### `guard_<F extends HKT>(): <U extends A>(g: (a: A) => a is U) => Prism<S, T · F, U>`\n\nCreate a prism that focuses on the subtype of `A` that matches the type\nguard `g`. When written to, uses the higher-kinded type `F` to construct\nthe output type.\n\n#### `index(i: number): RemovablePrism<S, _, ElemType<A>>`\n\nOnly works on arrays and strings. Removable.\n\nCreate a prism that focuses on the element type of the array `A`, or on\na substring of length 1 if `A` is `string`.\n\nWhen an element of a different type `B` is written to an array, the\nresulting array will have the type `Array<A | B>`.\n\nWhen writing to a string, only strings can be written. The length of the\nwritten string can be something else than 1.\n\n#### `head(): Prism<S, _, ElemType<A>>`\n\nShort for `index(0)`.\n\n#### `find(p: (e: ElemType<A>) => boolean): Prism<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nLike `.index()`, but the index to be focused on is determined by\nfinding the first element that matches the given predicate.\n\nWhen a different type `B` is written through this optic, the resulting\narray will have the type `Array<A | B>`.\n\n#### `when(f: (a: A) => boolean): Prism<S, _, A>`\n\nCreate a prism that skips the focus if it doesn't match the given\npredicate. Especially useful for filtering the focuses of a travesal.\n\nWhen a different type `B` is written through this optic, the resulting\nvalue will have the type `A | B`.\n\n### Traversals\n\nTraversals have the type `Traversal<S, T, A>`. In the following, we\nomit the exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `elems(): Traversal<S, _, ElemType<A>>`\n\nOnly works on array types. `ElemType<A>` is the element type of the\narray type `A`.\n\nCreate a traversal that focuses on all the elements of the array.\n\n### Getters\n\nGetters are read-only optics with a single focus. You can think of them\nlike one-way isomorphisms or read-only lenses.\n\nGetters have the type `Getter<S, A>`. See [Type\nparameters](#type-parameters) for the meanings of type parameters.\n\n#### `to<B>(f: (a: A) => B): Getter<S, B>`\n\nCreate a getter that applies the function `f` to its focus.\n\n### Setters\n\nSetters have the type `Setter<S, T, A>`. In the following, we\nomit the exact definition of `T` for clarity, and use `_` instead. See\n[Type parameters](#type-parameters) for the meanings of type\nparameters.\n\n#### `prependTo(): Setter<S, _, ElemType<A>>`\n\n#### `appendTo(): Setter<S, _, ElemType<A>>`\n\nOnly works on arrays.\n\nCreate a setter that focuses on the part _before the first element_ or\n_after the last element_ of the focus array. When written through,\nprepends or appends the value to the array.\n\nWhen an element of a different type `B` is written, the resulting array\nwill have the type `Array<A | B>`.\n\n### Composing\n\n#### `compose<B>(other: Optic<A, _, B>): Optic<S, _, B>`\n\n### Strings\n\nThe following optics only work on strings.\n\n#### `chars(): Traversal<S, _, string>`\n\nCreate a traversal that focuses on all the characters of the current\nstring focus.\n\nWhen written through, characters can be removed by writing the empty\nstring, or changed to longer strings.\n\n#### `words(): Traversal<S, _, string>`\n\nCreate a traversal that focuses on all the words of the current string\nfocus. Words are substrings that are separated by whitespace.\n\nWhen written through, words can be removed by writing the empty string,\nor changed to longer or shorter strings.\n\n## Prior art\n\nThere are many existing optics libraries of varying degree for\nJavaScript, but only few for TypeScript. It's generally hard to create\ngood typings for optics in TypeScript, and the task becomes impossible\nif one tried to retrofit types on an existing JavaScript implementation.\n\n[monocle-ts](https://github.com/gcanti/monocle-ts) is probably the most\npopular TypeScript optics library. It lacks polymorphism, and creating\noptics is verbose and cumbersome. You first create optics for each level\nof the data structure, and then compose them with separate function\ncalls. This also often requires you to declare many unnecessary\nintermediate types for your data.\n\n[@grammarly/focal](https://github.com/grammarly/focal) is not an optics\nlibrary per se, rather an UI framework. Its optics are very limited.\n","licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.1.0-pre.2","dist":{"shasum":"006dcd0f45362ef9417f716c51b841e911ec4db6","integrity":"sha512-vjGf8pZx7IF1p4FAkpufBL3JHmf0jhSlpFnVyNPgZM4RU1N8AqsNe5Ezrd/KmLkNCIXHwf5bdpEXTTezc9eHKw==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.1.0-pre.2.tgz","fileCount":20,"unpackedSize":108114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJerPssCRA9TVsSAnZWagAA6IgP/1h03K9+OLpSQjg4N1fe\nWlsAR4vqBhpiJOWZwkQAddXlktIeU6j0AsAsXYABSaPtR3o3HEGG3JICsW3I\neaCarAF3VK8kbO5Z04r7GJTVkrfS87b8cwPTjihoUx1WgJJOIDX2bG9xCXNO\nQeX/4j+YYHs788A6WIgBouXVKXk9lNAHcXvdYbrHkfxfKJvircXs/irtBmFj\nHpNz02eNWMVMjidudWd+ZzHku02vMpsNrCYOwI6Q1ONp9JGNvbK7F7jVqFGK\n8FfSq/eNb1CFqoU9iwyI5R5IeIP+UpbG8lUzzu9mLxtum0ORM7KNx+D29AvZ\nQfGxPZJbgmlmWQxW9Vf43lEs7CSRcLnlDqMwp1evVXPTEzkHsNwfSf+DT4NJ\nOUbDAwPpzcFeXdW/LHUtU+tZdJtMdg8fdObNtyndDrYsLJZ+e3H8fzsseqOL\nzIQYaHAYJblV17HlwseTPq5tdJakbKrH7e/sc1XhjONvsLHwsr3Cpxg7++tV\n25JCs/QVTPwdp7kpTwxP63AnHFCBeRroPcfYWlyYyQI9c89IUqPVQA9QtON+\nVOc3bST5A3g/L7/g7F7NhRq3kKfb+0e9hLG4tQsbNmax71cPUd8uNgGEJRgn\ndRjteTGx9PNfHqvxulS7fQVs75oRQOmOWMaOhCf1VF+jG5igKDIrqGsAVZ6S\nYHoW\r\n=UWjj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGkJYqvvNzXkdyvYac/heCWwGPih2IgSI5rvWpd1f6nyAiBpASnHcNrTRsU4kSVCRslRxSGm85IiNQF5AL3Zg/mAJQ=="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.1.0-pre.2_1588394796153_0.20948887001419858"},"_hasShrinkwrap":false},"1.1.0-pre.3":{"name":"optics-ts","version":"1.1.0-pre.3","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"rm -rf dist/ && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","prepublishOnly":"yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.1.0-pre.3","dist":{"shasum":"35c4941d64ca759f5a9c8b56f5438cde098c8f3b","integrity":"sha512-xnP5iBxwBJcqpFgjgGa+3WIy8nWQbbg3ppU3eVj9bo07iosSHYRllrw+rFYdFJ1AUtLN3+hM6I2OThtPqlg1qg==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.1.0-pre.3.tgz","fileCount":20,"unpackedSize":110401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJercE/CRA9TVsSAnZWagAAK04P/iP2YoYuPi4q7YbXN3C6\n3Fu79UzhVj+2++TBQMLA/6Gc3n0ItB/Ko8DuhBH2rnVgbsE01QNtZ7GIIJs6\nW84SjhCPutEyPvdPu6u+EVSVIYyDSfnUE1xmwQk9ae+pO3Y3pVofVW0Teb1D\nOGxX4CMz/wtKV4ztuvoHTOTfEszgvSODCStFSl5xFxmCl1DxWoxvdL006b+W\nZzx8gKHBUvsxrJKXvOYIeRGOGC0bnIXUrw6YA4WqDboEI7nzpV3ew3dQnHSJ\nRDZfwRz7HQylUVvXZk/CLXvc1cijACei0RZx+2VwPrKi5+5/V6NJi0RaF5p4\n9UTX/4N9Ump3HvpVa3qAd14j727fgJwmhXxcPUrIeKhzMx0Fjrsf7UaOM3SK\nm/0mClWvo4eh7OL8UD47a/wvnrFkwWd8TLvcBJBDK6PnY2e9VNX1ppGzNQKC\n9z5DNbZgi8/3eYoQYgntaM+iCXZfn11ErtUBNZocdT3AkQOYZItJWubNkNcW\nWct/Sa2152MLw4AT4mecfacCY3JFDEiEUlwXVtp0Tc7IAkmzI+/TNJZTEfKb\nLVL01oj8+CBGhbC1qmQ1PnNcR/eBFW16EfBeCTDhYLVMAcuHiXeljBopVZKx\nPFRWP7IuiPVwTztfjNCgov2WmKLwgNBU5ClPX6EkfM0f4uxaGV2mQxROgzss\n4UKP\r\n=TKOk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDp1f085/OOrk9F9YaoEGny84JAWO+D9j/Yfj67ge+vyAiB5GuzJSDtUAOJKoXDN5PU+ZkombQERcoyrnwnqPk9k2g=="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.1.0-pre.3_1588445503048_0.024552241633556182"},"_hasShrinkwrap":false},"1.1.0":{"name":"optics-ts","version":"1.1.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","clean":"rm -rf dist/","prepublishOnly":"yarn run clean && yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.9.0","@types/jest":"^25.1.4","doctoc":"^1.4.0","jest":"^25.1.0","prettier":"^2.0.2","ts-jest":"^25.2.1","ts-node":"^8.8.1","typescript":"^3.8.3"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.1.0","dist":{"shasum":"003c51c35dab5eb35c5523a03957e8bbd21ce8d2","integrity":"sha512-b1ZlzHYDgBUQd4HzT6zcr03T0IQzGXlyfzG2BhgGCfcQwo/K+PdJrLJWgibobjaVxYQoQye0oesdij0/VRMu3Q==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.1.0.tgz","fileCount":20,"unpackedSize":103932,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesa/hCRA9TVsSAnZWagAAYlMQAICtSXOc+YJQA8NyBOHT\ny3sSoMgcWdDAJrMfEXDbB4OZwLAvq4SUGdALRUGNF2NBYLGTlZXMgggRlj21\n90HGjPOIQ6pLeoh+1qcGkDJbQwCc065PdHtABD8Pz052RAGsTQqNqBEmjlg9\nyQCn5hUxFH3wMbi6GEw2frq3TzudAmoWghJb9mClAL1osTgzG8UtkRixR1jd\nSVFi5CirYYnm859VJuCxxLs/3cIxJ3QyaDgZHftplCdKiq/W8Dyh6ho0sMmH\n3wb8AzFOU0eQ8LGCpnI1fhja+nmqNcV9kwWFsf1s36JKu2XiJtWl/3lYRQSa\nMcOK+vw/fjbIV1OZ63Df8k/N2+BYfPP/7ZylVbdVM+tsur1r6OArW/ihYevV\ngiidpL/BiKZ0+HJ1JPcGiIKxtA4zwBPFIoRXcBxFaMXAWMwHMQN2JXJjf9Ph\nE8CL9H2DQediDvWYAp+89Z1UP6qpgTCmeQbZnAzWGsRV++K7ZoATTxo9no59\nSAnRl0FIobykpeSnLRtT3Csdy8PvOvv4gYy/WgpWI2o4b9+OYVIE6VAFNaed\nYnS55B87Pef3Rp+YRLM9rd378+O7B7PneHUC1RXcQahfnqHQkduwb55Zarqw\niMYulAQoaKsXyheqywgf2LwpmMAL3TGQg7KCv2N6Hov1zgTZnEybgw9W16c1\nOnER\r\n=UgsL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICAjkn1FHJwYhckytt7Xyjt49u04Wo9bkGyoOkZiMNwXAiBC8rCXv3bF27RSxWkhlxqEmMSMvKdN8qHzZQN79/1xAQ=="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.1.0_1588703200781_0.3558161399749078"},"_hasShrinkwrap":false},"1.2.0":{"name":"optics-ts","version":"1.2.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","clean":"rm -rf dist/","prepublishOnly":"yarn run clean && yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^26.0.15","doctoc":"^1.4.0","jest":"^26.6.1","prettier":"^2.1.2","ts-jest":"^26.4.3","ts-node":"^9.0.0","typescript":"^4.0.5"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@1.2.0","dist":{"shasum":"d8db012c4bb01be0504f9515ee6ee3df62329620","integrity":"sha512-YItI8h9IPjO3gWzcWlakJhrtzSQu0MJmkWTap89l45dVjaxHDqpJcfJX8VUNrRVoIXEt1Dx2WckdWoU2GYtnvg==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-1.2.0.tgz","fileCount":20,"unpackedSize":109565,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnHDmCRA9TVsSAnZWagAAJGkP/RhTukXxyr7FRcvX/1Nk\nXbk7Talp+DqAWbNuw5PXFZCol1kDKUKLr1PmrI9Sv8PHHB0hRHSdV31afraS\n6sodH//vlqtzXARYgSTiTINU8gqKfx4XLD/Fa810ouDcg2POrxc5t18VcTTo\n0G5gtua8WiqPY+4I0TCO1ROzm8QsNTX2x4YoIYV/gp45OxVgZPGcIhEWeOKi\naDC3D2d6pBa3bYgVM4/mZT8er5OGSl+l42qTdqeRpWtRp6Y05GubEPQ/EQel\n2Z7S7xy6S2MRC4T0GyzlOQdOeTIJ7M0upftcc8KLiHPswpVkT7en5PKszURN\ntkRJhd+MlRjT/FSW+CcQFjZo86AtLQbkvjnx/hlrEuMnkGmDup+LIlU6qqOJ\nTr1X/tBmXLib3mFy/wiX7lieFNbp2qIuU5aejDUmZJSTrw9PxQNMiQKXhNJq\nf5Tq2DQbpP8fYT/e/TAe+Hq98FUE+rnjA7ANh53MRG/WTpgZ3fFyVwNucQ46\n/IOkbj0Z8brA7sAUsuXIabNIBFMFeuRoAuRENllAlRcAWaUM/EgP2eBhaucM\nWyD1eO3aiKQBWr5U8sDcXiYdn5HO5gAtrMnswZASDwIG4v4C1Ho/r0oeVJK9\nCI0whljmyjlxtPfFcYRQcDiylD3PWpZEMANczpLyojM49m2sNEfaPg1eTI5c\ndL0K\r\n=AU0Z\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCIMQvQes1QSwBlAGnHGRE+haRHGdtF6bES6iAEtw+IAQIgZL6NB6bNSqt4XuUUdEAoH1Wro+QAlC1g8XaOWEnTArM="}]},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_1.2.0_1604088037728_0.17888961074027132"},"_hasShrinkwrap":false},"2.0.0":{"name":"optics-ts","version":"2.0.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","clean":"rm -rf dist/","lint":"prettier --check '**/*.ts'","lint:fix":"prettier --write '**/*.ts'","prepublishOnly":"yarn run clean && yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^26.0.15","doctoc":"^1.4.0","jest":"^26.6.1","prettier":"^2.2.0","ts-jest":"^26.4.3","ts-node":"^9.0.0","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.0.0","dist":{"shasum":"0b77900d8ff90a52ab1364963927a9c3d8512042","integrity":"sha512-4Nzbn4IYGNA6kpR6n/QS0gkMqi349o8DEsl2nrDEeLpAVz1tgzhaCus0drRl8ewe52RPWYqwIMemfzk/O924+Q==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.0.0.tgz","fileCount":20,"unpackedSize":115328,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxoNACRA9TVsSAnZWagAAqLMP/0szcS4KeIMXDyK3F1v+\n/X/ryQ1nN6PCOtkaSE/XlPOC8Jcgie/DxajkkSnkpwBYSseTjMGN61m282tE\nl0dRalNeSMzy4C0wlLxEBXyMF+m4ZOuuprvST6gVrO4K6Ozo6HpgMZVw32y3\nQthliWNkwBajcYYdSLMGPg2CysZZ390NYCNhiwJALcYJ1Vc+u+xH6f9Iuff1\nssitzuJO6tblyU4YEd4b68/Mj/wwfxzbkUfCQ/uHJAsuYBsQNEkDZNnXfhEl\nDVeVMdA9ml5GnYFXdjxm3cjti0vP+UfthDHiq1NOCgK7y+i0ZNCU4yX/1HUq\nP7s2eG1Ui1hV9sY41tTtKk49K1XkCFND/R3+SSh2o6cdYjrcQEZYCrJsEfs+\ncZQKyFOsojJ/llSKI71Lj5a/f+DxGD2Eq39IgjJtgz6l2S4bjLsNeo94Un2p\nxzkajH0JJRz4PIo0c+pOqPZLnukKC8gugixj6hDjbNlY1b5UD3TZNnqN90T3\nJNCVceVXyNTFbLL7wiFOJ5yvcyJ5VEYbF0+F34jfT8dE6NlrMDFjPdbaABKQ\nYIO3a3xoE9zJLSS7rW8Zr2qjDEb0ssRoW68n+9luTtQmhUwrLI740dxeNKH4\nh3D5mO5I/Lep+Fa+JY1btxXUiwD5dOr+juvzQad2TH6KNXQnrEwXXYWPTzRt\nJPe1\r\n=lYhQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGgOo3lIBcxdOpVzRdoAeO6VFe7lL61yzQNllT4+LTSeAiEA1I69e6nMHdTNdI6ExIMZh7n0txF2yBPR4FiGt+v+JvA="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.0.0_1606845247437_0.2359023573259924"},"_hasShrinkwrap":false},"2.1.0":{"name":"optics-ts","version":"2.1.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/lib/index.js","module":"./dist/esm/index.js","typings":"./dist/lib/index.d.ts","scripts":{"build":"tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json","test":"jest","clean":"rm -rf dist/","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","doctoc":"doctoc README.md --title '## Table of Contents' && prettier --write README.md","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^26.0.15","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","doctoc":"^2.0.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","jest":"^26.6.1","prettier":"^2.2.1","ts-jest":"^26.4.3","ts-node":"^9.0.0","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.1.0","dist":{"shasum":"dcfd20297ff77ed169d326792733a71e933e801e","integrity":"sha512-SJIwf16fwyo9+O+x303BifrWZ/H6Du/hS1zz4UERYt9BaRvxBID9XCYZlQ3c2aIrqeG64AxLcRy8VC/OYUkS9A==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.1.0.tgz","fileCount":20,"unpackedSize":121482,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgX4ZiCRA9TVsSAnZWagAAYOQP/2YBNZepCxq/XCTju4yK\nPCTlx1pVBceGQvlMQOKLrzDwooc5Q9e1rQ0K/EN5UfZTz2RgFWD7oib/TmRW\nacP2Jy8wlPK6fLqaIhANrbKE2wMl6AYM9XG75OILwvkaYFC/0npMfzEBZwHP\n51t5hqGl5IV2OXbjokJonVXrlHIt1zSHu/tTMT8gGkyr2IN6rf6aCBG3S74r\nJSrwlxUzO/5puWJVRavfRsgFcTceVSZcQZ8Ltm8YenYmngYY51gJJocI5Lpn\nNOJiOZuSfuwNNIXuGepEVSh9IcgTa0i63tqHS2+TQftTEbxbkGoblN5qBQvS\ndomL0HX0yprzQkyo1xDBdqUFKc6+uUSi+cU4+vRZ0aDyOMsAkd7Z2kUPgg+f\n2PUq8g8EC2EVIocp0gV2UAj1hSV4YhLx7yE6vr0eQgTuOBCnZKSRdukurtIS\n37Boma93cUkuAX4nfHYYidwwAaC4iccsCV0XMpoE28icTislwQllU/51nJn3\n+Gg3N4TpmG5FBpcDqUFDgUUqgZK5w5EozXKm0r8PBsQ35RfjOYCsIpSLwP68\n1IE/pP4RMVwRXqjsnIsqiMEQDG9PSLhE+d/MJp3COsbhHF+aoPhBroNbKCu3\npHBIxIOzplnzOScNL22NLDxOV3+ohuU1+yhHqh7EPMT/zczfvDrtdcv8j+lZ\nSU40\r\n=IHxe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBrIL4WjqcM/p63s6LkLIY0jeqhs8fBImOLW3aBVRdHTAiEA9Up696/5zwV2OfMGN+T5l7JrzMlp3zNKqmPznhkysy0="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.1.0_1616873058127_0.8914147493041651"},"_hasShrinkwrap":false},"2.2.0-pre.0":{"name":"optics-ts","version":"2.2.0-pre.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"readmeFilename":"README.md","readme":"# optics-ts\n\n[![Build](https://github.com/akheron/optics-ts/workflows/tests/badge.svg)](https://github.com/akheron/optics-ts/actions/workflows/tests.yml)\n\n`optics-ts` provides type-safe, ergonomic, polymorphic optics for TypeScript:\n\n- **Optics** allow you to read or modify values from deeply nested data\n  structures, while keeping all data immutable.\n- **Ergonomic**: Optics are composed with method chaining, making it easy and\n  fun!\n- **Polymorphic**: When writing through the optics, you can change the data\n  types in the nested structure.\n- **Type-safe**: The compiler will type check all operations you do. No `any`,\n  ever.\n\n## Features\n\n`optics-ts` supports lenses, prisms, traversals, removing items from containers,\nand much more!\n\nSince optics-ts v2.2.0, there are two syntaxes for defining optics: method\nchaining (the default) and standalone optics (experimental). See\n[the docs](https://akheron.github.io/optics-ts) for more info!\n\n## Getting started\n\nInstallation:\n\n```\nnpm install optics-ts\n```\n\nor\n\n```\nyarn add optics-ts\n```\n\nHere's a simple example demonstrating how lenses can be used to drill into a\nnested data structure:\n\n```typescript\nimport * as O from 'optics-ts'\n\ntype Book = {\n  title: string\n  isbn: string\n  author: {\n    name: string\n  }\n}\n\n// Create a lens that focuses on author.name\nconst optic = O.optic_<Book>()\n  .prop('author')\n  .prop('name')\n\n// This is the input data\nconst input: Book = {\n  title: \"The Hitchhiker's Guide to the Galaxy\"\n  isbn: \"978-0345391803\",\n  author: {\n    name: \"Douglas Adams\"\n  }\n}\n\n// Read through the optic\nO.get(optic)(input)\n// \"Douglas Adams\"\n\n// Write through the optic\nO.set(optic)(\"Arthur Dent\")(input)\n// {\n//   title: \"The Hitchhiker’s Guide to the Galaxy\"\n//   isbn: \"978-0345391803\",\n//   author: {\n//     name: \"Arthur Dent\"\n//   }\n// }\n\n// Update the existing value through the optic, while also changing the data type\nO.modify(optic)(str => str.length + 29)(input)\n// {\n//   title: \"The Hitchhiker’s Guide to the Galaxy\"\n//   isbn: \"978-0345391803\",\n//   author: {\n//     name: 42\n//   }\n// }\n```\n\nAnother example that converts all words longer than 5 characters to upper case:\n\n```typescript\nimport * as O from 'optics-ts/standalone'\n\nconst optic = O.optic<string>().words().when(s => s.length >= 5)\n\nconst input = 'This is a string with some shorter and some longer words'\nO.modify(optic)((s) => s.toUpperCase()(input)\n// \"This is a STRING with some SHORTER and some LONGER WORDS\"\n```\n\nSee the [documentation](https://akheron.github.io/optics-ts) for a tutorial and\na detailed reference of all supported optics.\n\n## Development\n\nRun `yarn` to install dependencies.\n\n### Running the test suite\n\nRun `yarn test`.\n\nFor compiling and running the tests when files change, run these commands in\nseparate terminals:\n\n```\nyarn build:test --watch\nyarn jest dist-test/ --watchAll\n```\n\n### Documentation\n\nYou need Python 3 to build the docs.\n\n```\npython3 -m venv venv\n./venv/bin/pip install mkdocs-material\n```\n\nRun a live reloading server for the documentation:\n\n```\n./venv/bin/mkdocs serve\n```\n\nOpen http://localhost:8000/ in the browser.\n\n### Releasing\n\n```\n$ yarn version --new-version <major|minor|patch>\n$ yarn publish\n$ git push origin main --tags\n```\n\nOpen https://github.com/akheron/optics-ts/releases, edit the draft release,\nselect the newest version tag, adjust the description as needed.\n","licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.2.0-pre.0","dist":{"shasum":"9d7ade085dd9e6596299e5a735e5543c480ed4df","integrity":"sha512-nqzfTPLeE8SV6D7VdotNzagqSW8BMhA/GgyDFpfuozLJBfHpUN3MfxRmevHObh8Me29+vGevm62nqCQc2yrU3w==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.2.0-pre.0.tgz","fileCount":112,"unpackedSize":130987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhN3YxCRA9TVsSAnZWagAAmZYP/R/Sv20LxLxxlGhHmpBO\n4pHGb7WXJ8qYVDeHe2kUPHVc4RJaaHClkgoevwGHdcyluMqqc3QkZEeruz83\nT4emEzALkdOuChkf92ZjhZTmWopEk7ZxT2fjpBLtXo/Uaredf3ZWXrZhduuG\nZVlQtmK+wRTVI1KUPieCMV6uuk+oxN52sMX/QahWHUsgXHwhWLFckf3Bddxl\nhPVTKh+DagmLXruJQh1YGklLrT8d83TzKcPy14gSaUjVtS85hpj26IinjX0Z\n6oJ3Ru0xaTZsfMPqNSKjzI7bTkshnkyXog2bUSV6+iyJm2pggieNhatUPbLZ\n7np3GMTiJQ14IMhzLbpN7mx8rIO7AK5xuCJjHyWYIY9L728GtXylCIU4xX4Q\nLQMobRWTdPqs+ky+d+lkt0HUY/+UMuXH96zd0T9cC7lvv4gGnEuxZlTbp3BJ\nAaiEbt6GH50GiZ1DA2xYShIfdecmTmh13jE5fyCb+oPg8Jbu6l/ZoDL6lR5a\nMgocySe6O+6rSutRTNVnxdvk5a0roZZHk9XJV2qmWbSGlMf8PNxKH00AIp+B\nohLhw0X1yLwvNaGbqsOFTfZcWBv5MnHN1Yal2Nf3smTkh7kxQ2Lf+nK0g4po\nCP4PY6Lt1Kt4yPAMfrsPrbLJUKb+sJjhfhVPQP/+QRM8JRKutRVMpCRovN6N\n6yBa\r\n=vhzj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWuHSk9vI3/KvNCXBbbkrA9i41FjmQRPmKL7BdBlEoCgIgV1QrveNE6FyP3uzRiOKGmWjfWZQXocrvz543Sj72FHk="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.2.0-pre.0_1631024689053_0.5536704154992678"},"_hasShrinkwrap":false},"2.2.0":{"name":"optics-ts","version":"2.2.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^3.3.1","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.2.0","dist":{"shasum":"978efa19e23f2a484bbbf82d9401930875223119","integrity":"sha512-1rkFaX3z7xqYsBSgOP9q8DDIidwWoUMr1dBa9m5gR0fNyEBELATo2W8VSZ6/mCJprJQTt3F1FLj3HDYTE7/P2Q==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.2.0.tgz","fileCount":112,"unpackedSize":130981,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhN3hWCRA9TVsSAnZWagAA5mAP/1tIIrcxeLx2lJLobL2/\nPHEvOUvp+ePZUUoRHaMKvrCLZd432kUtOFTFFWbgcAA5SlKyW0+gvbfIv20J\nsgwquuVGlb8d3oCki+BDK8bkjHhsPA/Y2OqQ2oSiJy+LRhpMTN42siHyjIEj\nqVGudt/pVcASnR30fFLwMpYvgTkkSUy4XlHspvFgYE0cTNqIJuwshf9ptanU\nlolujJk0/yOBankcfGMBD6bZEZeG8bHGhe1vxFFz4E7vbdJB95CjydvUwQpA\nZOhOsbg2Ycz3mgoWTog8wxLBPFw5mvHt+Z0AfuuTot44zxiD33do7JpG/ola\neY2NbzDXu3wpq+KTPZQQuWFmiH3hiUdKnXqMjWu/c32MGB9EIZu1aTZghGbi\nPXu6EpOwUAh4jLnMQmlpNqoEw6EDf52n0LRYpbSXgHiOO1Ensqh7Q7FkwoMh\nvSgxosihlm98HNcycp0htlfcSadq9vDypVUyYkUG0pIz8ZwUgLYQUL+VuFk7\nbU0FHe8BNvhpMt6G0eYLdGvon/443ZjXOXi3ZnVepSObW9cWvDLUQh1AQ0/+\nnKPXAKoywgXNFN2s9x5kvzSfE2AIigr5njc8Mk/wcUIV8NMLsCoePUYDfwID\n2e+jxa0XoDOaq8DH/Ir7/qdQGbjkP3DDikKLaMjsbSfNANuLOCUS//WCTKKA\nWwmo\r\n=zNNG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFVMTp7F6QQyfmaMya0AeHJSOaDSCnFqtmUGFzdaDRr3AiBDz35PExA285g6zTyEd3NzFMRhXiGM/ClobFXUsY8sEA=="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.2.0_1631025238496_0.2730859316485139"},"_hasShrinkwrap":false},"2.2.1":{"name":"optics-ts","version":"2.2.1","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.2.1","dist":{"shasum":"c5d003c4b801057968998e46d7115e6a824a0d88","integrity":"sha512-FL/h/U4C1BQBZt9dSPvc7ym2A6x+pC/EWnhzH1w0mR1NuYi/KIbFNwHBKViQCXTLLtk1SANizbjYrVt4+GVcJQ==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.2.1.tgz","fileCount":115,"unpackedSize":131603,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEyYTEiZGKE4swFysEifDgY543HotexDGbcfWqLdnTeTAiEA0mF3/XmRDTQvK3+zFaL8CO4Ef+ESqTgnhD5zQH70af8="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.2.1_1634927328170_0.2475280811486369"},"_hasShrinkwrap":false},"2.2.2":{"name":"optics-ts","version":"2.2.2","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.2.2","dist":{"shasum":"d145b507cf17998b7085a3e2dd62de7f20a22bb9","integrity":"sha512-FPylanPFrlXVcl/u9b6SJN0x1xHhXOGyEFm92vTTD0CHfvkswMDicRJHAowlXD1hqmxGR6MwA3jvAuPMHXcT4w==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.2.2.tgz","fileCount":115,"unpackedSize":131612,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDRz7rUD5aXUb2UzmQL3k6pCxZLOtnO1CvfMgeE/9Q9awIhANHW4GrmtD1mR/IBE233ZyYrppEhMbkDvXZrU1Xk4+Xh"}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.2.2_1634927442325_0.08093328431379931"},"_hasShrinkwrap":false},"2.3.0":{"name":"optics-ts","version":"2.3.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.3.0","dist":{"shasum":"5478da5a2ec46550093dfadd15d6bd87d957e925","integrity":"sha512-iu6//uEMAKsowlq7hd8pNTc43KOjxMPW60BBA8DIt0q311iiOaWPilMHGOyCDvQ7llRutwlCkGX6e4HnUD0ARg==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.3.0.tgz","fileCount":118,"unpackedSize":134896,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhxFobCRA9TVsSAnZWagAAek0QAJZLPHj1eoxeovUEcQT/\nVi+INnrolaNeUJs4qCXTzKvG3cioyWkGz6+I3v172ljv1gblVbs2d9Fyczdd\nB/K6WZjkR45JLGVwKkPJOEAX23GzGGCt/94oFK2Z9ikOKv3z6vzEY35NlqXs\ncetI4n6l7smX75J06xOldMUSjVTMiZzmUzesbrfV/zXjtLhHjqUZtJJ/E2jS\ndzsW8p3ppCK5O5oFfat/33PXUUFoKMXEf3WMVC3tK4DwS4giNxerHtxRNeSv\nMztA3HxnYH+EUdwq9Xo2a36X/fNFTvB2GSnKKepAzyKLF84DxjhXhgMVBaBl\nfrQ+g/z2hVWbpNthb2dAmZLhPuyhqnXSabRDyGZTyuVAV7qTLYLjRvOJ2d81\nkJa11x93Eo7WgQDSEp5m05B5ezb1jY0jjGgp0FVbSTFzAnLIiAjub+35+2ae\njwIK2cKbtE2Iuesh7RpRJpT7YaWKXS9/NFqgNm0Dtj0hHSm9x9N4ziqnygRP\nivQA+P1OWs3CD/XgWByrNDGcKrqiqiGwd46D0sfEW+UD5DBdX87nl6CvJzNW\nKGrXUJpZZFF4AdYKNtsgVzaDq6915iQG8GfEoeEqk6bRKDr89tiMrAvI8ldJ\nJWbvMI99XdYDV28uuvp7XJF5UAaMG6xeMtFQXuGeKo8KZ3R0PNcvStJpGA6H\nabpa\r\n=I53Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCy65bqcSapZEzhZmHoH9RGHAZGWlSUUuTvbiqqsSU41wIhAJP3os6e9oBn4stJbdu+Lk4T1Vt+8rnhSOgnrRPeF6NA"}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.3.0_1640258074936_0.26772698559220376"},"_hasShrinkwrap":false},"2.4.0":{"name":"optics-ts","version":"2.4.0","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^27.0.1","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","jest":"^27.0.6","prettier":"^2.2.1","ts-jest":"^27.0.5","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.4.0","dist":{"shasum":"b23d177a76de66fdec9a832eefbd43458a91953e","integrity":"sha512-BIYgnqOTEf+WiXuxuBFXeoCtyIDOwnUwCMybdQh8qdHyWXunwVVt7iD9XwNq8SCd5vUo9vqgYxF5ati/6inIuQ==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.4.0.tgz","fileCount":121,"unpackedSize":137526,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFbq7a+E9zoCxen+gZxMkosEcDNW6Yl9E7oVmp0ltwxtAiEAnQko89STRoJZRSo5hzN/50gDe46hOxocSDj4hkKxdnw="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjZBB1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpS8g//a2lsPxqtwOyhoL3JUqRg/loQ5uuBuR3kWkHPNHHF5Z6lZeBH\r\nEDtHq+R77/cqoyYn4XQ0Ixxw+4Lqcz/i58Htp6l/mUJrLZG+q/paNdHZXcV8\r\nViPEPeEuTGC9Rbce2L+Us2vS6fY+r4byPNQUSI2X5U6x3AFVaO5x6j0gWBkM\r\n/PFvsf7Ncz5GxVgY9tGGxKTXyfhej9jqC7V5kgIvKo3KitCqbFjD7pqxN4vi\r\nqLdobCL3z2US0PUJKr7fY2FuqBwXS5ySEOjrBYwmwRbhhWBId3eQVrmtBVr+\r\nLGq9wCwAxc3U1OFqYQDf+Yj85wA0xIWpBOFY4ropnXLbGLvHLZfHJ85VESrM\r\nm/B/G9OmGN1H3UFvjCtntolrBk/6Bx+OsFOESrO2DFOc+9HWaKK+cMThzeQn\r\nEbewzGg/PqcgWxuBZqXtk7KLiMEqmzzm2ySNShO4H2RXg9zAMx7Enccart7r\r\n6SpmoOeSqvq6RTRCulC9wIpRaWGhTFhCtzwSlKrA4qJU0IZUw+SNbO8kOVQy\r\nyeZOkjr5F60WCY8D1xnu60MWiFgiN9gEFIRrernO1v52wWFEn31Kb/WDsqZ8\r\n4KUVvDEk5faPRBCeS/OVmdz0aG755KOf0bfrnyHo6xTL+ZYALvFp/4Il75ej\r\nERI2Pu19lBso96squ2vpxYn22RZUZokD68E=\r\n=GuvA\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.4.0_1667502197176_0.44419675871500286"},"_hasShrinkwrap":false},"2.4.1":{"name":"optics-ts","version":"2.4.1","description":"Type-safe, ergonomic, polymorphic optics for TypeScript","repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"},"license":"MIT","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"main":"./dist/cjs/index.js","exports":{".":{"types":"./index.d.ts","import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"},"./standalone":{"types":"./standalone/index.d.ts","import":"./dist/mjs/standalone/index.js","require":"./dist/cjs/standalone/index.js"},"./interop":{"types":"./interop.d.ts","import":"./dist/mjs/interop.js","require":"./dist/cjs/interop.js"}},"scripts":{"typecheck":"tsc --noEmit","build":"yarn build:cjs && yarn build:mjs && yarn build:typings && scripts/fixup","build:cjs":"tsc -p tsconfig.cjs.json","build:mjs":"tsc -p tsconfig.mjs.json","build:typings":"tsc -p tsconfig.typings.json","build:test":"tsc -p tsconfig.test.json","test":"yarn build:test && jest","clean":"rm -rf dist/ dist-test/ standalone/ *.d.ts","lint":"eslint --max-warnings 0 '**/*.ts' && prettier --check \"**/*.{json,md}\"","lint:fix":"eslint --fix '**/*.ts' && prettier --write '**/*.{json,md}'","prepublishOnly":"yarn run clean && yarn run build","generate-index":"ts-node ./scripts/generate-index.ts > src/index.ts && prettier --write src/index.ts"},"devDependencies":{"@babel/types":"^7.12.1","@types/jest":"^29.5.2","@typescript-eslint/eslint-plugin":"^4.14.0","@typescript-eslint/parser":"^4.14.0","eslint":"^7.18.0","eslint-config-prettier":"^8.1.0","eslint-plugin-prettier":"^4.0.0","jest":"^29.5.0","prettier":"^2.2.1","ts-jest":"^29.1.0","typescript":"^4.1.2"},"licenseText":"MIT License\n\nCopyright (c) 2020 Petri Lehtinen\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"optics-ts@2.4.1","dist":{"shasum":"de94bda2b0ed7fde5b7631283031b9699459d40d","integrity":"sha512-HaYzMHvC80r7U/LqAd4hQyopDezC60PO2qF5GuIwALut2cl5rK1VWHsqTp0oqoJJWjiv6uXKqsO+Q2OO0C3MmQ==","tarball":"https://registry.npmjs.org/optics-ts/-/optics-ts-2.4.1.tgz","fileCount":121,"unpackedSize":137072,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBSLxAUy152E8r3jfyIycwV3Mf2Pgah14ccZh2BpjkC8AiEAz9Y2Xnz3LR2F4gwTSFXg57rePSSXzao8er+Me5Qgt6Q="}]},"_npmUser":{"name":"akheron","email":"petri@digip.org"},"directories":{},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/optics-ts_2.4.1_1689013508044_0.6728244724360708"},"_hasShrinkwrap":false}},"time":{"created":"2020-01-09T19:49:03.823Z","0.1.0":"2020-01-09T19:49:04.027Z","modified":"2023-07-10T18:25:08.403Z","1.0.0-rc1":"2020-04-18T04:41:58.153Z","1.0.0":"2020-04-23T17:47:37.287Z","1.1.0-pre.1":"2020-04-29T19:29:13.397Z","1.1.0-pre.2":"2020-05-02T04:46:36.291Z","1.1.0-pre.3":"2020-05-02T18:51:43.194Z","1.1.0":"2020-05-05T18:26:40.902Z","1.2.0":"2020-10-30T20:00:37.946Z","2.0.0":"2020-12-01T17:54:07.540Z","2.1.0":"2021-03-27T19:24:18.301Z","2.2.0-pre.0":"2021-09-07T14:24:49.254Z","2.2.0":"2021-09-07T14:33:58.621Z","2.2.1":"2021-10-22T18:28:48.409Z","2.2.2":"2021-10-22T18:30:42.495Z","2.3.0":"2021-12-23T11:14:35.079Z","2.4.0":"2022-11-03T19:03:17.339Z","2.4.1":"2023-07-10T18:25:08.275Z"},"maintainers":[{"name":"akheron","email":"petri@digip.org"}],"description":"Type-safe, ergonomic, polymorphic optics for TypeScript","license":"MIT","readme":"# optics-ts\n\n[![Build](https://github.com/akheron/optics-ts/workflows/tests/badge.svg)](https://github.com/akheron/optics-ts/actions/workflows/tests.yml)\n\n`optics-ts` provides type-safe, ergonomic, polymorphic optics for TypeScript:\n\n- **Optics** allow you to read or modify values from deeply nested data\n  structures, while keeping all data immutable.\n- **Ergonomic**: Optics are composed with method chaining, making it easy and\n  fun!\n- **Polymorphic**: When writing through the optics, you can change the data\n  types in the nested structure.\n- **Type-safe**: The compiler will type check all operations you do. No `any`,\n  ever.\n\n➡ [Documentation](https://akheron.github.io/optics-ts) ⬅\n\n## Features\n\n`optics-ts` supports lenses, prisms, traversals, removing items from containers,\nand much more!\n\nSince optics-ts v2.2.0, there are two syntaxes for defining optics: method\nchaining (the default) and standalone optics (experimental). See\n[the docs](https://akheron.github.io/optics-ts) for more info!\n\n## Getting started\n\nInstallation:\n\n```\nnpm install optics-ts\n```\n\nor\n\n```\nyarn add optics-ts\n```\n\nHere's a simple example demonstrating how lenses can be used to drill into a\nnested data structure:\n\n```typescript\nimport * as O from 'optics-ts'\n\ntype Book = {\n  title: string\n  isbn: string\n  author: {\n    name: string\n  }\n}\n\n// Create a lens that focuses on author.name\nconst optic = O.optic_<Book>().prop('author').prop('name')\n\n// This is the input data\nconst input: Book = {\n  title: \"The Hitchhiker's Guide to the Galaxy\",\n  isbn: '978-0345391803',\n  author: {\n    name: 'Douglas Adams',\n  },\n}\n\n// Read through the optic\nO.get(optic)(input)\n// \"Douglas Adams\"\n\n// Write through the optic\nO.set(optic)('Arthur Dent')(input)\n// {\n//   title: \"The Hitchhiker’s Guide to the Galaxy\"\n//   isbn: \"978-0345391803\",\n//   author: {\n//     name: \"Arthur Dent\"\n//   }\n// }\n\n// Update the existing value through the optic, while also changing the data type\nO.modify(optic)((str) => str.length + 29)(input)\n// {\n//   title: \"The Hitchhiker’s Guide to the Galaxy\"\n//   isbn: \"978-0345391803\",\n//   author: {\n//     name: 42\n//   }\n// }\n```\n\nAnother example that converts all words longer than 5 characters to upper case:\n\n```typescript\nimport * as O from 'optics-ts/standalone'\n\nconst optic = O.optic<string>().words().when(s => s.length >= 5)\n\nconst input = 'This is a string with some shorter and some longer words'\nO.modify(optic)((s) => s.toUpperCase()(input)\n// \"This is a STRING with some SHORTER and some LONGER WORDS\"\n```\n\nSee the [documentation](https://akheron.github.io/optics-ts) for a tutorial and\na detailed reference of all supported optics.\n\n## Development\n\nRun `yarn` to install dependencies.\n\n### Running the test suite\n\nRun `yarn test`.\n\nFor compiling and running the tests when files change, run these commands in\nseparate terminals:\n\n```\nyarn build:test --watch\nyarn jest dist-test/ --watchAll\n```\n\n### Documentation\n\nYou need Python 3 to build the docs.\n\n```\npython3 -m venv venv\n./venv/bin/pip install mkdocs-material\n```\n\nRun a live reloading server for the documentation:\n\n```\n./venv/bin/mkdocs serve\n```\n\nOpen http://localhost:8000/ in the browser.\n\n### Releasing\n\n```\n$ yarn version --new-version <major|minor|patch>\n$ yarn publish\n$ git push origin main --tags\n```\n\nOpen https://github.com/akheron/optics-ts/releases, edit the draft release,\nselect the newest version tag, adjust the description as needed.\n","readmeFilename":"README.md","keywords":["optics","lens","prism","traveral","isomorphism","immutable","functional-programming"],"repository":{"type":"git","url":"https://github.com/akheron/optics-ts"},"author":{"name":"Petri Lehtinen","email":"petri@digip.org"}}