# hyper-path

> Traverse a hyper api

Latest version **1.0.16** (published 2015-02-02) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.16 |
| Published | 2015-02-02 |
| First published | 2014-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Cameron Bytheway |
| Maintainers | camshaft |
| Keywords | hyper, json, path, traverse |

## Links

- npm: https://www.npmjs.com/package/hyper-path
- Repository: https://github.com/hypergroup/hyper-path
- Issues: https://github.com/hypergroup/hyper-path/issues
- npm.io page: https://npm.io/package/hyper-path

## Dependencies (2)

- [type-component](https://npm.io/package/type-component.md) 0.0.1
- [require-component](https://npm.io/package/require-component.md) ~0.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.16 (latest) — 2015-02-02
- 1.0.15 — 2015-01-12
- 1.0.14 — 2015-01-03
- 1.0.13 — 2015-01-03
- 1.0.12 — 2015-01-03
- 1.0.11 — 2014-12-11
- 1.0.10 — 2014-12-05
- 1.0.9 — 2014-11-14
- 1.0.8 — 2014-11-07
- 1.0.6 — 2014-10-26
- 1.0.5 — 2014-10-24
- 1.0.4 — 2014-10-24
- 1.0.3 — 2014-10-24
- 1.0.2 — 2014-10-23
- 1.0.1 — 2014-10-22
- … 5 more at https://npm.io/package/hyper-path/versions

## README

hyper-path [![Build Status](https://travis-ci.org/hypergroup/hyper-path.png)](https://travis-ci.org/hypergroup/hyper-path)
==========

Traverse a hyper api

Installation
------------

### Node

```sh
$ npm install hyper-path
```

### Component

```sh
$ component install hypergroup/hyper-path
```

Usage
-----

```js
var client = require('hyper-path');

/**
 * create a agent
 */

function agent(fn) {
  // make a request to the root of the api here and call
  // fn(err, body);
}

agent.get = function(href, fn) {
  // make a request to the href and call
  // fn(err, body);
}

client('.path.to.desired.property', agent)
  .on(function(err, property) {
    // property will be set to the value at the end of the passed path, deliminated with '.'
    // if any of the intermediate properties are undefined a short-circuit will occur and return `undefined`
  });
```

Agents can offer subscriptions and call `fn` anytime the data changes at the `href`. The methods should return an `unsubscribe` function so the request can clean itself up when calling `off`.

```js
function agent(fn) {
  // make a request here
  return function unsubscribe() {
    // implement me!
  }
}

agent.get = function(href, fn) {
  // make a request here
  return function unsubscribe() {
    // implement me!
  }
}

var req = client('.path.to.desired.property', agent)
  .on(function(err, property) {
    // this function will be called anytime any intermediate paths change
  });

// stop listening to api changes
req.off();
```

Clients can also use a scope for requests with the `scope` method.

```js
client('local.remote', agent)
  .scope({local: {href: '/path/to/resource'}})
  .on(function(err, remote) { });
```

The function passed to on will be refreshed anytime the scope is updated.

```js
var req = client('local.remote', agent)
  .on(function(err, remote) { });

req.scope({local: {href: '/new/path/to/other/resource'}});
```

Tests
-----

```sh
$ npm install
$ npm test
```

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