empowerjs
v0.0.1
Published
Empower regular JavaScript objects with shorthand routines
Readme
empower.js
Empower regular JavaScript objects with shorthand routines
Getting Started
empower.js works in Node and browsers, and supports amd loaders.
Install it via NPM:
npm install empowerjsor with Bower:
bower install empowerjsFunctions
Empower(object|string|number|array|function)
Creates an empowered version of the passed object
var man = {
name: 'superman',
age: 29,
spouse: undefined,
faceMask: null,
species: 'kryptonians',
father: {
name: 'Zor-El'
},
category: 'superhero',
grow: function() {
this.age++;
}
};
$man = Empower(man);
$man.value(); //return original man object
$man.name; //superman
$man.clean(); //man = {name: 'superman'}; (undefined and null values removed)
$man.$name.spaceOut(); // man.name = s u p e r m a n
$man.$name.reverse(); // man.name = n a m r e p u s
$man.$father.$name.reverse(); // man.father.name = 'lE-roZ'
$man.$species.singularize(); // man.species = 'kryptonian'
$man.$category.pluralize(); // man.category = 'heroes'
$man.$grow.run(); // man.age = 30
$man.$grow.runEvery(2000); // will run man.grow() every 2 seconds
$man.$grow.cancelRuns(); // will cancel previous periodic runDocumentation
Coming soon.
Running the tests
empower.js comes with automated tests that can be run by installing devDependencies and running:
npm testContributing
Please feel free to add more functions to the suite and submit pull requests to us. If you have a better version of an existing function, that will be highly valued, too.
Authors
- Riten Vagadiya ritenv
License
This project is licensed under the MIT License - see the LICENSE.md file for details
