# path-expression

> Property path creation from a code expression

Latest version **1.0.3** (published 2021-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install path-expression
pnpm add path-expression
yarn add path-expression
bun add path-expression
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-04-12 |
| First published | 2021-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Charles Hetier |
| Maintainers | charleshetier |
| Keywords | binding, expression, parser, vanilla |

## Links

- npm: https://www.npmjs.com/package/path-expression
- Repository: https://github.com/charleshetier/path-expression
- Homepage: https://github.com/charleshetier/path-expression#readme
- Issues: https://github.com/charleshetier/path-expression/issues
- npm.io page: https://npm.io/package/path-expression

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-04-12
- 1.0.2 — 2021-04-12
- 1.0.1 — 2021-04-12
- 1.0.0 — 2021-04-12

## README

# path-expression
Property path creation from an expression

Basicaly converts expression
```typescript
o => o.foo.bar
``` 
into 
```typescript
['foo', 'bar']
```

# Installation
using npm :
```
npm i path-expression
```

or using yarn :
```
yarn add path-expression
```

## Usage
for basic case :
```typescript
import {parsePathExpression} from 'path-expression';

const result = parsePathExpression(o => o.foo);
expect(result).toEqual(['foo']);
```

...and more complex cases :
```typescript
import {parsePathExpression} from 'path-expression';

const myVar1 = 5;
const myVar2 = 'bar';
const result = parsePathExpression(o => o[1][myVar1].foo[myVar2]);

expect(result).toEqual([1, 5, 'foo', 'bar']);
```

## Compatibility
The [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) object support is required.

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