@flaghoist/core

中文文档
0.2.1发布于 2026/10/31Apache-2.0TypeScriptESM + CJS零依赖近 30 天下载 1万

Flag schema, evaluation engine, and storage/auth interfaces for Flaghoist. Zero dependencies.

原始使用文档

@flaghoist/core

The evaluation engine behind Flaghoist. Flag schema, targeting rules, percentage rollouts, and the storage and auth interfaces the rest of the packages build on.

Zero dependencies, and no knowledge of HTTP or of where flags are stored.

You usually get this as a dependency of @flaghoist/server rather than installing it yourself. Install it directly if you are writing a storage adapter, or if you want to evaluate flags in process without running a server.

npm install @flaghoist/core
import { evaluate, createFlag } from '@flaghoist/core'

const flag = createFlag('new-checkout', {
  enabled: true,
  rollout: { percentage: 25 },
})

const result = evaluate(flag.flag, { targetingKey: 'user-123', plan: 'pro' })
// { value: true, reason: 'SPLIT', ... }

How evaluation works

Rules are ordered and the first match wins, with conditions inside a rule combined with AND. If no rule matches, the percentage rollout decides.

Rollouts bucket users with SHA-256 over the targeting key, so the same user always lands in the same place. Going from 10 percent to 20 percent adds people without reshuffling the ones already in.

Flags are boolean. There are no multivariate values, and evaluation returns a reason so you can tell why you got what you got.

Status

Beta. The core is feature-complete and ready for real projects. The API can still change before 1.0, and every breaking change is called out in the changelog, so pin your versions and read the notes when you upgrade. If something breaks, an issue is genuinely useful.

Apache-2.0. Part of Flaghoist.

版本与发布记录

@flaghoist/core 共发布 5 个版本,首次发布于 2026/08/22;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.2.1latest2026/10/3115 天前
0.2.02026/09/271 个月前
0.1.22026/08/252 个月前
0.1.12026/08/222 个月前
0.1.02026/08/222 个月前

关于 @flaghoist/core 的常见问题

@flaghoist/core 是什么?

Flag schema, evaluation engine, and storage/auth interfaces for Flaghoist. Zero dependencies.

如何安装 @flaghoist/core?

在项目目录运行 npm install @flaghoist/core,或使用 pnpm add / yarn add / bun add。

@flaghoist/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flaghoist/core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@flaghoist/core 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@flaghoist/core 可以商用吗?

@flaghoist/core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@flaghoist/core 的下载量有多少?

根据 npm 官方下载统计,@flaghoist/core 在 2026/10/15 – 2026/11/13 这 30 天内被下载 10,134 次,日均约 338 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flaghoist/core 还在维护吗?

最新版本 0.2.1 发布于 2026/10/31(15 天前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/08/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。