# js-object-utilities

> JavaScript utilities for nested objects

Latest version **2.2.2** (published 2026-08-05) · UNLICENSE license · 0 weekly downloads

## Install

```sh
npm install js-object-utilities
pnpm add js-object-utilities
yarn add js-object-utilities
bun add js-object-utilities
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2026-08-05 |
| First published | 2021-03-15 |
| Weekly downloads | 0 |
| License | UNLICENSE |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | rrainn, Inc. |
| Maintainers | fishcharlie |
| Keywords | object, utilities, nested, helper |

## Links

- npm: https://www.npmjs.com/package/js-object-utilities
- Repository: https://github.com/rrainn/js-object-utilities
- Homepage: https://github.com/rrainn/js-object-utilities#readme
- Issues: https://github.com/rrainn/js-object-utilities/issues
- npm.io page: https://npm.io/package/js-object-utilities

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.2.2 (latest) — 2026-08-05
- 2.2.1 — 2025-04-06
- 2.2.0 — 2023-12-20
- 2.1.0 — 2022-01-20
- 2.0.0 — 2021-03-17
- 1.0.0 — 2021-03-15

## README

# js-object-utilities

This package has a bunch of helper methods to work with nested objects in JavaScript.

## Install

```
npm i js-object-utilities
```

## API

### objectutils.get(obj, key)

This function takes in an object (`obj`) and a key (`key`) and returns the value for the given key.

```js
const objectutils = require("js-object-utilities");
console.log(objectutils.get({
	"data": {
		"hello": "world"
	}
}, "data.hello"));

// Will print "world"
```

### objectutils.set(obj, key, value)

This function takes in an object (`obj`), key (`key`), and a value (`value`) and mutates the object setting the value for the given key.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world"
	}
};
objectutils.set(object, "data.hello", "universe");
console.log(object); // {"data": {"hello": "universe"}}
```

### objectutils.delete(obj, key)

This function takes in an object (`obj`), and key (`key`), and deletes the given value for the key you passed in.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world"
	}
};
objectutils.delete(object, "data.hello");
console.log(object); // {"data": {}}
```

### objectutils.pick(obj, keys)

This function takes in an object (`obj`), and array of keys (`keys`), and returns an object for the given keys you passed in.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm"
	}
};
objectutils.delete(object, ["data.hello", "data.space"]);
console.log(object); // {"data": {"hello": "world", "space": "travel"}}
```

### objectutils.keys(obj)

This function takes in an object (`obj`), and returns an array of keys included in that object.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm"
	}
};
console.log(objectutils.keys(object)); // ["data", "data.hello", "data.space", "data.node"]
```

### objectutils.entries(obj)

This function takes in an object (`obj`), and returns an array of entries included in that object.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm"
	}
};
console.log(objectutils.keys(object)); // [["data", {"hello": "world", "space": "travel", "node": "npm"}], ["data.hello", "world"], ["data.space", "travel"], ["data.node", "npm]]
```

### objectutils.equals(obj)

This function takes in two values, and returns a boolean representing if they are equal. If objects as passed in it will check to ensure the entire object is identical.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm"
	}
};
console.log(objectutils.equals(object, {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm"
	}
})); // true

console.log(objectutils.equals(object, {
	"data": {
		"hello": "universe",
		"space": "travel",
		"node": "npm"
	}
})); // false
```

### objectutils.clearEmpties(obj)

This function takes in an object and mutates it to remove all objects with a length of 0.

```js
const objectutils = require("js-object-utilities");
const object = {
	"data": {
		"hello": "world",
		"space": "travel",
		"node": "npm",
		"otherData": {}
	}
};
objectutils.clearEmpties(object);
console.log(object);
// {
// 	"data": {
// 		"hello": "world",
// 		"space": "travel",
// 		"node": "npm",
// 	}
// }
```

### objectutils.isCircular(obj[, searchKey])

This function checks to see if an object is circular. If a search key is passed in it will only return `true` if the object is circular and the search key is the key that caused the circularity.

This function will also check all nested objects for circularity.

```js
const objectutils = require("js-object-utilities");

let object = {};
object.array = {"first": 1};
object.array2 = object;

const isCircular = objectutils.isCircular(object);
console.log(isCircular); // true

const isRandomKeyCircular = objectutils.isCircular(object, "random");
console.log(isRandomKeyCircular); // false

const isArray2KeyCircular = objectutils.isCircular(object, "array2");
console.log(isArray2KeyCircular); // true
```

### objectutils.circularKeys(obj[, searchKey])

This function is identical to `objectutils.isCircular` except it returns an array of keys that are circular.

```js
const objectutils = require("js-object-utilities");

let object = {};
object.array = {"first": 1};
object.array2 = object;

const circularKeys = objectutils.circularKeys(object);
console.log(circularKeys); // ["array2"]

const randomKeyCircular = objectutils.circularKeys(object, "random");
console.log(randomKeyCircular); // []

const array2KeyCircular = objectutils.circularKeys(object, "array2");
console.log(array2KeyCircular); // ["array2"]
```

---
_Source: https://npm.io/package/js-object-utilities · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
