- Notifications
You must be signed in to change notification settings - Fork13
DrBoolean/lenses
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Functional lenses that compose and stuff
require('./src/lenses').expose(global);varcompose=require('pointfree-fantasy').compose;// setup an easy test fnvartoUpperCase=function(x){returnx.toUpperCase();};// here's the data structurevaruser={name:"Bob",addresses:[{street:'99 Maple',zip:94004,type:'home'},{street:'2302 Powell',zip:94001,type:'work'}]}// make some lensesvarL=makeLenses(['name','addresses','street']);// compose the lensesvarsecondAddressesStreet=compose(L.addresses,L._num(2),L.street)// mess with the userover(secondAddressesStreet,toUpperCase,user)// { name: 'Bob', addresses: [ { street: '99 Maple', zip: 94004, type: 'home' }, { street: '2302 POWELL', zip: 94001, type: 'work' } ]}view(L.name,user)// 'Bob'set(L.name,'Kelly',user)// {name: "Kelly", addresses: [{street: '99 Maple', zip: 94004, type: 'home'}, {street: '2302 Powell', zip: 94001, type: 'work'}]}
For those not already familiar with lenses, a brief introduction can be foundhere
ROADMAP:
- add traverses and folds
- more combinators
- prisms
- this list is getting long...
About
Composable kmett style lenses
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.