
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.
@jlhv/object-helper
Advanced tools
A collection of utility functions for common object operations in TypeScript.
To install the package, use:
npm install @jlhv/object-helper
Import the library and use its functions:
import * as ObjectHelper from "@jlhv/object-helper";
const obj = { a: 1, b: 2, c: 3 };
console.log(ObjectHelper.isEmpty(obj)); // false
isEmpty(obj: Record<string, any>): boolean
Checks if an object is empty.
ObjectHelper.isEmpty({}); // true
ObjectHelper.isEmpty({ key: "value" }); // false
merge<T, U>(obj1: T, obj2: U): T & U
Merges two objects without modifying the originals.
const merged = ObjectHelper.merge({ a: 1 }, { b: 2 });
console.log(merged); // { a: 1, b: 2 }
deepClone<T>(obj: T): T
Creates a deep copy of an object.
const original = { a: { b: 2 } };
const copy = ObjectHelper.deepClone(original);
console.log(copy); // { a: { b: 2 } }
pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>
Picks specific keys from an object.
const obj = { a: 1, b: 2, c: 3 };
console.log(ObjectHelper.pick(obj, ["a", "c"])); // { a: 1, c: 3 }
omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>
Omits specific keys from an object.
console.log(ObjectHelper.omit({ a: 1, b: 2, c: 3 }, ["b"])); // { a: 1, c: 3 }
isEqual<T>(obj1: T, obj2: T): boolean
Checks if two objects are equal (shallow comparison).
ObjectHelper.isEqual({ a: 1 }, { a: 1 }); // true
ObjectHelper.isEqual({ a: 1 }, { a: 2 }); // false
hasNested(obj: Record<string, any>, path: string): boolean
Checks if an object has a nested property.
const obj = { a: { b: { c: 42 } } };
console.log(ObjectHelper.hasNested(obj, "a.b.c")); // true
console.log(ObjectHelper.hasNested(obj, "a.x.y")); // false
getNested<T>(obj: Record<string, any>, path: string, defaultValue?: T): T | undefined
Safely retrieves a nested property.
console.log(ObjectHelper.getNested({ a: { b: { c: 42 } } }, "a.b.c")); // 42
console.log(ObjectHelper.getNested({ a: { b: { c: 42 } } }, "a.x.y", "default")); // "default"
setNested<T>(obj: Record<string, any>, path: string, value: T): void
Sets a nested property in an object.
const obj = { a: { b: {} } };
ObjectHelper.setNested(obj, "a.b.d", 100);
console.log(obj.a.b.d); // 100
invert<T>(obj: T): Record<string, keyof T>
Swaps keys and values in an object.
console.log(ObjectHelper.invert({ a: 1, b: 2 })); // { "1": "a", "2": "b" }
toPairs<T>(obj: T): [keyof T, T[keyof T]][]
Converts an object to an array of key-value pairs.
console.log(ObjectHelper.toPairs({ a: 1, b: 2 })); // [["a", 1], ["b", 2]]
fromPairs<T>(pairs: [string, T][]): Record<string, T>
Creates an object from key-value pairs.
console.log(ObjectHelper.fromPairs([["a", 1], ["b", 2]])); // { a: 1, b: 2 }
freeze<T>(obj: T): Readonly<T>
Freezes an object to prevent modifications.
const frozen = ObjectHelper.freeze({ a: 1 });
// frozen.a = 2; // Error in strict mode
mapValues<T, U>(obj: T, callback: (value: T[keyof T], key: keyof T) => U): Record<keyof T, U>
Applies a function to each value in an object.
console.log(ObjectHelper.mapValues({ a: 1, b: 2 }, val => val * 2)); // { a: 2, b: 4 }
filter<T>(obj: T, predicate: (value: T[keyof T], key: keyof T) => boolean): Partial<T>
Filters object properties based on a function.
console.log(ObjectHelper.filter({ a: 1, b: 2, c: 3 }, val => val > 1)); // { b: 2, c: 3 }
deepMerge<T, U>(obj1: T, obj2: U): T & U
Performs a deep merge of two objects.
const obj1 = { a: { b: 1 } };
const obj2 = { a: { c: 2 } };
console.log(ObjectHelper.deepMerge(obj1, obj2)); // { a: { b: 1, c: 2 } }
ISC License.
Vijayavel R
FAQs
A simple utility library for object manipulation.
The npm package @jlhv/object-helper receives a total of 5 weekly downloads. As such, @jlhv/object-helper popularity was classified as not popular.
We found that @jlhv/object-helper demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
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.