open-index/open-npm huggingface dataset:
npm package: @soukadao/frontmatter-ts
Description: A frontmatter parser for TypeScript. Parses YAML frontmatter delimited by `---` from text content.
Latest version: 0.0.1

# @soukdao/frontmatter-ts

A frontmatter parser for TypeScript. Parses YAML frontmatter delimited by `---` from text content.

Built on top of [@soukadao/yaml-ts](https://www.npmjs.com/package/@soukadao/yaml-ts).

## Installation

```bash
bun add @soukdao/frontmatter-ts
```

## Usage

```typescript
import { parse } from "@soukdao/frontmatter-ts";

const source = `---
title: Hello World
tags:
  - typescript
  - yaml
draft: false
---
# Hello World

This is the body content.`;

const result = parse(source);
// result.data  => { title: "Hello World", tags: ["typescript", "yaml"], draft: false }
// result.content => "# Hello World\n\nThis is the body content."
```

`parse` returns `null` if the input has no frontmatter.

```typescript
parse("No frontmatter here"); // => null
```

## API

### `parse(source: string): FrontmatterResult | null`

Parses a string containing YAML frontmatter.

- Returns `{ data, content }` if frontmatter is found
- Returns `null` if no frontmatter is detected

### Types

```typescript
interface FrontmatterResult {
  data: { [key: string]: YamlValue };
  content: string;
}
```

### Errors

- `FrontmatterError` — base error class
- `ExtractError` — thrown on extraction failures

## License

MIT
npm package: @soukadao/yaml-ts
Description: A YAML 1.2.2 parser written in TypeScript.
Latest version: 0.0.5

# yaml-ts

A YAML 1.2.2 parser written in TypeScript.

## Install

```sh
npm install yaml-ts
```

## Usage

```ts
import { parse } from "yaml-ts";

parse("hello: world");
// { hello: "world" }

parse("- 1\n- 2\n- 3");
// [1, 2, 3]

parse("count: 42");
// { count: 42 }

parse("enabled: true");
// { enabled: true }
```

## Supported Features

- Plain scalars (strings, integers, floats, booleans, null)
- Block mappings (`key: value`)
- Block sequences (`- item`)
- Nested structures
- Single-quoted strings (`'...'`)
- Double-quoted strings with escape sequences (`"..."`)
- Flow sequences (`[a, b, c]`)
- Flow mappings (`{a: 1, b: 2}`)
- Literal block scalars (`|`, `|-`, `|+`)
- Folded block scalars (`>`, `>-`, `>+`)
- Document markers (`---`, `...`)
- Comments (`#`)

## YAML 1.2.2 Core Schema

Scalar values are resolved according to the [YAML 1.2.2 Core Schema](https://yaml.org/spec/1.2.2/#103-core-schema):

| YAML | TypeScript |
|---|---|
| `null`, `Null`, `NULL`, `~` | `null` |
| `true`, `True`, `TRUE` | `true` |
| `false`, `False`, `FALSE` | `false` |
| `42`, `-17`, `+5` | `number` (integer) |
| `0o17` | `number` (octal) |
| `0xFF` | `number` (hex) |
| `3.14`, `1.5e+3` | `number` (float) |
| `.inf`, `-.inf` | `Infinity`, `-Infinity` |
| `.nan` | `NaN` |
| `'42'`, `"true"` | `string` (quoted = no type resolution) |

## Development

```sh
bun install
bun run test
bun run coverage
bun run build
```

## License

MIT