data-lens
javascript implementation of data-lens
Last updated 5 years ago by yyoud88 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install data-lens 
SYNC missed versions from official npm registry.

data-lens

Simple JavaScript implementation of data-lens

Usage

Lens = require('data-lens');

// Basic use
lens = new Lens(getter, setter);

lens.get(data); // === getter(data)
lens.set(val, data); // === setter(val, data)

// Chaining
lens1.then(lens2).get(data);
lens1.then(lens2).set(val, data);
lens1.key(key1).key(key2).index(index1).index(index2)...;

// Convenience methods
Lens.index(0).get([1,2,3]); // 1
Lens.index(0).set(3, [1,2,3]); // [3, 2, 3]

Lens.key('a').get({a: 1}); // 1
Lens.key('a').set(3, {a: 1}); // {a: 3}

Lens.path('a.b').get({a: {b: 1}}); // 1
Lens.path('a.b').set(3, {a: {b: 1}}); // {a: {b: 3}}

Lens.compose(lens1, lens2); // Equivalent to lens1.then(lens2)

Current Tags

  • 0.0.14                                ...           latest (5 years ago)

13 Versions

  • 0.0.14                                ...           5 years ago
  • 0.0.13                                ...           5 years ago
  • 0.0.12                                ...           5 years ago
  • 0.0.11                                ...           5 years ago
  • 0.0.10                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |