Skip to content

functional programming helpers to be used with object's keys and values

Notifications You must be signed in to change notification settings

tjmehta/fn-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED - use tjmehta/object-loops

fn-object

Build Status dependency status dev dependency status

map and filter for object keys and values

Map an Object's values

var fno = require('fn-object');
var obj = {
  key: 'val'
};

fno(obj).vals
  .map(function (val) {
    return val+'1';
  })
  .val()
/*
  {
    key: 'val1'
  }
*/

Filter an Object's values

var fno = require('fn-object');
var obj = {
  foo: true,
  bar: true,
  qux: false
};

fno(obj).vals
  .filter(function (val) {
    return val;
  })
  .val()
/*
  {
    foo: true,
    bar: true
  }
*/

Map an Object's keys

var fno = require('fn-object');
var obj = {
  key: 'val'
};

fno(obj).keys
  .map(function (key) {
    return key+'1';
  })
  .val()
/*
  {
    key1: 'val'
  }
*/

Filter an Object's keys

var fno = require('fn-object');
var obj = {
  key : true,
  key2: true,
  foo : true
};

fno(obj).keys
  .filter(function (key) {
    return key.indexOf('key') === 0;
  })
  .val()
/*
  {
    key : true,
    key2: true
  }
*/

About

functional programming helpers to be used with object's keys and values

Resources

Stars

Watchers

Forks

Packages

No packages published