https://github.com/adrielcodeco/pii-scope
A library to create new global scopes
https://github.com/adrielcodeco/pii-scope
Last synced: 2 months ago
JSON representation
A library to create new global scopes
- Host: GitHub
- URL: https://github.com/adrielcodeco/pii-scope
- Owner: adrielcodeco
- License: mit
- Created: 2018-05-31T20:03:15.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-18T17:39:31.000Z (over 7 years ago)
- Last Synced: 2026-03-11T17:43:48.899Z (3 months ago)
- Language: TypeScript
- Size: 389 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Pii Scope](https://github.com/adrielcodeco/pii-scope)
Pii Scope is library to create new global scopes
[](http://standardjs.com)
[](https://travis-ci.org/adrielcodeco/pii-scope)
[](https://ci.appveyor.com/project/adrielcodeco/pii-scope/branch/master)
[](https://coveralls.io/github/adrielcodeco/pii-scope?branch=master)
[](https://npmjs.org/package/@pii/scope)
## Installation
```
npm i -S @pii/scope
```
## Requirements
* NodeJS version >= 6
## Documentation
* [Quick Start](https://adrielcodeco.github.io/pii-scope#quick-start)
* [Examples](https://github.com/adrielcodeco/pii-scope/tree/master/examples)
## Examples
Here is a simple example to get you started:
index.js
```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
```js
class Test {
set() {
global.testVar = 3.1415
}
log() {
console.log(global.testVar || Math.random())
}
}
module.exports = Test
```
### License
This project is [MIT licensed](./LICENSE).
[](http://standardjs.com)