Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruanyl/ensure-keys
https://github.com/ruanyl/ensure-keys
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ruanyl/ensure-keys
- Owner: ruanyl
- License: mit
- Created: 2015-03-17T21:18:56.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-18T20:45:10.000Z (almost 10 years ago)
- Last Synced: 2024-12-05T17:16:11.688Z (about 2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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']
```