/extrode

simple key extractor for objects and arrays

Primary LanguageJavaScriptMIT LicenseMIT

extrode

Build Status Coverage Status npm version

A small library that extracts specified keys from a single object or objects in an array.

Installation

npm install extrode

Usage

  • Example usage for object arrays:
var extrode = require('extrode');
var dirtyArray = [{ x: 1, y: 2 }, { x: 3, y: 4 }, { x: 5, y: 6}];

var result = extrode(dirtyArray, ['x']);

Output should be [{ x: 1 }, { x: 3 }, { x: 5 }]

  • Example usage for a single object:
var extrode = require('extrode');
var dirtyObject = { x: 1, y: 2 };

var result = extrode(dirtyObject, ['x']);

Output should be { x: 1 }

Tests

npm test

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.