node package manager

sanitize-object

ūüíä sanitize-object

NPM Version node Build Status

Experimental JS Object cleanup

Installation

$ npm install sanitize-object

Example

const { exclude, only } = require('sanitize-object/exclude')
 
const sanitizeUser = exclude('password', 'id')
const result = sanitizeUser({id: 42, name: 'Rupert', password: 'qwerty'})
// result: { name: 'Rupert'} 
 
const sanitizeUser = only('name')
const result = sanitizeUser({id: 42, name: 'Rupert', password: 'qwerty'})
// result: { name: 'Rupert'}