@pii/scope
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Pii Scope

Pii Scope is library to create new global scopes

js-standard-style Build Status (linux, Mac) Build status (Windows) Coverage Status

NPM

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.

js-standard-style

Readme

Keywords

Package Sidebar

Install

npm i @pii/scope

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

42.1 kB

Total Files

23

Last publish

Collaborators

  • pii