1.0.0 • Published 8 years ago

object-limiter v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

#object-limiter.js

Delete properties from an object which are not specified in the list

Installation

$ npm install object-limiter

Usage

var limiter=require('object-limiter');

var obj={
	name:'John',
	surname:'Doe',
	email:'johndoe@example.com',
	website:'example.com',
	password:'secret',
};

####limitTo(object, propertyNames:String) Outputs new object with the given property names.

  • object: Javascript Object
  • propertyNames: Comma Separated property names //ex:'name, surname'
console.log( limiter.limitTo(obj,'name, email') );
/* Outputs:
{  
    name:'John',
    email:'johndoe@example.com'
}
*/

####limitFrom(object, propertyNames:String) Outputs new object with properties from source but without the given property names.

  • object: Javascript Object
  • propertyNames: Comma Separated property names //ex:'name, surname'
console.log( limiter.limitFrom(obj,'password') );
/* Outputs:
{  
    name:'John',
    surname:'Doe',
    email:'johndoe@example.com',
    website:'example.com'
}
*/