0.1.6 • Published 9 years ago

o-shiny v0.1.6

Weekly downloads
2
License
-
Repository
github
Last release
9 years ago

o-shiny

Build Status

Removes inherited properties, nulls, functions as well as empty strings, arrays and objects from JavaScript objects.

Installation

npm install o-shiny

Usage

Using an object as input

var shine = require('o-shiny');

var object = {
    keyA: '',
    keyB: {},
    keyC: []
    keyD: null,
    keyE: function() {},
    keyF: 'o-shiny'
};

var shinyObject = shine(object);

Result

{
    keyF: 'o-shiny'
}

Using a JSON string as input

var json = '{"key": "o-shiny"}';

var shinyObject = shine(json);

Result

{
    key: 'o-shiny'
}

Options

By default, shine will remove inherited properties, nulls, functions as well as empty strings, arrays and objects. They may all be individually overriden.

Defaults

var allow = {
    hasOwnProperty: true,
    nulls: false,
    functions: false,
    emptyStrings: false,
    emptyArrays: false,
    emptyObjects: false,
    blacklist: [],
    whitelist: []
};

blacklist: an array of keys to remove even if their content is otherwise valid

whitelist: an array of keys to leave in the resulting object, except if their content is invalid

Tests

mocha
0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago