
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
composite-object
Advanced tools
A module for mapping between multi-part string keys and values
npm install composite-object
const { CompositeObject } = require("composite-object");
const map = new CompositeObject();
map.set(["a", "b", "c"], "test-value");
map.get(["a", "b", "c"]);
//=> 'test-value'
Type: CompositeObject
Object
Properties to populate the CompositeObject with. Object
inputs must be in the same form as those created by the
CompositeObject.prototype.toJSON() method.
const compositeObject1 = new CompositeObject();
const compositeObject2 = new CompositeObject(compositeObject1);
const compositeObject3 = new CompositeObject({ a: "test-value", b: "test-value-2" }, { keyLength: 1 });
const compositeObject4 = new CompositeObject({ a: { b: "test-value" } }, { keyLength: 2 });
const compositeObject4 = new CompositeObject({ a: { b: { c: "test-value" } } }, { keyLength: 3 });
Type: Object
Type: "reference"
"on-write"
"keys"
Default: "keys"
Determines when the keys for the provided CompositeObject
or Object
are copied.
"reference"
Never copy keys. Changes made will affect the source. Only supported for copying an Object
.
"on-write"
Copy keys as changes are made.
"keys"
Copy all keys immediately.
Type: number
Manually specify the length of keys. Only used when constructing using an Object
.
Removes all key/value pairs from the CompositeObject
.
Returns true
if a property in the CompositeObject
existed and has been removed, or false
if the property does
not exist.
Type: string[]
The key of the property to be deleted. Shorter keys will delete all properties with matching keys.
Returns a new Iterator
object that contains an array of [key, value]
for each property in the CompositeObject
.
Calls callbackFn once for each property present in the CompositeObject
.
Returns the value associated to the key
, or undefined
if there is none.
Type: string[]
The key
of the property to be returned. Shorter keys will return the Object
associated to the key if one exists.
Returns a boolean asserting whether a value has been associated to the key
in the CompositeObject
or not.
Type: string[]
The key
of the property to be found. Shorter keys will find any properties with matching keys.
Returns a new Iterator
object that contains the keys for each property in the CompositeObject
.
Sets the value of the key
in the CompositeObject
. Returns the CompositeObject
.
Type: string[]
The key
to set the value for. All keys must have the same Array
length.
Type: any
The value to store.
Returns a tree-like Object
structure containing all properties in the CompositeObject
.
const compositeObject = new CompositeObject();
compositeObject.set(["a", "b", "c"], "test-value");
const json = JSON.stringify(compositeObject);
console.log(json);
//=>{ "a": { "b": { "c": "test-value" } } }
const compositeObject2 = new CompositeObject(JSON.parse(json), { keyLength: 3 });
Returns a new Iterator
object that contains the values for each property in the CompositeObject
.
Returns a new Iterator
object that contains an array of [key, value]
for each property in the CompositeObject
.
To provide better typing support, you can import copies of the CompositeObject
class typed for the length of key
being used.
import { CompositeObject3 } from "composite-object";
enum StringEnum {
One = "one",
Two = "two",
}
const compositeObject = new CompositeObject3<string, "a" | "b", MyStringEnum, string>();
compositeObject.set(["key-part", "a", MyStringEnum.One], "test-value");
const value: string = compositeObject.get(["key-part", "a", MyStringEnum.One]);
const subObject: Record<MyStringEnum, string> = compositeObject.get(["key-part", "a"]);
Some text from this readme was sourced from developer.mozilla.org.
FAQs
A module for mapping between multi-part string keys and values
The npm package composite-object receives a total of 3 weekly downloads. As such, composite-object popularity was classified as not popular.
We found that composite-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.