Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "binding-js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Data binding modules.", | ||
"main": "index.js", | ||
"main": "src/binding.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "webpack ./test/test2.js test/bundle.js --watch" | ||
}, | ||
@@ -20,4 +20,9 @@ "repository": { | ||
"devDependencies": { | ||
"observable-js": "^0.3.0" | ||
"webpack": "^1.13.1" | ||
}, | ||
"dependencies": { | ||
"fastdom-js": "^0.1.0", | ||
"observable-js": "^0.3.0", | ||
"utility-js": "^0.1.0" | ||
} | ||
} |
var PathObserver = require('./path-observer') | ||
function Scope (object, parent) { | ||
this.object = object | ||
this.parent = parent | ||
} | ||
Scope.prototype = { | ||
root: function () { | ||
var root = this | ||
while (root.parent && (root = root.parent)) {} | ||
return root | ||
}, | ||
val: function (path, value) { | ||
var parts, object, part, root, key | ||
if (value === undefined) { | ||
if (path instanceof Object) { | ||
for (var i in path) { | ||
this.val(i, path[i]) | ||
} | ||
return this | ||
} | ||
parts = path.split('.') | ||
object = this.object | ||
while (parts.length) { | ||
part = parts.shift() | ||
if (part === '$parent') { | ||
if (!this.parent) { | ||
return | ||
} | ||
object = this.parent.object | ||
continue | ||
} else if (part === '$root') { | ||
root = this.root() | ||
if (!root) { | ||
return | ||
} | ||
object = root.object | ||
continue | ||
} | ||
if (!(object instanceof Object)) { | ||
return | ||
} | ||
if (!(part in object)) { | ||
return | ||
} | ||
object = object[part] | ||
} | ||
return object | ||
} | ||
parts = path.split('.') | ||
object = this.object | ||
key = parts.pop() | ||
if (parts.length) { | ||
object = this.val(parts.join('.')) | ||
} | ||
if (!(object instanceof Object)) { | ||
return this | ||
} | ||
if (object.isObservableObject) { | ||
object.prop(key, value) | ||
} else { | ||
object[key] = value | ||
} | ||
return this | ||
}, | ||
apply: function (path, args) { | ||
var parts = path.split('.') | ||
var object = this.object | ||
var key = parts.pop() | ||
if (parts.length) { | ||
object = this.val(parts.join('.')) | ||
} | ||
if (!(object instanceof Object)) { | ||
return | ||
} | ||
if (!(object[key] instanceof Function)) { | ||
return | ||
} | ||
return object[key].apply(object, args) | ||
}, | ||
call: function (path) { | ||
return this.apply(path, Array.prototype.slice.call(arguments, 1)) | ||
}, | ||
observe: function (path, callback) { | ||
new PathObserver(path, callback).observe(this.object) | ||
return this | ||
}, | ||
unobserve: function (path, callback) { | ||
throw new Error('Not implemented yet') | ||
} | ||
} | ||
module.exports = require('./scope') |
@@ -13,5 +13,10 @@ | ||
var parts = this.path.split('.') | ||
var initialize = true | ||
var keyObserver = new KeyObserver(parts.pop(), { | ||
observe: function () { | ||
callback() | ||
observe: function (object) { | ||
if (initialize) { | ||
initialize = false | ||
return | ||
} | ||
callback(object) | ||
} | ||
@@ -18,0 +23,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
29966
13
1047
1
3
2
+ Addedfastdom-js@^0.1.0
+ Addedobservable-js@^0.3.0
+ Addedutility-js@^0.1.0
+ Addedfastdom-js@0.1.0(transitive)
+ Addedobservable-js@0.3.0(transitive)
+ Addedutility-js@0.1.0(transitive)