observify-varhash
converts JS objects into their observable equivalents using observ
Last updated 6 years ago by dguttman .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install observify-varhash 
SYNC missed versions from official npm registry.

observify-varhash

This is just a fork of observify, but uses observ-varhash for objects instead of observ-struct so that keys can be added and removed.

Converts JS objects into their observable equivalents using observ, observ-array and observ-varhash. Designed for use with mercury

NPM

installation

npm install observify-varhash

usage

var observify = require('observify-varhash')
var data = observify({
  "foo": "bar",
  "cats": ["taco", "burrito"],
  "age": 82
})

is equivalent to doing:

var array = require('observ-array')
var varhash = require('observ-varhash')
var value = require('observ')

var data = varhash({
  "foo": value("bar"),
  "cats": array([value("taco"), value("burrito")]),
  "age": value(82)
})

blacklisted properties

observ-varhash has a blacklist of property names that cannot be used as keys (as they clash with javascript reserved words).

You can pass an options object with a autoRename property to tell observify to rename these properties.

var observify = require('observify-varhash')
var data = observify({
  "name":"I'm bad, I'm bad, you know it",
  "comment":"I am OK"
}, {
  autoRename:'$'
})

console.log(data())

This would print:

{
  $name:"I'm bad, I'm bad, you know it",
  comment:"I am OK"
}

If autoRename is true it will default to $.

Current Tags

  • 1.1.1                                ...           latest (6 years ago)

2 Versions

  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |