# segmented-property

> A utility for immutably setting and getting properties on JavaScript objects as slash-delimited paths.

Latest version **4.0.0** (published 2023-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install segmented-property
pnpm add segmented-property
yarn add segmented-property
bun add segmented-property
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-10-27 |
| First published | 2017-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Marius Lundgård |
| Maintainers | mariuslundgard |

## Links

- npm: https://www.npmjs.com/package/segmented-property
- Repository: https://github.com/mariuslundgard/segmented-property
- Homepage: https://github.com/mariuslundgard/segmented-property#readme
- Issues: https://github.com/mariuslundgard/segmented-property/issues
- npm.io page: https://npm.io/package/segmented-property

## Recent versions

- 4.0.0 (latest) — 2023-10-27
- 3.0.1 (next) — 2021-02-22
- 3.0.3 — 2021-02-22
- 3.0.0 — 2021-02-22
- 2.0.4 — 2018-07-18
- 2.0.3 — 2018-07-18
- 2.0.2 — 2017-11-30
- 2.0.1 — 2017-11-25
- 2.0.0 — 2017-11-25
- 1.0.2 — 2017-04-24
- 1.0.1 — 2017-04-24
- 1.0.0 — 2017-04-24

## README

# segmented-property

A utility for immutably setting and getting properties on JavaScript objects as slash-delimited paths.

```sh
npm install segmented-property
```

[![npm version](https://img.shields.io/npm/v/segmented-property.svg?style=flat-square)](https://www.npmjs.com/package/segmented-property)

## Usage

```js
import {get, set} from 'segmented-property'

const obj1 = {foo: {bar: 1}}
const obj2 = set(obj1, 'foo/bar', 2)

console.log(get(obj1, 'foo/bar')) // 1
console.log(get(obj2, 'foo/bar')) // 2
```

## API

#### `get(source, [key])`

Gets a value.

#### `set(source, [key], value)`

Sets a new value and returns a new object.

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