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

@kordar-lib/base

v2.0.0

Published

基础工具与抽象:包含表格上下文与查询、权限校验 Hook、条件过滤器、表单/排序/权限树等页面辅助方法,以及通用组件类型定义。

Readme

@kordar-lib/base

基础工具与抽象:包含表格上下文与查询、权限校验 Hook、条件过滤器、表单/排序/权限树等页面辅助方法,以及通用组件类型定义。

模块概览

  • 条件过滤(conditions)
    • 注册条件处理器(registerConditionHandler)
    • 预置 LIKE、NEQ 等处理器;默认回退 EQ
    • 可用于本地数据的筛选与分页
  • 表格上下文(table)
    • TableContext 接口与 DefaultTableContext 实现
    • DefaultQuery:注入 fetch 后统一拼接固定条件/排序
    • CheckboxSelection:表格多选的值管理
    • 事件发布器(publishevent):注册/触发组件间回调
  • Hook(hook)
    • 权限校验(checkaccess):AND/OR/FUNC 三种校验方式
    • 弹窗/选择/重定向等实用 Hook 定义与组合
  • 页面辅助(page)
    • 表单项/搜索项定义与通用 helper(排序、默认条件/排序、权限树等)
  • 组件类型(components)
    • 面包屑等通用 UI 的类型定义

快速使用

按需引入:

import { DefaultTableContext } from '@kordar-lib/base'
import type { TableConfig } from '@kordar-lib/base'

const cfg: TableConfig = {
  name: 'UserTable',
  defaultPageNumber: 1,
  defaultPageSize: 20,
  fetch: (searchBody) => api.listUsers(searchBody),
}

const ctx = new DefaultTableContext(cfg)
ctx.search()

注册条件处理器:

import executeCondition, { registerConditionHandler } from '@kordar-lib/base'

registerConditionHandler('EQ', { execute: (item, key, val) => item[key] === val })
const { data, count } = executeCondition(list, [{ key: 'name', type: 'LIKE', value: 'ab' }], 1, 20)

权限校验 Hook:

import createCheckAccess from '@kordar-lib/base'

const access = createCheckAccess([
  { key: 'user.edit', type: 'AND', value: ['user.update'] }
], { AndCan: Admin.can, OrCan: Admin.orCan, Permissions: Admin.permissions })

access.can('user.edit')

页面辅助:

import { toOptions, toSorts, defaultConditions } from '@kordar-lib/base'

toOptions({ a: 'A', b: 'B' })
toSorts('name', 'descending')
defaultConditions(undefined, [{ key: 'enabled', type: 'EQ', value: 1 }])

构建与类型(Monorepo:npm)

在仓库根目录执行:

npm install
npm run -w @kordar-lib/base build

类型检查:

npm exec -w @kordar-lib/base -- tsc -p tsconfig.json --noEmit