expressions-js
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "expressions-js", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Converts simplified JavaScript expressions into executable functions for JavaScript frameworks.", | ||
@@ -24,6 +24,3 @@ "keywords": [ | ||
}, | ||
"licenses": { | ||
"type": "MIT", | ||
"url": "git://github.com/chip-js/expressions-js/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -30,0 +27,0 @@ "test": "mocha test" |
@@ -11,2 +11,8 @@ # Expressions.js | ||
To install Expressions.js you can use npm. | ||
``` | ||
npm install expressions-js | ||
``` | ||
`parse(expr)` will return a function that can be executed against any context and will return the results. | ||
@@ -13,0 +19,0 @@ |
@@ -28,3 +28,3 @@ var referenceCount = 0; | ||
// matches property chains (e.g. `name`, `user.name`, and `user.fullName().capitalize()`) | ||
var propertyRegex = /((\{|,|\.)?\s*)([a-z$_\$](?:[a-z_\$0-9\.-]|\[['"\d]+\])*)(\s*(:|\(|\[)?)|(\[)/gi; | ||
var propertyRegex = /((\{|,|\.)?\s*)([a-z$_\$](?:[a-z_\$0-9\.-]|\[['"\d]+\])*)(\s*(:|\(|\[)?)/gi; | ||
/** | ||
@@ -31,0 +31,0 @@ * Broken down |
@@ -143,2 +143,10 @@ var expect = require('chai').expect; | ||
it('should deal with array literals', function() { | ||
expect(parse('[foo, bar]')).to.equal('[this.foo, this.bar]'); | ||
}); | ||
it('should deal with object literals', function() { | ||
expect(parse('{foo: foo, bar: bar }')).to.equal('{foo: this.foo, bar: this.bar }'); | ||
}); | ||
it('should work with simple setters', function() { | ||
@@ -145,0 +153,0 @@ expect(parse('foo = _value_')).to.equal('this.foo = _value_'); |
36832
639
302