with-scope
v1.0.1
Published
Expose the properties of a given `Object` as local variables to a given `Function`.
Downloads
9
Readme
with-scope v1.0.1
Expose the properties of a given Object
as local variables to a given Function
.
npm install with-scope
usage
var withScope = require("with-scope")
var scope = { hello: "world" }
withScope(scope, function () {
console.log(hello)
})
CoffeeScript-generated functions have their first var
statement cleaned of any properties found in __scope
!
withScope = require "with-scope"
scope = hello: "world"
# The function passed to `withScope` would override `__scope.hello` with `var hello;` but this library fixes that for you!
withScope scope, ->
hello ?= "<no value>"
# This should still print "world".
console.log hello
tests
All tests are passing! Find out for yourself:
npm install -g jasmine-node
npm test
changelog
1.0.1
+ CoffeeScript support
1.0.0
+ Initial release