cody-utils 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.history/package_20200212101131.json +19 -0
- package/.history/package_20250527165758.json +19 -0
- package/.history/package_20250527165800.json +19 -0
- package/.history/package_20250527165806.json +19 -0
- package/.history/package_20250527165810.json +19 -0
- package/.history/package_20250527165815.json +19 -0
- package/.history/package_20250527165817.json +19 -0
- package/.history/package_20250527165826.json +19 -0
- package/.history/package_20250527165829.json +19 -0
- package/.history/package_20250527165835.json +19 -0
- package/.history/package_20250527170050.json +19 -0
- package/.history/package_20250527170051.json +19 -0
- package/.history/webpack.config_20200212101131.js +23 -0
- package/.history/webpack.config_20250527165622.js +23 -0
- package/.history/webpack.config_20250527165631.js +23 -0
- package/.history/webpack.config_20250527165643.js +23 -0
- package/.history/webpack.config_20250527165647.js +23 -0
- package/README.md +124 -0
- package/dist/cody-utils.min.js +435 -0
- package/package.json +19 -0
- package/src/array/chunk.js +30 -0
- package/src/array/compact.js +6 -0
- package/src/array/concat.js +16 -0
- package/src/array/declares.js +92 -0
- package/src/array/difference.js +12 -0
- package/src/array/drop.js +28 -0
- package/src/array/flatten.js +28 -0
- package/src/array/merge.js +18 -0
- package/src/array/pull.js +33 -0
- package/src/array/slice.js +33 -0
- package/src/array/unique.js +40 -0
- package/src/axios/index.js +97 -0
- package/src/event-bus/index.js +46 -0
- package/src/function/apply.js +17 -0
- package/src/function/bind.js +18 -0
- package/src/function/call.js +17 -0
- package/src/function/debounce.js +22 -0
- package/src/function/throttle.js +15 -0
- package/src/index.js +30 -0
- package/src/object/clone.js +34 -0
- package/src/object/deepClone.js +105 -0
- package/src/object/merge.js +14 -0
- package/src/object/myInstanceOf.js +22 -0
- package/src/object/newInstance.js +20 -0
- package/src/promise/index.js +226 -0
- package/src/pub-sub/index.js +95 -0
- package/src/string/index.js +28 -0
- package/test/01_call_apply_bind.html +47 -0
- package/test/02_throttle_debounce.html +54 -0
- package/test/02_/345/207/275/346/225/260/351/230/262/346/212/226/344/270/216/350/212/202/346/265/201.jpg +0 -0
- package/test/03_array_declare.html +51 -0
- package/test/04_array_unique.html +32 -0
- package/test/05_array_concat_slice.html +28 -0
- package/test/06_array_flatten.html +23 -0
- package/test/07_array_compact_chunk.html +25 -0
- package/test/08_array_difference_merge.html +22 -0
- package/test/09_array_pull_pullAll.html +27 -0
- package/test/10_array_drop_dropRight.html +32 -0
- package/test/11_new_instanceof.html +47 -0
- package/test/12_object_merge.html +34 -0
- package/test/13_deepClone.html +42 -0
- package/test/13_shallowClone.html +27 -0
- package/test/13_/346/265/213/350/257/225/351/201/215/345/216/206/345/257/271/350/261/241/346/225/210/347/216/207.html +38 -0
- package/test/13_/346/265/213/350/257/225/351/201/215/345/216/206/346/225/260/347/273/204/346/225/210/347/216/207.html +60 -0
- package/test/14_string.html +21 -0
- package/test/15_/346/211/213/345/206/231/347/273/247/346/211/277.html +53 -0
- package/test/16_/346/211/213/345/206/231/344/272/213/344/273/266/346/200/273/347/272/277.html +32 -0
- package/test/17_/346/211/213/345/206/231/346/266/210/346/201/257/350/256/242/351/230/205/344/270/216/345/217/221/345/270/203.html +48 -0
- package/test/18_/346/211/213/345/206/231Promise.html +49 -0
- package/test/19_/346/211/213/345/206/231ajax/350/257/267/346/261/202/345/207/275/346/225/260.html +102 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/01_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/225/260/347/273/204//346/225/260/347/273/204/345/270/270/350/247/201/346/223/215/344/275/2341.html +48 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/01_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/225/260/347/273/204//346/225/260/347/273/204/345/270/270/350/247/201/346/223/215/344/275/2342.html +74 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/01_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/225/260/347/273/204//346/225/260/347/273/204/345/270/270/350/247/201/346/223/215/344/275/2343.html +53 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/01_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/225/260/347/273/204//346/225/260/347/273/204/345/270/270/350/247/201/346/223/215/344/275/2344.html +54 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/02_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/240/210//346/240/210_/345/272/224/347/224/250_/345/215/201/350/277/233/345/210/266/350/275/254/344/272/214/350/277/233/345/210/266.html +41 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/02_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/346/240/210//346/240/210_/346/265/213/350/257/225.html +29 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/03_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/351/230/237/345/210/227//344/274/230/345/205/210/347/272/247/351/230/237/345/210/227_/346/265/213/350/257/225.html +29 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/03_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/351/230/237/345/210/227//351/230/237/345/210/227_/345/272/224/347/224/250_/345/207/273/351/274/223/344/274/240/350/212/261.html +38 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/03_/345/237/272/346/234/254/346/225/260/346/215/256/347/273/223/346/236/204_/351/230/237/345/210/227//351/230/237/345/210/227_/346/265/213/350/257/225.html +33 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/04_/346/225/260/346/215/256/347/273/223/346/236/204_/351/223/276/350/241/250//345/217/214/345/220/221/351/223/276/350/241/250_/346/265/213/350/257/225.html +55 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/04_/346/225/260/346/215/256/347/273/223/346/236/204_/351/223/276/350/241/250//351/223/276/350/241/250_/346/265/213/350/257/225.html +52 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/05_/346/225/260/346/215/256/347/273/223/346/236/204_/346/240/221//344/272/214/345/217/211/346/220/234/347/264/242/346/240/221_/346/265/213/350/257/225.html +48 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/06_/346/225/260/346/215/256/347/273/223/346/236/204_/351/233/206/345/220/210//351/233/206/345/220/210_/346/265/213/350/257/225.html +50 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/07_/346/216/222/345/272/217/347/256/227/346/263/225/3/347/247/215/345/237/272/346/234/254/346/216/222/345/272/217_/346/265/213/350/257/225.html +19 -0
- package/test/20_/346/225/260/346/215/256/347/273/223/346/236/204/344/270/216/347/256/227/346/263/225/07_/346/216/222/345/272/217/347/256/227/346/263/225//351/253/230/347/272/247/346/216/222/345/272/217_/346/265/213/350/257/225.html +19 -0
- package/test/README.md +207 -0
- package/test/db.json +54 -0
- package/webpack.config.js +23 -0
- package//350/207/252/345/256/232/344/271/211npm/345/267/245/345/205/267/345/272/223.md +91 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "atguigu-utils",
|
3
|
+
"version": "1.2.3",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["atguigu", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "atguigu-utils",
|
3
|
+
"version": "1.20.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["atguigu", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "atguigu-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["atguigu", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "atgucodyigu-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["atguigu", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["atguigu", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/atguigu-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "尚硅谷大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "xfzhang",
|
5
|
+
"description": "大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "yu",
|
5
|
+
"description": "大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "cody",
|
5
|
+
"description": "大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "cody",
|
5
|
+
"description": "大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.minjs",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "cody-utils",
|
3
|
+
"version": "1.0.1",
|
4
|
+
"author": "cody",
|
5
|
+
"description": "大前端自定义工具函数库",
|
6
|
+
"keywords": ["cody", "utils", "array", "object", "function", "promise", "axios", "数据结构", "算法"],
|
7
|
+
"main": "dist/cody-utils.min.js",
|
8
|
+
"license": "MIT",
|
9
|
+
"scripts": {
|
10
|
+
"build": "webpack --watch"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"webpack": "^4.41.5",
|
14
|
+
"webpack-cli": "^3.3.10"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"lodash": "^4.17.15"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
mode: 'development',
|
5
|
+
mode: 'production',
|
6
|
+
// entry: './src/index.js',
|
7
|
+
|
8
|
+
output: {
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
10
|
+
// filename: 'atguigu-utils.js',
|
11
|
+
filename: 'atguigu-utils.min.js',
|
12
|
+
libraryTarget: 'umd', // 打包生成库可以通过esm/commonjs/reqirejs的语法引入
|
13
|
+
library: 'aUtils' // 向外暴露的对象的名称
|
14
|
+
},
|
15
|
+
externals: {
|
16
|
+
lodash: {
|
17
|
+
commonjs: 'lodash',
|
18
|
+
commonjs2: 'lodash',
|
19
|
+
amd: 'lodash',
|
20
|
+
root: '_' // 页面引入的全局变量
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
mode: 'development',
|
5
|
+
mode: 'production',
|
6
|
+
// entry: './src/index.js',
|
7
|
+
|
8
|
+
output: {
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
10
|
+
// filename: 'atguigu-utils.js',
|
11
|
+
filename: 'atguigu-utils.min.js',
|
12
|
+
libraryTarget: 'umd', // 打包生成库可以通过esm/commonjs/reqirejs的语法引入
|
13
|
+
library: 'cUtils' // 向外暴露的对象的名称
|
14
|
+
},
|
15
|
+
externals: {
|
16
|
+
lodash: {
|
17
|
+
commonjs: 'lodash',
|
18
|
+
commonjs2: 'lodash',
|
19
|
+
amd: 'lodash',
|
20
|
+
root: '_' // 页面引入的全局变量
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
mode: 'development',
|
5
|
+
mode: 'production',
|
6
|
+
// entry: './src/index.js',
|
7
|
+
|
8
|
+
output: {
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
10
|
+
// filename: 'atguigu-utils.js',
|
11
|
+
filename: 'cody-utils.min.js',
|
12
|
+
libraryTarget: 'umd', // 打包生成库可以通过esm/commonjs/reqirejs的语法引入
|
13
|
+
library: 'cUtils' // 向外暴露的对象的名称
|
14
|
+
},
|
15
|
+
externals: {
|
16
|
+
lodash: {
|
17
|
+
commonjs: 'lodash',
|
18
|
+
commonjs2: 'lodash',
|
19
|
+
amd: 'lodash',
|
20
|
+
root: '_' // 页面引入的全局变量
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
mode: 'development',
|
5
|
+
// mode: 'production',
|
6
|
+
// entry: './src/index.js',
|
7
|
+
|
8
|
+
output: {
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
10
|
+
// filename: 'atguigu-utils.js',
|
11
|
+
filename: 'cody-utils.min.js',
|
12
|
+
libraryTarget: 'umd', // 打包生成库可以通过esm/commonjs/reqirejs的语法引入
|
13
|
+
library: 'cUtils' // 向外暴露的对象的名称
|
14
|
+
},
|
15
|
+
externals: {
|
16
|
+
lodash: {
|
17
|
+
commonjs: 'lodash',
|
18
|
+
commonjs2: 'lodash',
|
19
|
+
amd: 'lodash',
|
20
|
+
root: '_' // 页面引入的全局变量
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
mode: 'development',
|
5
|
+
// mode: 'production',
|
6
|
+
entry: './src/index.js',
|
7
|
+
|
8
|
+
output: {
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
10
|
+
// filename: 'atguigu-utils.js',
|
11
|
+
filename: 'cody-utils.min.js',
|
12
|
+
libraryTarget: 'umd', // 打包生成库可以通过esm/commonjs/reqirejs的语法引入
|
13
|
+
library: 'cUtils' // 向外暴露的对象的名称
|
14
|
+
},
|
15
|
+
externals: {
|
16
|
+
lodash: {
|
17
|
+
commonjs: 'lodash',
|
18
|
+
commonjs2: 'lodash',
|
19
|
+
amd: 'lodash',
|
20
|
+
root: '_' // 页面引入的全局变量
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
package/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# 尚硅谷大前端自定义工具函数库
|
2
|
+
|
3
|
+
# 说明
|
4
|
+
## 1. 包含以下8个方面
|
5
|
+
1). 函数相关
|
6
|
+
2). 数组相关
|
7
|
+
3). 对象相关
|
8
|
+
4). 字符串相关
|
9
|
+
5). 事件总线
|
10
|
+
6). 消息订阅与发布
|
11
|
+
7). Promise
|
12
|
+
8). ajax函数axios
|
13
|
+
9). 数据结构与算法
|
14
|
+
|
15
|
+
## 2. 使用
|
16
|
+
1). 下载:
|
17
|
+
npm install -S atguigu-utils
|
18
|
+
yarn add atguigu-utils
|
19
|
+
|
20
|
+
2). 网页中使用
|
21
|
+
<script src="./node_modules/atguigu-utils/dist/atguigu-utils.js"></script>
|
22
|
+
<script>
|
23
|
+
console.log(aUtils.flatten1([1, [3, [2, 4]]])) // [1, 3, 2, 4]
|
24
|
+
</script>
|
25
|
+
|
26
|
+
3). 模块化引入
|
27
|
+
import {flatten1} from 'atguigu-utils'
|
28
|
+
const {flatten2} = require('atguigu-utils')
|
29
|
+
console.log(aUtils.flatten1([1, [3, [2, 4]]]))
|
30
|
+
console.log(aUtils.flatten2([1, [3, [2, 4]]]))
|
31
|
+
|
32
|
+
4). 完整的功能函数测试
|
33
|
+
test文件夹下都一系列测试页面
|
34
|
+
|
35
|
+
# API
|
36
|
+
## 1. 函数相关
|
37
|
+
|
38
|
+
### call()
|
39
|
+
语法: call(fn, obj, ...args)
|
40
|
+
功能: 等同于函数对象的call方法
|
41
|
+
|
42
|
+
### apply()
|
43
|
+
语法: apply(fn, obj, args)
|
44
|
+
功能: 等同于函数对象的apply方法
|
45
|
+
|
46
|
+
### bind(fn, obj, args)
|
47
|
+
语法: bind(fn, obj, ...args)
|
48
|
+
功能: 等同于函数对象的bind方法
|
49
|
+
|
50
|
+
### throttle()
|
51
|
+
语法: throttle(callback, delay)
|
52
|
+
功能: 用来生成节流函数的工具函数
|
53
|
+
|
54
|
+
### debounce()
|
55
|
+
语法: debounce(callback, delay)
|
56
|
+
功能: 用来生成防抖函数的工具函数
|
57
|
+
|
58
|
+
|
59
|
+
## 2. 数组相关
|
60
|
+
### map()
|
61
|
+
### reduce()
|
62
|
+
### filter()
|
63
|
+
### find()
|
64
|
+
### findIndex()
|
65
|
+
### every()
|
66
|
+
### some()
|
67
|
+
### unique1() / unique2() / unique3()
|
68
|
+
### concat()
|
69
|
+
### slice()
|
70
|
+
### flatten()
|
71
|
+
### compact()
|
72
|
+
### chunk() / chunk2()
|
73
|
+
### difference()
|
74
|
+
### mergeArray()
|
75
|
+
### pull()
|
76
|
+
### pullAll()
|
77
|
+
### drop()
|
78
|
+
### dropRight()
|
79
|
+
|
80
|
+
|
81
|
+
## 3. 对象相关
|
82
|
+
### newInstance()
|
83
|
+
### myInstanceOf()
|
84
|
+
### mergeObject()
|
85
|
+
### clone1() / clone2()
|
86
|
+
### deepClone1() / deepClone2() / deepClone3() / deepClone4()
|
87
|
+
|
88
|
+
|
89
|
+
## 4. 字符串相关
|
90
|
+
### reverseString()
|
91
|
+
### palindrome()
|
92
|
+
### truncate()
|
93
|
+
|
94
|
+
|
95
|
+
## 5. 事件总线: eventBus
|
96
|
+
### eventBus.on()
|
97
|
+
### eventBus.emit()
|
98
|
+
### eventBus.off()
|
99
|
+
|
100
|
+
|
101
|
+
## 6. 消息订阅与发布: PubSub
|
102
|
+
### PubSub.subscribe()
|
103
|
+
### PubSub.publish()
|
104
|
+
### PubSub.unsubscribe()
|
105
|
+
|
106
|
+
|
107
|
+
## 7. Promise
|
108
|
+
### Promise()
|
109
|
+
### Promise.prototype.then()
|
110
|
+
### Promise.prototype.catch()
|
111
|
+
### Promise.resolve()
|
112
|
+
### Promise.reject()
|
113
|
+
### Promise.all()
|
114
|
+
### Promise.race()
|
115
|
+
### Promise.resolveDelay()
|
116
|
+
### Promise.rejectDelay()
|
117
|
+
|
118
|
+
## 8. ajax函数axios
|
119
|
+
### axios()
|
120
|
+
### axios.get()
|
121
|
+
### axios.post()
|
122
|
+
### axios.delete()
|
123
|
+
### axios.put()
|
124
|
+
|