Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
call-context
Advanced tools
This package provides a simple call-stack context provision.
import { context } from "call-context";
const ctx = context("my context"); // name is optional
const fn = () => {
console.log(ctx.require()); // we'll provide 42, so this will log 42.
};
const contextProvidedFn = ctx.provide(42)(fn);
contextProvidedFn();
Context's require()
will throw an error if the context has not been provided.
Name your context at construction time so that you get a meaningful error
message.
Use provide
.
import { provide } from "call-context";
const contextProvidedFn =
provide(context1, value1)(context2, value2)(context3, value3)(fn);
Use get
to consume the context optionally. This returns undefined
if the
context has not been provided.
import { context } from "call-context";
const ctx = context("my context"); // name is optional
const fn = () => {
console.log(ctx.get() ?? 42); // This will log 42 without provision.
};
fn();
Using call-stack context allows dependencies to be provided deep in the call hierarchy. This idea is inspired from React's conext, which allows dependencies to be provided deep in the component hierarchy. Context allows for more liberal use of dependency inversion, because it reduces the amount of pumbling required to send the dependencies to the use site.
The alternative, i.e. passing dependencies down the call hierarchy, has better traceability.
FAQs
A context provision tool.
The npm package call-context receives a total of 0 weekly downloads. As such, call-context popularity was classified as not popular.
We found that call-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.