# minim-parse-result

> Minim Parse Result Namespace

Latest version **0.11.1** (published 2019-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install minim-parse-result
pnpm add minim-parse-result
yarn add minim-parse-result
bun add minim-parse-result
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.1 |
| Published | 2019-03-26 |
| First published | 2015-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 1 |
| Unpacked size | 9.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 79 |
| Author | Apiary.io |
| Maintainers | apiary-sre, danielgtaylor, kylef, pksunkara, smizell, zdne |

## Links

- npm: https://www.npmjs.com/package/minim-parse-result
- Repository: https://github.com/apiaryio/api-elements.js
- Homepage: https://github.com/apiaryio/api-elements.js/tree/master/packages/minim-parse-result
- Issues: https://github.com/apiaryio/api-elements.js/issues
- npm.io page: https://npm.io/package/minim-parse-result

## Dependencies (1)

- [minim-api-description](https://npm.io/package/minim-api-description.md) ^0.9.1

## Recent versions

- 0.11.1 (latest) — 2019-03-26
- 0.11.0 — 2019-02-26
- 0.10.1 — 2018-05-23
- 0.10.0 — 2017-12-04
- 0.9.0 — 2017-11-03
- 0.8.0 — 2017-08-07
- 0.7.0 — 2017-07-11
- 0.6.1 — 2017-07-03
- 0.6.0 — 2017-06-29
- 0.5.0 — 2017-05-12
- 0.4.1 — 2017-05-10
- 0.4.0 — 2017-04-04
- 0.3.0 — 2017-03-30
- 0.2.2 — 2016-04-28
- 0.2.1 — 2015-11-30
- … 2 more at https://npm.io/package/minim-parse-result/versions

## README

# Minim Parse Result Namespace

[![NPM version](https://img.shields.io/npm/v/minim-parse-result.svg)](https://www.npmjs.org/package/minim-parse-result)
[![License](https://img.shields.io/npm/l/minim-parse-result.svg)](https://www.npmjs.org/package/minim-parse-result)

This library provides an interface to the [Refract Parse Result namespace](https://github.com/refractproject/refract-spec/blob/master/namespaces/parse-result-namespace.md).

It extends upon the base types as defined in [Minim](https://github.com/refractproject/minim) and should be used with the [minim-api-description](https://github.com/apiaryio/api-elements.js/tree/master/packages/minim-api-description) package.

## Install

```sh
npm install minim-parse-result
```

## Usage

```js
import minim from 'minim';
import parseResult from 'minim-parse-result';

const namespace = minim.namespace()
  .use(parseResult);

// Initialize elements directly
const ParseResult = namespace.getElementClass('parseResult');
let category = new ParseResult();
```

## Elements

### ParseResult ([ArrayElement](https://github.com/refractproject/minim#arrayelement))
An element that holds information about the result of parsing an input.

#### Properties

##### parseResult.annotations
Get an array element of all child elements with the element name `annotation`. This property is **read-only**.

```js
let annotations = parseResult.annotations;
```

##### parseResult.api
Get the first child element with an element name of `category` and a class name of `api`. This property is **read-only**.

```js
let api = parseResult.api;
```

##### parseResult.errors
Get an array element of all child elements with the element name `annotation` and class name `error`. This property is **read-only**.

```js
let errors = parseResult.errors;
```

##### parseResult.warnings
Get an array element of all child elements with the element name `annotation` and class name `warning`. This property is **read-only**.

```js
let warnings = parseResult.warnings;
```

### Annotation ([StringElement](https://github.com/refractproject/minim#stringelement))
An element that annotates the input or parse result with additional information, such as warnings or errors. The content of the annotation contains the text:

```js
console.log(`Warning: ${annotation.toValue()}`);
```

#### Properties

##### annotation.code
An optional warning, error, or other numerical code. This is a shortcut for accessing the element's `code` attribute.

```js
// Show the code
console.log(annotation.code.toValue());

// Set the code
annotation.code = 123;
```

### SourceMap (Element)
An element which maps a component of the parse result to the input via a given list of file locations and lengths.

The content of the source map is an array of locations.

#### Convenience function
You can use a convenience property to retrieve the sourceMap from any element.

```js
// Print [[1, 2]]
console.log(element.sourceMapValue);
```

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