You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fn-object

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fn-object

map and filter for object's keys and values, and get a modified object

0.2.4
latest
Source
npmnpm
Version published
Weekly downloads
11
1000%
Maintainers
1
Weekly downloads
 
Created
Source

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
  }
*/

Keywords

functional

FAQs

Package last updated on 03 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts