Sign In

flatted

Package Overview
Dependencies
Maintainers
1
Versions
44
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.3
to
3.4.4
+16
-14
golang/pkg/flatted/flatted.go

@@ -16,3 +16,3 @@ package flatted

// Stringify converts a Go value into a specialized flatted JSON string.
func Stringify(value any, replacer any, space any) (string, error) {
func Stringify(value, replacer, space any) (string, error) {
knownKeys := []any{}

@@ -36,3 +36,3 @@ knownValues := []string{}

kind := rv.Kind()
if kind == reflect.String || kind == reflect.Slice || kind == reflect.Map || kind == reflect.Ptr {
if kind == reflect.String || kind == reflect.Slice || kind == reflect.Map || kind == reflect.Pointer {
for i, k := range knownKeys {

@@ -64,3 +64,3 @@ if kind == reflect.String {

// Dereference pointers to process the underlying Slice, Map, or Array
for rv.Kind() == reflect.Ptr && !rv.IsNil() {
for rv.Kind() == reflect.Pointer && !rv.IsNil() {
rv = rv.Elem()

@@ -129,6 +129,7 @@ }

indent := ""
if s, ok := space.(string); ok {
indent = s
} else if i, ok := space.(int); ok {
indent = strings.Repeat(" ", i)
switch v := space.(type) {
case string:
indent = v
case int:
indent = strings.Repeat(" ", v)
}

@@ -212,9 +213,10 @@

func revive(key string, value any, reviver func(k string, v any) any) any {
if arr, ok := value.([]any); ok {
for i, v := range arr {
arr[i] = revive(strconv.Itoa(i), v, reviver)
switch v := value.(type) {
case []any:
for i, el := range v {
v[i] = revive(strconv.Itoa(i), el, reviver)
}
} else if m, ok := value.(map[string]any); ok {
keys := make([]string, 0, len(m))
for k := range m {
case map[string]any:
keys := make([]string, 0, len(v))
for k := range v {
keys = append(keys, k)

@@ -224,3 +226,3 @@ }

for _, k := range keys {
m[k] = revive(k, m[k], reviver)
v[k] = revive(k, v[k], reviver)
}

@@ -227,0 +229,0 @@ }

{
"name": "flatted",
"version": "3.4.3",
"version": "3.4.4",
"description": "A super light and fast circular JSON parser.",

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