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

xunhuan

v0.3.1

Published

小而快的迭代器库

Downloads

16

Readme

xunhuan

小而快的迭代器库。

import * as X from 'xunhuan'

X.range(1000).c(
  X.filter(x => x % 2 === 0),
  X.map(x => x * x),
  X.skipWhile(x => x < 1000),
  X.sum,
)

特性

  • 小:压缩后 <5kB。且用 Iter.c 方法实现链式调用,使所有方法都支持 tree shaking,例如上面代码构建并压缩后 <1kB。
  • 快:受 Rust 启发,使用内部迭代提高性能,一些方法还有专门优化。根据 benchmark,本库比类似库都快,仅次于原生的循环。
  • 每个方法都有文档与经过测试的示例。加上全面的模糊测试,代码覆盖率达到 100%
  • 自带的支持,无需用元组等模拟键值对。filter 等方法会保留原有的键。
  • 部分迭代器支持随机访问,可以二分查找之类。且类型安全,编译期可以检测出迭代器是否可随机访问。
  • 部分迭代器支持双端迭代,允许反向迭代。且同样类型安全
  • 由 TypeScript 写成,类型推导能力强。例如 filter 等方法可以自动收窄。
  • 迭代器惰性求值、不可变,支持无限长。
  • 无运行时依赖。

Benchmark

native loop - test/main.bench.ts > flatMap
  1.99x faster than xunhuan
  2.48x faster than lodash
  2.90x faster than iterare
  3.02x faster than lazy.js
  3.04x faster than immutable
  5.54x faster than extra-iterable
  12.88x faster than native array method

native loop - test/main.bench.ts > range
  16.75x faster than xunhuan
  22.28x faster than lazy.js
  25.41x faster than lodash
  26.94x faster than immutable
  75.79x faster than extra-iterable

native loop - test/main.bench.ts > zip
  18.00x faster than xunhuan
  28.99x faster than lazy.js
  30.01x faster than iterare
  30.46x faster than lodash
  57.78x faster than extra-iterable
  98.16x faster than immutable