Partial.lenses
Partial lenses is a comprehensive, high-performance optics library for JavaScript
Install / Use
/learn @calmm-js/Partial.lensesREADME
<a id="partial-lenses"></a> ≡ ▶ Partial Lenses ·

Lenses are basically an abstraction for simultaneously specifying operations to update and query immutable data structures. Lenses are highly composable and can be efficient. This library provides a rich collection of partial isomorphisms, lenses, and traversals, collectively known as optics, for manipulating JSON and users can write new optics for manipulating non-JSON objects, such as Immutable.js collections. A partial lens can view optional data, insert new data, update existing data and remove existing data and can, for example, provide defaults and maintain required data structure parts. Try Lenses!
<a id="contents"></a> ≡ ▶ Contents
- Tutorial
- The why of optics
- Reference
- Stable subset
- Additional libraries
- Optics
- On partiality
- On indexing
- On immutability
- On composability
- On lens laws
- Operations on optics
L.assign(optic, object, maybeData) ~> maybeData<small><sup>v11.13.0</sup></small>L.disperse(optic, [...maybeValues], maybeData) ~> maybeData<small><sup>v14.6.0</sup></small>L.modify(optic, (maybeValue, index) => maybeValue, maybeData) ~> maybeData<small><sup>v2.2.0</sup></small>L.modifyAsync(optic, (maybeValue, index) => maybeValuePromise, maybeData) ~> maybeDataPromise<small><sup>v13.12.0</sup></small>L.remove(optic, maybeData) ~> maybeData<small><sup>v2.0.0</sup></small>L.set(optic, maybeValue, maybeData) ~> maybeData<small><sup>v1.0.0</sup></small>L.traverse(algebra, (maybeValue, index) => operation, optic, maybeData) ~> operation<small><sup>v10.0.0</sup></small>
- Nesting
L.compose(...optics) ~> opticor[...optics]<small><sup>v1.0.0</sup></small>L.flat(...optics) ~> optic<small><sup>v13.6.0</sup></small>
- Recursing
L.lazy(optic => optic) ~> optic<small><sup>v5.1.0</sup></small>
- Adapting
L.choices(optic, ...optics) ~> optic<small><sup>v11.10.0</sup></small>L.choose((maybeValue, index) => optic) ~> optic<small><sup>v1.0.0</sup></small>- <a href="#l-cond" title="L.cond: (...[(Maybe s, Index) -> Boolean, POptic s a][, [POptic s a]]) -> POptic s a"><code>L.cond(...[(maybeValue, index) => testable, consequentOptic][, [alternativeOptic]]) ~> optic</code></a> <small><sup>v13.1.0</sup></small>
- <a href="#l-condof" title="L.condOf: (PTraversal s c, ...[(Maybe c, Index) -> Boolean, POptic s a][, [POptic s a]]) -> POptic s a"><code>L.condOf(traversal, ...[(maybeValue, index) => testable, consequentOptic][, [alternativeOptic]]) ~> optic</code></a> <small><sup>v13.5.0</sup></small>
L.ifElse((maybeValue, index) => testable, optic, optic) ~> optic<small><sup>v13.1.0</sup></small>L.orElse(backupOptic, primaryOptic) ~> optic<small><sup>v2.1.0</sup></small>
- Indices
L.joinIx(optic) ~> optic<small><sup>v13.15.0</sup></small>L.mapIx((index, maybeValue) => index) ~> optic<small><sup>v13.15.0</sup></small>L.reIx(optic) ~> optic<small><sup>v14.10.0</sup></small>L.setIx(index) ~> optic<small><sup>v13.15.0</sup></small>L.skipIx(optic) ~> optic<small><sup>v13.15.0</sup></small>L.tieIx((innerIndex, outerIndex) => index, optic) ~> optic<small><sup>v13.15.0</sup></small>
- Debugging
L.getLog(lens, maybeData) ~> maybeValue<small><sup>v13.14.0</sup></small>L.log(...labels) ~> optic<small><sup>v3.2.0</sup></small>
- Internals
L.Identity ~> Monad<small><sup>v13.7.0</sup></small>L.IdentityAsync ~> Monadish<small><sup>v13.12.0</sup></small>L.Select ~> Applicative<small><sup>v14.0.0</sup></small>L.toFunction(optic) ~> optic<small><sup>v7.0.0</sup></small>
- Transforms
- Operations on transforms
L.transform(optic, maybeData) ~> maybeData<small><sup>v11.7.0</sup></small>L.transformAsync(optic, maybeData) ~> maybeDataPromise<small><sup>v13.12.0</sup></small>
- Sequencing
L.seq(...transforms) ~> transform<small><sup>v9.4.0</sup></small>
- Transforming
L.appendOp(value) ~> traversal<small><sup>v14.14.0</sup></small>L.assignOp(object) ~> traversal<small><sup>v11.13.0</sup></small>L.modifyOp((maybeValue, index) => maybeValue) ~> traversal<small><sup>v11.7.0</sup></small>L.prependOp(value) ~> traversal<small><sup>v14.14.0</sup></small>L.removeOp ~> traversal<small><sup>v11.7.0</sup></small>- [
L.setOp(maybeValue) ~> traversal](#l-setop 'L.setOp: Maybe
- Operations on transforms
Related Skills
node-connect
337.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.3kCommit, push, and open a PR
