1.0.0 • Published 8 years ago
6b2f7cba85b3b7129e74b5db7b1a23df v1.0.0
DataBind
Module used for data binding between a javascript object (provider) and a string (consumer), saves the synchronized data into a new object.
Installation
$ npm install 6b2f7cba85b3b7129e74b5db7b1a23df --save
function dataBind(map, scope)
Params
- (string)
map
: The string template, a valid javascript object - (object)
scope
: The data object
Returns
Object
with same format asmap
parameter orfalse
if an error occursfalse
if a property is not defined in thescope
object and themap
string requires it or if themap
string has an incorrect syntax
Example:
var dataBind = require('6b2f7cba85b3b7129e74b5db7b1a23df')
var map = '{Data: {property1: data.prop}, Other: {propertyN: other.data} }'
var scope = {
'data': {
'prop': 'VALUE 1'
},
'other': {
'data': 'VALUE 2'
}
}
var result = dataBind(map, scope)
The result variable will contain
{
"Data": {
"property1": "VALUE 1"
},
"Other": {
"propertyN": "VALUE 2"
}
}
Other info
Publish package, runs test tasks when the code changes
$ gulp
Unit tests and code coverage tasks
$ gulp test
1.0.0
8 years ago