Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Nov 29, 2024
1 parent 98d59cd commit f8ffa11
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# Propathy
# Propathy

[![version](https://img.shields.io/npm/v/propathy?label=npm)](https://www.npmjs.com/package/propathy)
[![downloads](https://img.shields.io/npm/dm/propathy?label=downloads)](https://www.npmjs.com/package/propathy)
[![license](https://img.shields.io/npm/l/propathy?label=license)](/LICENSE)

Operate objects via dot path.

## Install

```shell
pnpm i propathy
```

## Usage

```ts
import { getProperty, setProperty, hasProperty, deleteProperty } from "propathy";

const target = { foo: { bar: [{ baz: "qux" }] } };

getProperty(target, "foo.bar[0].baz");
// "qux"

getProperty(target, "foo.bar[1]");
// undefined

setProperty(target, "foo.bar[0].baz", "kzr");
console.log(target);
// { foo: { bar: [{ baz: "kzr" }] } }

hasProperty(target, "foo.bar[0].baz");
// true

hasProperty(target, "foo.bar[1]");
// false

deleteProperty(target, "foo.bar[0].baz");
// true

console.log(target);
// { foo: { bar: [{}] } }
```

0 comments on commit f8ffa11

Please sign in to comment.