# dotty

> Access properties of nested objects using dot-path notation

Latest version **0.1.2** (published 2021-11-02) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install dotty
pnpm add dotty
yarn add dotty
bun add dotty
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2021-11-02 |
| First published | 2012-07-30 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 125 |
| Author | Conrad Pankoff |
| Maintainers | stramel89, mhernandez, deoxxa |
| Keywords | object, access, dot, path, mongodb |

## Links

- npm: https://www.npmjs.com/package/dotty
- Repository: https://github.com/deoxxa/dotty
- Homepage: https://github.com/deoxxa/dotty#readme
- Issues: https://github.com/deoxxa/dotty/issues
- npm.io page: https://npm.io/package/dotty

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2021-11-02
- 0.1.1 — 2021-01-25
- 0.1.0 — 2018-02-22
- 0.0.2 — 2013-04-19
- 0.0.1 — 2012-07-30

## README

# Dotty ![Build and Test](https://github.com/deoxxa/dotty/workflows/Build%20and%20Test/badge.svg) [![npm](https://img.shields.io/npm/v/dotty.svg)](https://www.npmjs.com/package/dotty)

Access properties of nested objects using dot-path notation.

## Overview

Dotty makes it easy to programmatically access arbitrarily nested objects and
their properties.

## Installation

Here's a link to the [npm](https://npmjs.org/package/dotty) page.

    npm install dotty

## Usage

Also see the [documentation](http://deoxxa.github.com/dotty/docs/) and
[example](example.js).

```javascript
var dotty = require("dotty");

var object = {
  a: {
    b: {
      x: "y",
    },
    c: {
      x: "z",
    },
  },
};

console.log(dotty.exists(object, "a.b.x")); // true
console.log(dotty.exists(object, ["a", "b", "x"])); // true
console.log(dotty.exists(object, "a.b.z")); // false
console.log(dotty.exists(object, ["a", "b", "z"])); // false

console.log(dotty.get(object, "a.b.x")); // "y"
console.log(dotty.get(object, ["a", "b", "x"])); // "y"
console.log(dotty.get(object, "a.b.z")); // undefined
console.log(dotty.get(object, ["a", "b", "z"])); // undefined

dotty.put(object, "a.b.hello", "hi");
dotty.put(object, ["a", "c", "yo"], "sup");

console.log(dotty.search(object, "a.b.*"));
console.log(dotty.search(object, ["a", "b", "*"]));
console.log(dotty.search(object, "a.*.x"));
console.log(dotty.search(object, ["a", "*", "x"]));
console.log(dotty.search(object, ["a", "*", /..+/]));
console.log(
  dotty.search(object, "a.b.*", function (value, parent, key) {
    parent[key] = value + "!";
  })
);

console.log(dotty.remove(object, "a.b.x"));
console.log(dotty.remove(object, "a.b.y"));

console.log(dotty.removeSearch(object, "a.*.x"));

console.log(dotty.deepKeys(object));
console.log(dotty.deepKeys(object, { leavesOnly: true }));
console.log(dotty.deepKeys(object, { leavesOnly: true, asStrings: true }));

console.log(object);
```

## License

3-clause BSD. A copy is included with the source.

## Contact

- GitHub ([http://github.com/deoxxa](deoxxa))
- Twitter ([http://twitter.com/deoxxa](@deoxxa))
- Email ([mailto:deoxxa@fknsrs.biz](deoxxa@fknsrs.biz))

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