You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

flatted

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatted - npm Package Compare versions

Comparing version
3.4.0
to
3.4.1
+1
-1
package.json
{
"name": "flatted",
"version": "3.4.0",
"version": "3.4.1",
"description": "A super light and fast circular JSON parser.",

@@ -5,0 +5,0 @@ "unpkg": "min.js",

@@ -28,16 +28,9 @@ # ISC License

def _array_keys(value):
keys = []
i = 0
for _ in value:
keys.append(i)
i += 1
return keys
for i in range(len(value)):
yield i
def _object_keys(value):
keys = []
for key in value:
keys.append(key)
return keys
yield key

@@ -60,20 +53,2 @@ def _is_array(value):

def _loop(keys, input, known, output):
for key in keys:
value = output[key]
if isinstance(value, _String):
_ref(key, input[int(value.value)], input, known, output)
return output
def _ref(key, value, input, known, output):
if _is_array(value) and value not in known:
known.append(value)
value = _loop(_array_keys(value), input, known, value)
elif _is_object(value) and value not in known:
known.append(value)
value = _loop(_object_keys(value), input, known, value)
output[key] = value
def _relate(known, input, value):

@@ -88,2 +63,18 @@ if _is_string(value) or _is_array(value) or _is_object(value):

def _resolver(input, lazy, parsed):
def resolver(output):
keys = _array_keys(output) if _is_array(output) else _object_keys(output) if _is_object(output) else []
for key in keys:
value = output[key]
if isinstance(value, _String):
tmp = input[int(value.value)]
output[key] = tmp
if (_is_array(tmp) or _is_object(tmp)) and tmp not in parsed:
parsed.append(tmp)
lazy.append([output, key])
return output
return resolver
def _transform(known, input, value):

@@ -134,8 +125,12 @@ if _is_array(value):

value = input[0]
lazy = []
revive = _resolver(input, lazy, [value])
if _is_array(value):
return _loop(_array_keys(value), input, [value], value)
value = revive(value)
if _is_object(value):
return _loop(_object_keys(value), input, [value], value)
i = 0
while i < len(lazy):
o, k = lazy[i]
i += 1
o[k] = revive(o[k])

@@ -142,0 +137,0 @@ return value