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

wssf-kage-js

v1.0.2

Published

TypeScript 函数式工具:柯里化、组合、高阶拦截、纯函数、中间件等 24 类模式,面向前端与 AI 流水线

Readme

Kage.js (wssf-kage-js)

面向 前端与 AI 业务 的 TypeScript 函数式工具集合:柯里化、组合、高阶拦截、纯函数、惰性/记忆化、中间件、策略、Option 等 24 类常见函数模式,便于组合提示词流水线、鉴权与降级、数据变换等逻辑。

  • 运行时零依赖(dependencies 为空)
  • 发布物仅含 dist(CJS + ESM + .d.ts),支持按需 import

npm 页面展示的是本 README。更完整的说明、分节示例见仓库内 Docusaurus 文档(pnpm run docs:dev 本地预览)。

安装

npm install wssf-kage-js
# 或
pnpm add wssf-kage-js

快速开始

柯里化与普通工具(curry、pipe、debounce …)

import { curry, pipe, debounce } from 'wssf-kage-js';

const add = (a: number, b: number, c: number) => a + b + c;
curry(add)(1)(2)(3); // => 6

pipe<string>((s) => s.trim(), (s) => s.toUpperCase())('  hi  '); // => 'HI'

const onResize = debounce(200)(() => console.log('resize'));

组合与 Prompt / 意图流水线(compose.ts)

import { sanitizePrompt, routeIntent, withFallback } from 'wssf-kage-js';

sanitizePrompt('  <b>x</b>  ');
routeIntent({ text: '美元汇率' });

const safe = withFallback('降级文案')(async () => {
  throw new Error('fail');
});
await safe();

纯函数与闭包

import { normalizeText, sumNumbers, createCounter } from 'wssf-kage-js';

normalizeText('  Hello  ');
sumNumbers([1, 2, 3]);

const c = createCounter(0);
c.increment();

异步与生成器

import { asyncMap, retryAsync, createRange, streamChunks } from 'wssf-kage-js';

await asyncMap([1, 2], async (n) => n * 2);
await retryAsync(async () => 'ok', 2);

[...createRange(1, 3)];

for await (const x of streamChunks(['a', 'b'], 0)) {
  console.log(x);
}

导出结构(与源码目录对应)

| 模块 | 代表能力 / 符号 | |------|------------------| | currying | curry、compose、pipe、get/set、map/filter/reduce、debounce、throttle、logger、request、validate … | | compose | composePipe、sanitizePrompt、safetyGate、routeIntent、tokenManager、buildPrompt、dataPipeline、processSearchList … | | higherOrder | withPermission、withPerformance、withTokenAudit、withFallback、withSanitizer、withLock、withAuditTrail、withUIFormat | | pureFunction | sumNumbers、normalizeText、calculateWeightedScore | | closureFunction | createCounter、createAccumulator | | partialFunction | partial、partialRight | | decoratorFunction | withLogging、withRetry | | middlewareFunction | runMiddleware、createLogMiddleware | | strategyFunction | createStrategyRunner、financeStrategy、codingStrategy、defaultStrategy | | guardFunction | assertDefined、assertNonEmptyArray、isRecord | | predicateFunction | isNonEmptyString、isPositiveNumber、andPredicate、orPredicate | | transformerFunction | toUserViewModel、transformCollection | | reducerFunction | counterReducer、reduceItems | | recursiveFunction / tailRecursiveFunction | factorialRecursive、flattenTree、factorialTailRecursive、sumTailRecursive | | lazyFunction | deferValue、createOnceResolver、mapLazyValue | | memoizedFunction | memoizeUnary、clearMemoizedCache | | callbackFunction | mapWithCallback、forEachWithCallback、createDelayedCallback | | asyncFunction | delay、asyncMap、retryAsync | | generatorFunction / asyncGeneratorFunction | createRange、iterateWords、streamChunks、collectAsyncGenerator | | factoryFunction | createFormatter、createThresholdChecker | | pointFreeFunction | mapValues、filterValues、joinWith、pointFreeUserNames | | monadFunction | some、none、mapOption、flatMapOption、getOptionOrElse |

完整分节说明与「每函数一例」见仓库 docs/function-types/。

本地开发与文档

pnpm install
pnpm run build          # 产出 dist/
pnpm test               # 测试(若已配置)
pnpm run docs:dev       # Docusaurus 文档站
pnpm run docs:site:build

TypeDoc 默认输出目录为 typedoc-html/(见 typedoc.json),与文档站 Markdown 源码分离。

许可证

MIT

更新日志

1.0.2

  • 修正 npm README:与当前 src 导出一致,移除不存在的 lodash 式 API 描述。

1.0.1

  • 发版指向 npm 官方 registry;安装仍可使用国内镜像(见仓库 .npmrc 说明)。

1.0.0

  • 首次公开发布。