Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ruanyl/ensure-keys


https://github.com/ruanyl/ensure-keys

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

ensure-keys
========
[![build status](https://secure.travis-ci.org/ruanyl/ensure-keys.svg)](http://travis-ci.org/ruanyl/ensure-keys)
[![NPM version](https://badge.fury.io/js/ensure-keys.svg)](http://badge.fury.io/js/ensure-keys)

ensure a json has specific keys

## Installation

This module is installed via npm:

``` bash
$ npm install ensure-keys --save
```

## Example Usage

``` js
var ensureKeys = require('ensure-keys');

var json = {
name: 'bigruan',
age: 12,
child: {
name: 'yulong',
age: 1
}
}
// return the keys that not exists or has value: undefined, null and ''
ensureKeys(json, ['name', 'job', 'child.name']); // -> ['job']
```