0.1.6 • Published 11 years ago

o-shiny v0.1.6

Weekly downloads
2
License
-
Repository
github
Last release
11 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

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago