1.6.5 • Published 6 months ago

micro-class v1.6.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

MICRO CLASS

简介

扩展 js/ts工具类数据结构

安装

npm i micro-class
# or
yarn i micro-class
# or
pnpm i micro-class

案例

/* 并查集 */
import { UnionQuerySet } from "micro-class";

// 初始化并查集,设置默认权重为 0,
const unionQuerySet = new UnionQuerySet<string, number>(
  (prev, curr, pos) => (pos ? prev + curr : prev - curr),
  0
);
// 添加 a 和 b 两个点,默认权重为
unionQuerySet.add("a");
unionQuerySet.add("b");
// 查找 a 所属集合,因为 a 并没有连接其它点,所以指向自己
unionQuerySet.find("a"); // { value: 0, to: "a" }
// 连接 a 点到 b 点(有向),权重为 2
unionQuerySet.join("a", "b", 2);
// 查找 a 所属集合
unionQuerySet.find("a"); // { value: 2, to: "b" }
/* 列表 */
import { List } from 'micro-class'

const list = new List([0, 1, 2, 3, 4])

// 切片
list[':-5:-1']  // [4, 3, 2, 1]

测试用例

更多使用方法请参考 测试用例

1.6.4

6 months ago

1.6.5

6 months ago

1.6.3

9 months ago

1.6.2

9 months ago

1.6.1

9 months ago

1.6.0

9 months ago

1.5.1

9 months ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago