New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@clipboard-health/execution-context

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clipboard-health/execution-context - npm Package Compare versions

Comparing version 0.6.3 to 0.7.0

src/lib/util.d.ts

2

package.json
{
"name": "@clipboard-health/execution-context",
"description": "A lightweight Node.js utility for managing execution contexts and metadata aggregation using AsyncLocalStorage.",
"version": "0.6.3",
"version": "0.7.0",
"bugs": "https://github.com/ClipboardHealth/core-utils/issues",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -15,2 +15,14 @@ import "../types/global";

export declare function addMetadataToLocalContext(metadata: Record<string, unknown>): void;
/**
* A utility function that will add metadata to the list under current context's key
* @param key - the list's key (string) in the context
* @param metadata - the metadata (key-value pair), to be added to the context
*/
export declare function addToMetadataList(key: string, metadata: Record<string, unknown>): void;
/**
* A utility function that will add metadata to the record under current context's key,
* supporting nested records.
* @param key - the record's key (string) in the context
* @param metadata - the metadata (key-value pair), to be added to the context
*/
export declare function addToMetadataRecord(key: string, metadata: Record<string, unknown>): void;

@@ -8,4 +8,6 @@ "use strict";

exports.addToMetadataList = addToMetadataList;
exports.addToMetadataRecord = addToMetadataRecord;
require("../types/global");
const node_async_hooks_1 = require("node:async_hooks");
const util_1 = require("./util");
globalThis.threadLocalStorage ||= new node_async_hooks_1.AsyncLocalStorage();

@@ -60,2 +62,7 @@ function getAsyncLocalStorage() {

}
/**
* A utility function that will add metadata to the list under current context's key
* @param key - the list's key (string) in the context
* @param metadata - the metadata (key-value pair), to be added to the context
*/
function addToMetadataList(key, metadata) {

@@ -65,2 +72,22 @@ const metadataList = [...getMetadataListByKey(key), metadata];

}
function getMetadataRecordByKey(key) {
const context = getExecutionContext();
if (context?.metadata && key in context.metadata) {
const metadataForKey = context.metadata[key];
if ((0, util_1.isRecord)(metadataForKey)) {
return metadataForKey;
}
}
return {};
}
/**
* A utility function that will add metadata to the record under current context's key,
* supporting nested records.
* @param key - the record's key (string) in the context
* @param metadata - the metadata (key-value pair), to be added to the context
*/
function addToMetadataRecord(key, metadata) {
const metadataRecord = { ...getMetadataRecordByKey(key), ...metadata };
addMetadataToLocalContext({ [key]: metadataRecord });
}
//# sourceMappingURL=contextStore.js.map

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc