# @stackmeister/json-ref

> @stackmeister/json-ref ==========================

Latest version **0.1.5** (published 2022-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @stackmeister/json-ref
pnpm add @stackmeister/json-ref
yarn add @stackmeister/json-ref
bun add @stackmeister/json-ref
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2022-11-09 |
| First published | 2022-11-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 36.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | torbenkoehn |

## Links

- npm: https://www.npmjs.com/package/@stackmeister/json-ref
- Repository: https://github.com/StackmeisterGmbH/typescript-packages
- Homepage: https://github.com/StackmeisterGmbH/typescript-packages#readme
- Issues: https://github.com/StackmeisterGmbH/typescript-packages/issues
- npm.io page: https://npm.io/package/@stackmeister/json-ref

## Dependencies (5)

- [node-fetch](https://npm.io/package/node-fetch.md) ^3.2.10
- [@stackmeister/uri](https://npm.io/package/@stackmeister/uri.md) ^0.1.5
- [@stackmeister/clone](https://npm.io/package/@stackmeister/clone.md) ^0.1.4
- [@stackmeister/types](https://npm.io/package/@stackmeister/types.md) ^0.1.4
- [@stackmeister/json-pointer](https://npm.io/package/@stackmeister/json-pointer.md) ^0.1.3

## Recent versions

- 0.1.5 (latest) — 2022-11-09
- 0.1.4 — 2022-11-09

## README

@stackmeister/json-ref
==========================

Typing and utilities for working with JSON-Schema Refs (`{ $ref: '' }`)

Install
=======

```bash
// Yarn
yarn add @stackmeister/json-ref

// NPM
npm i @stackmeister/json-ref
```

TypeScript typings are included (No `@types/` package needed)

Usage
=====

### Dereferencing a value

The most important key function of this library is **dereferencing**.

It takes any value and will recursively resolve any JSON-refs found in it.

It supports all common operations regarding `$id` and `$anchor` in the JSON-schema standard.

Notice the input value doesn't have to be a JSON-Schema! Dereferencing can be used on any
JavaScript value freely.

```ts
import type { deref } from '@stackmeister/json-ref'

const user = {
  properties: {
    email: { $ref: '#/$defs/email' },
    password: { type: 'string', minLength: 5 },
  },
  $defs: {
    email: { type: 'string' }
  }
}

const resolvedUser = await deref(user)
```

Resolving external URLs, handling internal ID/Base-URLs via `$id`, internal anchors etc. are all fully supported.

It also comes with proper typing which allows you to cleanly remove refs from a type-definition
once resolved.

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