# @internetarchive/field-parsers

> Field parsers for Internet Archive metadata fields.

Latest version **1.2.0** (published 2026-07-27) · AGPL-3.0-only license · 0 weekly downloads

## Install

```sh
npm install @internetarchive/field-parsers
pnpm add @internetarchive/field-parsers
yarn add @internetarchive/field-parsers
bun add @internetarchive/field-parsers
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-07-27 |
| First published | 2021-05-27 |
| Weekly downloads | 0 |
| License | AGPL-3.0-only |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 184.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Internet Archive |
| Maintainers | bfalling, mitraardron, vbanos, kngenie, iisa, cdrini, nsharma123, dualcnhq, latonv, ibnesayeed, tracey.pooh, jim-at-ia, jeffwklein, rebecca-shoptaw, jbuckner, dhallia |

## Links

- npm: https://www.npmjs.com/package/@internetarchive/field-parsers
- npm.io page: https://npm.io/package/@internetarchive/field-parsers

## Recent versions

- 1.2.0 (latest) — 2026-07-27
- 1.2.0-beta.0 (beta) — 2026-07-06
- 0.1.5-alpha-webdev7387.0 (alpha) — 2025-06-18
- 0.1.4 (canary) — 2023-08-23
- 1.1.1 — 2026-07-06
- 1.1.0 — 2026-07-02
- 1.0.0 — 2025-06-24
- 0.1.4-rc.0 — 2025-06-03
- 0.1.3-alpha1 — 2023-08-18
- 0.1.4-alpha.1 — 2023-04-20
- 0.1.3 — 2022-04-19
- 0.1.2 — 2022-04-19
- 0.1.2-alpha.2 — 2022-04-19
- 0.1.2-alpha.1 — 2022-04-19
- 0.1.1 — 2022-01-20
- … 3 more at https://npm.io/package/@internetarchive/field-parsers/versions

## README

[![Build Status](https://travis-ci.com/internetarchive/iaux-field-parsers.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-field-parsers) [![codecov](https://codecov.io/gh/internetarchive/iaux-field-parsers/branch/main/graph/badge.svg?token=IMK8Q3SCK1)](https://codecov.io/gh/internetarchive/iaux-field-parsers)

# Internet Archive Field Parsers

Parsers to convert strings from Internet Archive API responses to their native javascript equivalents.

Each parser implements the `FieldParserInterface`:
```
export type FieldParserRawValue = string | number | boolean;

export interface FieldParserInterface<T> {
  /**
   * Parse the raw value and return a value of type T or undefined if unparseable
   *
   * @param rawValue T | undefined
   */
  parseValue(rawValue: FieldParserRawValue): T | undefined;
}
```
They are responsible for parsing the input and returning the appropriate value or `undefined`.

## Usage

Instantiate a parser or use the shared instance:
```
const parser = new BooleanParser()
parser.parse('true') => true

BooleanParser.shared.parse('false') => false
```

See tests for more usage examples.

## Available Parsers:

1. `Boolean`
2. `Byte` - a number in bytes
3. `Date` - parses the various Internet Archive date formats
4. `Duration` - Parses `hh:mm:ss.ms` and `ss.ms` formats to seconds
5. `MediaType` - Internet Archive media types
6. `Number`
7. `PageProgression` - Internet Archive page progression (right to left, left to right)
8. `String`

## Testing with Web Test Runner
To run the suite of Web Test Runner tests, run
```bash
yarn run test
```

To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run

```bash
yarn run test:watch
```

## Linting with ESLint, Prettier, and Types
To scan the project for linting errors, run
```bash
yarn run lint
```

You can lint with ESLint and Prettier individually as well
```bash
yarn run lint:eslint
```
```bash
yarn run lint:prettier
```

To automatically fix many linting errors, run
```bash
yarn run format
```

You can format using ESLint and Prettier individually as well
```bash
yarn run format:eslint
```
```bash
yarn run format:prettier
```

## Tooling configs

For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.

If you customize the configuration a lot, you can consider moving them to individual files.

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