🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

@proc/context

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proc/context

A Hierachical Application Context

latest
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

An application context.

A hierachical application context object. Create a parent context for the application and spawn child contexts for each request/process. Each gets a unique id and lifecycle.

Properties can be weakly attached to the context and the lifecycle events ensure they can be destroyed after a request, hopefully avoiding memory leaks by held resources.

The enhancer allows wrapping properties to the context without specifying the implementations. This means you can create the interface (in Typescript) and code against it, but leave the real implementation up the main library.

Simple Usage

import createContext from "@proc/context";

const ctx = createContext();
const child = ctx.child();

ctx.waitForChildren().finally(() => {
  console.log("child context finished");
});

someLongProcess(child).finally(() => {
  child.done(); // causes console.log: child context finished
});

ctx.done(); // free all resources

FAQs

Package last updated on 08 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts