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

interpolate-json

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interpolate-json - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

21

lib/main.js

@@ -13,3 +13,4 @@ const extend = require('extend');

prefix: '${',
suffix: '}'
suffix: '}',
subKeyPointer: '.'
};

@@ -20,3 +21,5 @@

escapeRegex(opt.prefix.trim()) +
'([\\s]*[\\w\\.]+[\\s]*)' +
'([\\s]*[\\w]+(?:' +
escapeRegex(opt.subKeyPointer.trim()) +
'[\\w]+)*[\\s]*)' +
escapeRegex(opt.suffix.trim()),

@@ -43,5 +46,5 @@ 'g'

const traverse = (obj, path) => {
const traverse = (obj, path, subKeyPointer) => {
let result = path
.split('.')
.split(subKeyPointer)
.reduce((parent, key) => parent[key] || {}, obj);

@@ -71,7 +74,7 @@ return type(result) === 'number' || type(result) === 'string' ? result : '';

const flattenAndResolve = (obj, matchSet, paramRegex) => {
const flattenAndResolve = (obj, matchSet, paramRegex, subKeyPointer) => {
let cache = {};
matchSet.forEach(match => {
// Step 1: Get current value
let curVal = traverse(obj, match);
let curVal = traverse(obj, match, subKeyPointer);
// Step 2: Is it clean

@@ -90,3 +93,4 @@ if (paramRegex.test(curVal)) {

getMatchSet(curVal.match(paramRegex), paramRegex),
paramRegex
paramRegex,
subKeyPointer
)

@@ -118,3 +122,4 @@ );

getMatchSet(matches, paramRegex),
paramRegex
paramRegex,
options.subKeyPointer
);

@@ -121,0 +126,0 @@ needToDo = true;

{
"name": "interpolate-json",
"version": "0.3.0",
"version": "0.3.1",
"description": "Interpolate a Javascript (Node.js V8) Object or string with json - Advanced",

@@ -5,0 +5,0 @@ "main": "index.js",

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