localscope

1.0.2 • Public • Published

LocalScope

A tool to import members of objects into local scopes in JavaScript

I wrote a blog post explaining the reasoning behind this and how it works here.

Here is a good example of how to use this code:

var local = require("localScope");

let obj = {
    a: "Hello,",
    b: "World!"
};

function testImport() {
    eval(local("obj"));

    console.log(a, b);
    // Woah! a and b were declared in the scope of this function
}

testImport();

Package Sidebar

Install

npm i localscope

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

8.95 kB

Total Files

7

Last publish

Collaborators

  • 414owen