Attributa
Assign attributes to this
with just one line!
Installation
Run
$ npm install --save attributa
Usage
assign()
attributa.assign(obj, data)
obj
: the object you want to assign the valuesdata
: the data that you want to use to assign value
var attributa = ; var data = username: 'jasoki' password: 'password' email: 'email@gmail.com' city: 'Toronto' country: 'Canada' age: 27; var { ;};var user = data; // user// { username: 'jasoki',// password: 'password',// email: 'email@gmail.com',// city: 'Toronto',// country: 'Canada',// age: 27 }
only()
attributa.only(obj, data, attributes)
obj
: the object you want to assign the valuesdata
: the data that you want to use to assign valueattributes
: attribute(s) that you want to assign the value to. accepts a string or an array.
only() for one attribute
var attributa = ; var data = username: 'jasoki' password: 'password' email: 'email@gmail.com' city: 'Toronto' country: 'Canada' age: 27; var { attributa;};var user = data; // user// { username: null,// password: 'password',// email: null,// city: null,// country: null,// age: null }
only() for multiple attributes
var attributa = ; var data = username: 'jasoki' password: 'password' email: 'email@gmail.com' city: 'Toronto' country: 'Canada' age: 27; var { attributa;};var user = data; // user// { username: null,// password: 'password',// email: null,// city: null,// country: null,// age: 27 }
except()
attributa.except(obj, data, attributes)
obj
: the object you want to assign the valuesdata
: the data that you want to use to assign valueattributes
: attribute(s) that you want to assign the value to. accepts a string or an array.
except() for one attribute
var attributa = ; var data = username: 'jasoki' password: 'password' email: 'email@gmail.com' city: 'Toronto' country: 'Canada' age: 27; var { attributa;};var user = data; // user// { username: null,// password: 'password',// email: 'email@gmail.com',// city: 'Toronto',// country: 'Canada',// age: 27 }
except() for multiple attributes
var attributa = ; var data = username: 'jasoki' password: 'password' email: 'email@gmail.com' city: 'Toronto' country: 'Canada' age: 27; var { attributa;};var user = data; // user// { username: null,// password: null,// email: 'email@gmail.com',// city: 'Toronto',// country: 'Canada',// age: 27 }