object-conform
object-conform allows you to ensure that objects conform to a model.
Installation
npm install --save object-conform
Usage
The module exports a single function: conform
var conform = ; var model = foo: 'foo' bar: 1 2 3 baz: yak: true emu: false ; var object = extraneous: true foo: 'otherfoo' baz: yak: true emu: false extraneous: true ; var conformed = ; console;
This will result in a conformed object, with extraneous fields removed and missing fields added, but with existing fields shared with the model preserved:
{ "foo": "otherfoo", "bar": [ 1, 2, 3 ], "baz": { "yak": true, "emu": false }}
Contributing
Pull requests are very welcome! Just make sure your code:
-
Passes jshint given the included .jshintrc
-
Is beautified using jsbeautifier and the included .jsbeautifyrc
Why?
I wanted a simple, reusable way to ensure objects conformed to basic models.
CHANGELOG
v0.1.0
- Initial release.