@augu/ 收藏 ~

📝 以 TypeScript 制作的收藏库
0.x 构建
如果您想要使用 0.x 构建或查看它的源代码,将在 0.x (中文(简体) ) 树枝,你可以这样做 npm i @augu/immutable。 。 。 .
从0.x - > 1.x起的变化
Pair财务报告和审定财务报表TimedQueue被重新删除- 所有贬值方法被删除
- 名称从
@augu/immutable改为@augu/collections
使用量
// 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
维护者
许可证
@ augu/ 收藏 以 麻省理工学院。 。 。