@augu/collections

中文文档
1.1.0发布于 2021/09/12MITTypeScriptCommonJS零依赖近 30 天下载 9398

📝 Collections library made in TypeScript

原始使用文档
文档目录5 节
  1. 0.x builds
  2. Changes from 0.x -> 1.x
  3. Usage
  4. Maintainers
  5. License

@augu/collections · npm version Stars Workflow Status Build Status Build Size

📝 Collections library made in TypeScript

0.x builds

If you would like to use the 0.x builds or view it's source code, it'll be available under the 0.x branch and you can do so with npm i @augu/immutable.

Changes from 0.x -> 1.x

  • Pair and TimedQueue are remvoed
  • All deprecated methods are removed
  • Name is changed from @augu/immutable to @augu/collections

Usage

// CommonJS
const collections = require('@augu/collections');

// ES6+
import collections from '@augu/collections';

// Collection: Key-value pair that is an extension of [Map]
const coll = new collections.Collection(); // Create a empty one
const coll = new collections.Collection({
  // Create one with key-value pairs
  key: 'value',
  [Symbol('key')]: 'value',
});

coll.get('key'); // the value if added or undefined
coll.set('key', 'value'); // the value if the key isn't added

coll.filter((value) => value === 'value'); // Returns a Array of values if the predicate is true
coll.map((v) => v); // Returns a Array of values that are mapped by it's predicate function
coll.reduce((curr, acc) => curr + acc, 0); // Implementation of Array.reduce
coll.sort((a, b) => a - b); // Implementation of Array.sort

// Queue: Queue-based system with a timer extension to do time-based queues
const queue = new collections.Queue(); // Create a empty Queue
const queue = new collections.Queue(['a', 'b', 'c']); // Create one with values being added

queue.get(0); // Get a item from it's index
queue.add('c'); // Add a item to the queue
queue.delete(2); // Delete a item from it's index
queue.filter((c) => c === 'a'); // Filter out the queue from a predicate function
queue.map((u) => u); // Map out anything from a predicate function

Maintainers

License

@augu/collections is released under MIT. 💖

版本与发布记录

@augu/collections 共发布 14 个版本,首次发布于 2020/12/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.0latest2021/09/125 年前
1.0.122021/06/025 年前
1.0.112021/06/015 年前
1.0.102021/05/305 年前
1.0.92021/05/245 年前
1.0.82021/04/135 年前

关于 @augu/collections 的常见问题

@augu/collections 是什么?

📝 Collections library made in TypeScript

如何安装 @augu/collections?

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

@augu/collections 支持 TypeScript 吗?

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

@augu/collections 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@augu/collections 需要什么版本的 Node.js?

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

@augu/collections 可以商用吗?

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

@augu/collections 的下载量有多少?

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

@augu/collections 还在维护吗?

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