@nuware/lenses

Functional Lenses

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
10Nov 23, 2018Jul 28, 2018Minified + gzip package size for @nuware/lenses in KB

Readme

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.