1.0.0 • Published 8 years ago

6b2f7cba85b3b7129e74b5db7b1a23df v1.0.0

Weekly downloads
1
License
-
Repository
-
Last release
8 years ago

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 as map parameter or false if an error occurs
  • false if a property is not defined in the scope object and the map string requires it or if the map 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