@nuware/lenses

0.1.15 • Public • Published

Lenses

Install

npm install @nuware/lenses --save

or

<script defer src="https://unpkg.com/@nuware/lenses@latest/dist/lenses.umd.js"></script>

or

<script defer src="https://unpkg.com/@nuware/lenses@latest/dist/lenses.min.js"></script>

Usage

Browser

const { Prop, Get, Set, Over, Focus } = window.nuware.L

Node

const { Prop, Get, Set, Over, Focus } = require('@nuware/lenses')

or

import { Prop, Get, Set, Over, Focus } from '@nuware/lenses'

Example

const NameLens = Prop('name')
const NestedLens = Focus(['a', 'b', 'c'])

const a = Set(NameLens)('Value')({})                      // {name: 'Value'}
const b = Get(NameLens)(a)                                // 'Value'
const c = Over(NameLens)((val) => val.toLowerCase()))(a)  // {name: 'value'}

const d = Set(NestedLens)(true)(c)                        // {name: 'value', a: {b: {c: true}}}
const e = Over(NestedLens)((val) => !val))(d)             // {name: 'value', a: {b: {c: false}}}

API

Comming soon...

Authors

Readme

Keywords

Package Sidebar

Install

npm i @nuware/lenses

Weekly Downloads

1

Version

0.1.15

License

MIT

Unpacked Size

8.36 kB

Total Files

7

Last publish

Collaborators

  • outbreak