@pii/scope
v1.1.1
Published
A library to create new global scopes
Downloads
3
Readme
Pii Scope
Pii Scope is library to create new global scopes
Installation
npm i -S @pii/scope
Requirements
- NodeJS version >= 6
Documentation
Examples
Here is a simple example to get you started:
index.js
import scope from '@pii/scope'
// or require for ES5
// const scope = require('@pii/scope').default
const Test1 = scope.New(require.resolve('./test'))
const t1 = new Test1()
t1.set()
t1.log()
const list = [1,2,3,4,5,6,7,8,9]
list.forEach(_ => {
const Test2 = scope.New(require.resolve('./test'))
const t2 = new Test2()
t2.log()
})
test.js
class Test {
set() {
global.testVar = 3.1415
}
log() {
console.log(global.testVar || Math.random())
}
}
module.exports = Test
License
This project is MIT licensed.