@abozhilov/set-utils 中文文档教程
@abozhilov/set-utils - v1.0.0
用于使用内置 Set
的实用程序库。
用 TypeScript 编写。
Installation
npm
npm install @abozhilov/set-utils
yarn
yarn add @abozhilov/set-utils
Table of contents
Functions
Functions
isSubset
▸ isSubset<Т
>(setA
, setB
): boolean
检查setA
是否是 setB
的子集。 该操作由 setA ⊆ setB
表示。
assert.equal(
isSubset(new Set([1, 2]), new Set([1, 2, 3])),
true
);
Type parameters
Name |
---|
Т |
Parameters
Name | Type |
---|---|
setA | Set <Т > |
setB | Set <Т > |
Returns
boolean
Defined in
index.ts:12
isStrictSubset
▸ isStrictSubset<Т
>(setA
, setB):
boolean
检查 setA
是否是 setB
的严格(适当)子集。 该操作由 setA ⊂ setB
表示。
assert.equal(
isStrictSubset(new Set([1, 2]), new Set([1, 2, 3])),
true
);
assert.equal(
isStrictSubset(new Set([1, 2]), new Set([1, 2])),
false
);
Type parameters
Name |
---|
Т |
Parameters
Name | Type |
---|---|
setA | Set <Т > |
setB | Set <Т > |
Returns
boolean
Defined in
index.ts:41
isSuperset
▸ isSuperset<T
>(setA
, setB):
boolean
检查 setA
是否是 setB
的超集。 该操作由 setA ⊇ setB
表示。
assert.equal(
isSuperset(new Set([1, 2, 3]), new Set([1, 2])),
true
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
Returns
boolean
Defined in
index.ts:60
isStrictSuperset
▸ isStrictSuperset<T
>(setA
, setB):
boolean
检查 setA
是否是 setB
的严格(正确)超集。 该操作由 setA ⊃ setB
表示。
assert.equal(
isStrictSuperset(new Set([1, 2, 3]), new Set([1, 2])),
true
);
assert.equal(
isStrictSuperset(new Set([1, 2]), new Set([1, 2])),
false
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
Returns
boolean
Defined in
index.ts:82
union
▸ union<T
>(setA
, setB, ...
restSets
): Set
<T
>;
返回包含每个集合中所有元素的新集合。 该操作由 setA ⋃ setB
表示。
assert.deepEqual(
union(new Set([1, 2]), new Set([3, 4])),
new Set([1, 2, 3, 4])
);
assert.deepEqual(
union(new Set([1, 2]), new Set([3, 4]), new Set([5, 6])),
new Set([1, 2, 3, 4, 5, 6])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...restSets | Set <T >[] |
Returns
设置
<T
>
Defined in
index.ts:105
intersect
▸ 相交<T
>(setA
, setB
, …sets
): Set
<T
>;
返回一个新集合,其中包含 setA
的所有元素,这些元素也属于 setB
。 该操作由 setA ⋂ setB
表示。
assert.deepEqual(
intersect(new Set([1, 2, 3]), new Set([2, 3, 4])),
new Set([2, 3])
);
assert.deepEqual(
intersect(new Set([1, 2, 3]), new Set([2, 3, 4]), new Set([2, 3, 5])),
new Set([2, 3])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
设置
<T
>
Defined in
index.ts:139
difference
▸ 差异<T
>(setA
, setB
, ...sets
): Set
<T
>;
返回一个新集合,其中包含 setA
中不属于 setB
的所有元素。 该操作由 setA \ setB
表示。
assert.deepEqual(
difference(new Set([1, 2, 3]), new Set([3, 4, 5])),
new Set([1, 2])
);
assert.deepEqual(
difference(new Set([1, 2, 3, 4, 5]), new Set([3, 4]), new Set([4, 5])),
new Set([1, 2])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
设置
<T
>
Defined in
index.ts:178
symmetricDifference
▸ symmetricDifference<T
>(setA
, setB
, ...集合
): Set
<T
>;
返回一个新集合,其中包含 setA
中不属于 setB
的所有元素,反之亦然。 该操作由 setA ∆ setB
表示。
assert.deepEqual(
symmetricDifference(new Set([1, 2, 3]), new Set([3, 4, 5])),
new Set([1, 2, 4, 5])
);
assert.deepEqual(
symmetricDifference(new Set([1, 2, 3, 4]), new Set([3, 4, 5, 6]), new Set([4, 5, 7])),
new Set([1, 2, 6, 7])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
设置
<T
>
Defined in
index.ts:217
@abozhilov/set-utils - v1.0.0
Utility library for working with the built-in Set
.
Written in TypeScript.
Installation
npm
npm install @abozhilov/set-utils
yarn
yarn add @abozhilov/set-utils
Table of contents
Functions
Functions
isSubset
▸ isSubset<Т
>(setA
, setB
): boolean
Checks whether setA
is a subset of setB
. The operation is denoted by setA ⊆ setB
.
assert.equal(
isSubset(new Set([1, 2]), new Set([1, 2, 3])),
true
);
Type parameters
Name |
---|
Т |
Parameters
Name | Type |
---|---|
setA | Set <Т > |
setB | Set <Т > |
Returns
boolean
Defined in
index.ts:12
isStrictSubset
▸ isStrictSubset<Т
>(setA
, setB
): boolean
Checks whether setA
is a strict (proper) subset of setB
. The operation is denoted by setA ⊂ setB
.
assert.equal(
isStrictSubset(new Set([1, 2]), new Set([1, 2, 3])),
true
);
assert.equal(
isStrictSubset(new Set([1, 2]), new Set([1, 2])),
false
);
Type parameters
Name |
---|
Т |
Parameters
Name | Type |
---|---|
setA | Set <Т > |
setB | Set <Т > |
Returns
boolean
Defined in
index.ts:41
isSuperset
▸ isSuperset<T
>(setA
, setB
): boolean
Checks whether setA
is a superset of setB
. The operation is denoted by setA ⊇ setB
.
assert.equal(
isSuperset(new Set([1, 2, 3]), new Set([1, 2])),
true
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
Returns
boolean
Defined in
index.ts:60
isStrictSuperset
▸ isStrictSuperset<T
>(setA
, setB
): boolean
Checks whether setA
is a strict (proper) superset of setB
. The operation is denoted by setA ⊃ setB
.
assert.equal(
isStrictSuperset(new Set([1, 2, 3]), new Set([1, 2])),
true
);
assert.equal(
isStrictSuperset(new Set([1, 2]), new Set([1, 2])),
false
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
Returns
boolean
Defined in
index.ts:82
union
▸ union<T
>(setA
, setB
, …restSets
): Set
<T
>
Returns new set which contains all elements from each set. The operation is denoted by setA ⋃ setB
.
assert.deepEqual(
union(new Set([1, 2]), new Set([3, 4])),
new Set([1, 2, 3, 4])
);
assert.deepEqual(
union(new Set([1, 2]), new Set([3, 4]), new Set([5, 6])),
new Set([1, 2, 3, 4, 5, 6])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...restSets | Set <T >[] |
Returns
Set
<T
>
Defined in
index.ts:105
intersect
▸ intersect<T
>(setA
, setB
, …sets
): Set
<T
>
Returns a new set with all elements of setA
that also belongs to setB
. The operation is denoted by setA ⋂ setB
.
assert.deepEqual(
intersect(new Set([1, 2, 3]), new Set([2, 3, 4])),
new Set([2, 3])
);
assert.deepEqual(
intersect(new Set([1, 2, 3]), new Set([2, 3, 4]), new Set([2, 3, 5])),
new Set([2, 3])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
Set
<T
>
Defined in
index.ts:139
difference
▸ difference<T
>(setA
, setB
, …sets
): Set
<T
>
Returns a new set with all elements of setA
that not belongs to setB
. The operation is denoted by setA \ setB
.
assert.deepEqual(
difference(new Set([1, 2, 3]), new Set([3, 4, 5])),
new Set([1, 2])
);
assert.deepEqual(
difference(new Set([1, 2, 3, 4, 5]), new Set([3, 4]), new Set([4, 5])),
new Set([1, 2])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
Set
<T
>
Defined in
index.ts:178
symmetricDifference
▸ symmetricDifference<T
>(setA
, setB
, …sets
): Set
<T
>
Returns a new set with all elements of setA
that not belongs to setB
and vice versa. The operation is denoted by setA ∆ setB
.
assert.deepEqual(
symmetricDifference(new Set([1, 2, 3]), new Set([3, 4, 5])),
new Set([1, 2, 4, 5])
);
assert.deepEqual(
symmetricDifference(new Set([1, 2, 3, 4]), new Set([3, 4, 5, 6]), new Set([4, 5, 7])),
new Set([1, 2, 6, 7])
);
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
setA | Set <T > |
setB | Set <T > |
...sets | Set <T >[] |
Returns
Set
<T
>
Defined in
index.ts:217
你可能也喜欢
- 5lg-calculator 中文文档教程
- @01ht/ht-client-helper-functions 中文文档教程
- @0x-jerry/events 中文文档教程
- @0xcert/ethereum-bitski-frontend-provider 中文文档教程
- @3m/cli 中文文档教程
- @42.nl/jarb-final-form 中文文档教程
- @4ex/indicators 中文文档教程
- @4geit/rct-chatbox-list-component 中文文档教程
- @4geit/rct-landing-page-layout-component 中文文档教程
- @_000407/singlish.js 中文文档教程