Have ideas to improve npm?Join in the discussion! »

with-scope

1.0.1 • Public • Published

with-scope v1.0.1 stable

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

Keywords

none

Install

npm i with-scope

DownloadsWeekly Downloads

0

Version

1.0.1

License

none

Last publish

Collaborators

  • avatar