deduplication 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +22 -0
  2. package/package.json +8 -0
  3. package/vertify.html +0 -0
package/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 数组去重
3
+ * @param arr 要去重的数组
4
+ * @param type number type为1表示使用set函数去重,type为2表示使用
5
+ */
6
+ export default function deduplication(arr,type=1) {
7
+ switch(type){
8
+ case 1:
9
+ this.method1(arr);
10
+ break;
11
+ case 2:
12
+ this.method2(arr);
13
+ break;
14
+ }
15
+
16
+ }
17
+
18
+ //set去重
19
+ function method1(arr){
20
+ let a = new Set(arr);
21
+ return [...a];
22
+ }
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "deduplication",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "repository": "",
6
+ "author": "henry",
7
+ "license": "MIT"
8
+ }
package/vertify.html ADDED
File without changes