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

@h-ai/datapipe

v0.1.0-alpha9

Published

Data processing pipeline module for hai-framework: clean, chunk, transform

Readme

@h-ai/datapipe

数据处理管线模块,提供文本清洗(clean)、分块(chunk)和可组合管线(pipeline)功能。纯函数模块,无需初始化。

支持的功能

| 功能 | 说明 | | -------- | ----------------------------------------------------------- | | 文本清洗 | 移除 HTML 标签、URL、Email,标准化空白,自定义正则替换 | | 文本分块 | 句子、段落、Markdown 标题、分页符、字数、字符、自定义分隔符 | | 管线组合 | 链式组合清洗 → 转换 → 分块 → 分块后处理,一次执行 |

快速开始

import { datapipe, HaiDatapipeError } from '@h-ai/datapipe'

// 直接清洗
const cleaned = datapipe.clean('<p>Hello</p>', { removeHtml: true })

// 按 Markdown 标题分块
const chunks = datapipe.chunk(text, { mode: 'markdown', maxSize: 2000 })

// 管线模式(链式组合多步操作)
const result = await datapipe.pipeline()
  .clean({ removeHtml: true, removeUrls: true })
  .transform(text => text.toLowerCase())
  .chunk({ mode: 'paragraph', maxSize: 1000, overlap: 100 })
  .chunkTransform(chunks => chunks.filter(c => c.content.length > 50))
  .run(rawText)

分块模式

| 模式 | 说明 | | --------- | -------------------------------- | | sentence | 按句子分块 | | paragraph | 按段落分块 | | markdown | 按 Markdown 标题分块 | | page | 按分页符分块 | | word | 按字数分块 | | character | 按字符数分块 | | custom | 自定义分隔符(需提供 separator) |

错误处理

所有操作返回 HaiResult<T>,通过 result.success 判断成功或失败。错误码为字符串格式 hai:datapipe:NNN

const result = datapipe.chunk(text, { mode: 'custom' })
if (!result.success) {
  switch (result.error.code) {
    case HaiDatapipeError.MISSING_SEPARATOR.code:
      // mode='custom' 时需要提供 separator
      break
    case HaiDatapipeError.CONFIG_ERROR.code:
      // 配置参数校验失败
      break
  }
}

测试

pnpm --filter @h-ai/datapipe test

License

Apache-2.0