Skip to content
/ funo Public

Small library implementing such function as map, filter, reduce for objects

License

Notifications You must be signed in to change notification settings

gwer/funo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Funo

Funo implements map, filter, reduce and other functions for objects handling.

In the JS core these functions are implemented only for arrays. Such libraries as underscore and lodash can work with objects, but they return an array. Thus the information stored in the keys of the original object is lost. Funo solves this problem.

Install

Node.js

npm install funo
var funo = require('funo')

Browser

First download funo.js, then include it on the page:

<script src="funo.js"></script>

Usage

var a = {
    port4: { alias: 'LAN4', isWan: false },
    port3: { alias: 'LAN3', isWan: false },
    port2: { alias: 'LAN2', isWan: false },
    port1: { alias: 'LAN1', isWan: false },
    wifi1: { alias: 'WiFi', isWan: false },
    internet: { alias: 'WAN', isWan: true }
}
console.log(funo.map(a, port => port.alias))
/*{
    port4: 'LAN4',
    port3: 'LAN3',
    port2: 'LAN2',
    port1: 'LAN1',
    wifi1: 'WiFi',
    internet: 'WAN'
}*/

console.log(funo.filter(a, port => port.isWan))
/*{
    internet: { alias: 'WAN', isWan: true }
}*/

Version

0.5.0

About

Small library implementing such function as map, filter, reduce for objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published