apiref
stack-local-storage@0.2.0

StackLocalStorage  Class

A StackLocalStorage can be used to pass (thread) values (referred to as a “store”) through synchronous call stacks. This can be helpful in eliminating repetitive variable passing when creating DSLs.

Signature

export declare class StackLocalStorage<T> 

Example

const store = new StackLocalStorage(0)
store.run(1, () => {
  console.log(store.getStore()) // 1
})
console.log(store.getStore()) // 0

Constructors

ConstructorDescription
(constructor)(initialStore)Creates a new StackLocalStorage.

Methods

MethodDescription
getStore()Returns the current store.
run(store, f, args)Runs a function with a given store.