npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qzsy/arrow-parser

v0.2.2

Published

Parse arrow-format LLM structured output

Readme

@qzsy/arrow-parser

Parse arrow format LLM structured output into JavaScript objects. Schema-aware parsing supports nested objects and arrays (string arrays and object arrays with ITEM -> START ... END blocks).

Install

npm install @qzsy/arrow-parser

Quick start

Flat parse (scalars only)

import { parseFromLlm } from "@qzsy/arrow-parser";

const text = `DATA -> START
TITLE -> "Hello"
SCORE -> 95
DATA -> END`;

parseFromLlm(text);
// { TITLE: "Hello", SCORE: 95 }

Schema-aware parse (recommended)

Use with JSON Schema (from Zod via zod-to-json-schema):

import { parseToJson } from "@qzsy/arrow-parser";

const schema = {
  type: "object",
  properties: {
    strengths: { type: "array", items: { type: "string" } },
    suggestions: { type: "array", items: { type: "string" } },
  },
};

const text = `DATA -> START
STRENGTHS -> START
观察细致
逻辑清晰
STRENGTHS -> END
SUGGESTIONS -> START
建议加强练习
SUGGESTIONS -> END
DATA -> END`;

parseToJson(text, schema);
// { strengths: ["观察细致", "逻辑清晰"], suggestions: ["建议加强练习"] }

Object arrays

const schema = {
  type: "object",
  properties: {
    dimensions: {
      type: "array",
      items: {
        type: "object",
        properties: {
          description: { type: "string" },
          chartType: { type: "string" },
        },
      },
    },
  },
};

// LLM output:
// DIMENSIONS -> START
// DIMENSION -> START
// DESCRIPTION -> "正确率"
// CHART_TYPE -> BAR
// DIMENSION -> END
// DIMENSIONS -> END

API

| Export | Description | |--------|-------------| | parseToJson(text, schema) | Schema-guided parse into camelCase object | | parseFromLlm(text) | Flat KEY→value parse (uppercase keys) | | tryParsePartial(text) | Incremental / SSE-friendly partial parse | | expandArrowIntentLines(text) | Split lines & comma-separated pairs | | parseArrowQuotedValue(line, key) | Extract quoted string for a key | | fieldToArrowKey(name) | chartTypeCHART_TYPE | | arrayItemKey(name) | dimensionsDIMENSION | | JsonSchema | JSON Schema subset type |

Array format rules

| Type | Arrow format | |------|----------------| | string[] | KEY -> START + one plain-text line per item + KEY -> END | | object[] | KEY -> START + repeat ITEM -> START ... ITEM -> END + KEY -> END |

Do not output JSON arrays (KEY -> ["a","b"] or multi-line []).

Pipeline

Zod Schema → schemaToArrowPrompt (@qzsy/zod-to-arrow) → LLM → parseToJson → zod.safeParse

Testing

This package includes 2800+ generated test cases covering string arrays, object arrays, nested objects, bad JSON-array outputs, and round-trip stability.

pnpm test
pnpm test:coverage

Version

0.2.0 — schema-aware parseToJson, nested block fix, criteria/ITEM array key handling.

See also: 箭头格式规范.md