0.0.3 • Published 9 years ago
use-this v0.0.3
use-this
Just some underscore implementations.
Possible use:
var person = [
{name: { first: 'Gian', last: 'Febrian' } },
{name: { first: 'Suci', last: 'Alfia' } }
];
To get nested property value
useThis(person).getThis('name.first', 0); //Gian
useThis(person).getThis('name.first', 0); //Suci
To pluck nested property value
useThis(person).pluckThis('name.first');
//['Gian', 'Suci']
To pair property value
useThis(person).pairThese('name.first', 'name.last');
//{Gian: 'Febrian', Suci: 'Alfia'}
To fill template object
var template = { fullName: '{name.first} {name.last}' }
var pattern = {
'name.first': {value: 'propertyValue'},
'name.last': {value: 'propertyValue'}}
useThis(person).fillThisTemplate(template, pattern);
//[ { fullName: 'Gian Febrian' }, { fullName: 'Suci Alfia' } ]