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

json-templater

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-templater - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

36

object_test.js

@@ -86,2 +86,38 @@ suite('object', function() {

);
verify(
'nested arrays',
[
'{{some.arrays}}',
{ some: { arrays: [1, [2, [{3: 4}]]] } }
],
[1, [2, [{3: 4}]]]
);
verify(
'nested objects', [
'{{some.object}}',
{ some: { object: {3: {4: 5}} } }
],
{3: {4: 5}}
);
verify(
'nested arrays in objects and objects in arrays',
[
{
'arrays{{some.arrays.0}}': '{{some.arrays}}',
'object{{some.arrays.1.0}}': '{{some.object}}'
}, {
some: {
arrays: [1, [2, [{ 3: 4 }]]],
object: { 3: { 4: 5 }}
}
}
], {
arrays1: [1, [2, [{ 3: 4 }]]],
object2: { 3: { 4: 5 }}
}
);
});

2

package.json
{
"name": "json-templater",
"version": "1.0.3",
"version": "1.0.4",
"description": "Simple json/js object template strings",

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

@@ -55,11 +55,18 @@ /**

if (input.indexOf(TEMPLATE_OPEN) === -1) return input;
return input.replace(REGEX, function(whole, path) {
var result;
var replaced = input.replace(REGEX, function(whole, path) {
var value = extractValue(path, view);
if (value) {
return value;
if (typeof value === 'object') {
result = value;
return;
} else {
return value;
}
}
return whole;
});
return result ? result : replaced;
}
module.exports = replace;
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