Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

json-e

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-e - npm Package Compare versions

Comparing version
4.7.1
to
4.8.0
+1
-1
json_e.egg-info/PKG-INFO
Metadata-Version: 2.1
Name: json-e
Version: 4.7.1
Version: 4.8.0
Summary: A data-structure parameterization system written for embedding context in JSON objects

@@ -5,0 +5,0 @@ Home-page: https://json-e.js.org

@@ -69,2 +69,5 @@ from __future__ import absolute_import, print_function, unicode_literals

def is_int(v):
return isinstance(v, int)
def is_string(v):

@@ -105,2 +108,9 @@ return isinstance(v, string)

@builtin("range", minArgs=2)
def range_builtin(start, stop, step=1):
if step == 0 or not all([is_int(n) for n in [start, stop, step]]):
raise BuiltinError("invalid arguments to builtin: range")
return list(range(start, stop, step))
@builtin("lowercase", argument_tests=[is_string])

@@ -107,0 +117,0 @@ def lowercase(v):

@@ -307,2 +307,41 @@ from __future__ import absolute_import, print_function, unicode_literals

@operator("$reduce")
def reduce(template, context):
EACH_RE = r"each\([a-zA-Z_][a-zA-Z0-9_]*,\s*[a-zA-Z_][a-zA-Z0-9_]*(,\s*([a-zA-Z_][a-zA-Z0-9_]*))?\)"
checkUndefinedProperties(template, [r"\$reduce", "initial", EACH_RE])
value = renderValue(template["$reduce"], context)
if not isinstance(value, list):
raise TemplateError("$reduce value must evaluate to an array")
if len(template) != 3:
raise TemplateError("$reduce must have exactly three properties")
each_keys = [k for k in template if k.startswith("each(")]
if len(each_keys) != 1:
raise TemplateError("$reduce requires each(..)")
each_key = each_keys[0]
each_args = [x.strip() for x in each_key[5:-1].split(",")]
each_acc = each_args[0]
each_var = each_args[1]
each_idx = each_args[2] if len(each_args) > 2 else None
each_template = template[each_key]
resultValue = template["initial"]
subcontext = context.copy()
for i, elt in enumerate(value):
if each_idx is None:
subcontext[each_acc] = resultValue
subcontext[each_var] = elt
else:
subcontext[each_acc] = resultValue
subcontext[each_var] = elt
subcontext[each_idx] = i
r = renderValue(each_template, subcontext)
if r is not DeleteMarker:
resultValue = r
return resultValue
@operator("$find")

@@ -309,0 +348,0 @@ def find(template, context):

Metadata-Version: 2.1
Name: json-e
Version: 4.7.1
Version: 4.8.0
Summary: A data-structure parameterization system written for embedding context in JSON objects

@@ -5,0 +5,0 @@ Home-page: https://json-e.js.org

@@ -5,3 +5,3 @@ import json

version = "4.7.1"
version = "4.8.0"

@@ -8,0 +8,0 @@ description = "A data-structure parameterization system written for embedding context in JSON objects"