
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
gopkg.in/nqd/flat.v0
Take a golang map and flatten it or unfatten a map with delimited key.
This work inspired by the nodejs flat package
Flatten given map, returns a map one level deep.
in := map[string]interface{}{
"a": "b",
"c": map[string]interface{}{
"d": "e",
"f": "g",
},
"z": [2, 1.4567],
}
out, err := flat.Flatten(in, nil)
// out = map[string]interface{}{
// "a": "b",
// "c.d": "e",
// "c.f": "g",
// "z.0": 2,
// "z.1": 1.4567,
// }
Since there is flatten, flat should have unfatten.
in := map[string]interface{}{
"foo.bar": map[string]interface{}{"t": 123},
"foo": map[string]interface{}{"k": 456},
}
out, err := flat.Unflatten(in, nil)
// out = map[string]interface{}{
// "foo": map[string]interface{}{
// "bar": map[string]interface{}{
// "t": 123,
// },
// "k": 456,
// },
// }
Use a custom delimiter for flattening/unflattening your objects. Default value is .
.
in := map[string]interface{}{
"hello": map[string]interface{}{
"world": map[string]interface{}{
"again": "good morning",
}
},
}
out, err := flat.Flatten(in, &flat.Options{
Delimiter: ":",
})
// out = map[string]interface{}{
// "hello:world:again": "good morning",
// }
When Safe is true, fatten will preserve arrays and their contents. Default Safe value is false
.
in := map[string]interface{}{
"hello": map[string]interface{}{
"world": []interface{}{
"one",
"two",
}
},
}
out, err := flat.Flatten(in, &flat.Options{
Delimiter: ".",
Safe: true,
})
// out = map[string]interface{}{
// "hello.world": []interface{}{"one", "two"},
// }
MaxDepth is the maximum number of nested objects to flatten. MaxDepth can be any integer number. MaxDepth = 0 means no limit.
Default MaxDepth value is 0
.
in := map[string]interface{}{
"hello": map[string]interface{}{
"world": []interface{}{
"again": "good morning",
}
},
}
out, err := flat.Flatten(in, &flat.Options{
Delimiter: ".",
MaxDepth: 2,
})
// out = map[string]interface{}{
// "hello.world": map[string]interface{}{"again": "good morning"},
// }
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.