Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@incanta/config

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@incanta/config - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

2

lib/config.d.ts

@@ -16,3 +16,3 @@ export interface IConfigOptions {

getWithParts<T>(keyParts: string[]): T;
has(key: string): boolean;
tryGet<T>(key: string): T | null;
set<T>(key: string, value: T): void;

@@ -19,0 +19,0 @@ setWithParts<T>(keyParts: string[], value: T): void;

@@ -100,12 +100,42 @@ "use strict";

}
const variableRegex = /\$\{[a-zA-Z\-_0-9.]+\}/g;
const replaceValue = (value) => {
const regexResult = value.matchAll(variableRegex);
for (const match of regexResult) {
const keyToReplace = match[0].slice(2, match[0].length - 1);
const value = this.tryGet(keyToReplace);
if (value !== null) {
obj = obj.replace(match[0], `${value}`);
}
}
};
// replace all ${value} with the value from the config
if (typeof obj === "string") {
replaceValue(obj);
}
else if (typeof obj === "object") {
// walk the object and replace all strings with the value from the config
const walkObject = (curObj) => {
for (const property of Object.keys(curObj)) {
const value = curObj[property];
if (typeof value === "string") {
replaceValue(value);
}
else if (typeof value === "object") {
walkObject(value);
}
}
};
walkObject(obj);
}
return obj;
}
has(key) {
tryGet(key) {
try {
this.get(key);
const value = this.get(key);
return value;
}
catch {
return false;
return null;
}
return true;
}

@@ -112,0 +142,0 @@ set(key, value) {

{
"name": "@incanta/config",
"version": "0.1.8",
"version": "0.1.9",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "exports": {

Sorry, the diff of this file is not supported yet

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