@vyke/context
v0.0.2
Published
A simple context manager for running code in a specific context
Downloads
3
Readme
Installation
npm i @vyke/context
API
defineContext
Defines a context that can be used to run code in a specific context
const context = defineContext('test')
const context1 = 'test 1'
const context2 = 'test 2'
const context3 = 'test 3'
context.run(context1, () => {
console.log(context.getValue(context1)) // test 1
context.run(context2, () => {
console.log(context.getValue(context2)) // test 2
context.run(context3, () => {
console.log(context.getValue(context3)) // test 3
})
console.log(context.getValue(context2)) // test 2
})
console.log(context.getValue(context1)) // test 1
})