@chronicstone/array-query

中文文档
1.0.5发布于 2024/10/09MITTypeScriptESM + CJS零依赖近 30 天下载 2883

A simple and lightweight array query library

原始使用文档
文档目录5 节
  1. Query JavaScript arrays with ORM-like syntax, benefiting fr…
  2. Key Features:
  3. INSTALLATION
  4. USAGE EXAMPLE
  5. License

Array-Query

npm version npm downloads bundle JSDocs License

Query JavaScript arrays with ORM-like syntax, benefiting from excellent type-safety & developer experience.

Key Features:

  • 🛠 Type-safe Querying: Design your queries with strong typing (typed sort / search / filter keys & output)
  • 📄 Pagination: Easily paginate through large datasets with built-in support.
  • 🔎 Full-text Search: Perform comprehensive searches across multiple fields in your data.
  • 🧭 Advanced Filtering: Apply complex filters with various match modes for precise data retrieval. Supports logical grouping, nested conditions, and array matching.
  • 🔢 Flexible Sorting: Order results based on any field, with support for multiple sort criteria.
  • 🚀 Lightweight and Fast: Queries stay super fast, even with large datasets.
  • 🧩 Zero Dependencies: Completely self-contained with no external dependencies, ensuring a small bundle cost

INSTALLATION

// npm
npm install @chronicstone/array-query

// yarn
yarn add @chronicstone/array-query

// pnpm
pnpm add @chronicstone/array-query

// bun
bun add @chronicstone/array-query

USAGE EXAMPLE

import { query } from '@chronicstone/array-query'

const users = [
  { id: 1, fullName: 'John Doe', email: '[email protected]', age: 30, status: 'active', roles: ['admin'], createdAt: '2023-01-01' },
  { id: 2, fullName: 'Jane Smith', email: '[email protected]', age: 28, status: 'inactive', roles: ['user'], createdAt: '2023-02-15' },
  { id: 3, fullName: 'Bob Johnson', email: '[email protected]', age: 35, status: 'active', roles: ['user', 'manager'], createdAt: '2023-03-20' },
  // ... more users
]

const { totalRows, totalPages, rows } = query(users, {
  // Pagination
  page: 1,
  limit: 10,

  // Sorting
  sort: [
    { key: 'age', dir: 'desc' },
    { key: 'fullName', dir: 'asc' }
  ],

  // Searching
  search: {
    value: 'john',
    keys: ['fullName', 'email']
  },

  // Filtering
  filter: [
    { key: 'status', matchMode: 'equals', value: 'active' },
    { key: 'age', matchMode: 'greaterThan', value: 25 },
  ]
})

This example demonstrates pagination, multi-field sorting, full-text searching, and complex filtering with nested conditions and array field matching.

License

MIT License © 2023-PRESENT Cyprien THAO

版本与发布记录

@chronicstone/array-query 共发布 15 个版本,首次发布于 2024/07/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.5latest2024/10/092 年前
1.0.42024/10/082 年前
1.0.32024/10/082 年前
1.0.22024/10/082 年前
1.0.12024/07/192 年前
1.0.02024/07/192 年前

关于 @chronicstone/array-query 的常见问题

@chronicstone/array-query 是什么?

A simple and lightweight array query library

如何安装 @chronicstone/array-query?

在项目目录运行 npm install @chronicstone/array-query,或使用 pnpm add / yarn add / bun add。

@chronicstone/array-query 支持 TypeScript 吗?

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

@chronicstone/array-query 支持 ESM 还是 CommonJS?

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

@chronicstone/array-query 可以商用吗?

@chronicstone/array-query 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@chronicstone/array-query 的下载量有多少?

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

@chronicstone/array-query 还在维护吗?

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