amos-tool 1.4.6 → 1.4.9
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/.prettierignore +2 -2
- package/.prettierrc +50 -50
- package/README.md +5 -0
- package/apis/objectPath.md +129 -129
- package/index.d.ts +23 -4
- package/index.js +3 -3
- package/lib/_browser.js +10 -8
- package/lib/_clone.js +67 -62
- package/lib/_cookie.js +35 -32
- package/lib/_deepCopy.js +17 -29
- package/lib/_deepEqual.js +6 -13
- package/lib/_fastDeepEqual.js +28 -44
- package/lib/_flashSupport.js +13 -10
- package/lib/_forOwn.js +8 -7
- package/lib/_funcThrottle.js +16 -15
- package/lib/_isnode.js +2 -1
- package/lib/_list.js +55 -67
- package/lib/_object.assign.js +14 -24
- package/lib/_object.entries.js +6 -5
- package/lib/_object.values.js +5 -4
- package/lib/_omit.js +12 -12
- package/lib/_parseJson.js +7 -6
- package/lib/_pick.js +8 -7
- package/lib/_queue.js +24 -21
- package/lib/_shallowCopy.js +24 -23
- package/lib/_stringify.js +14 -17
- package/lib/_supportWs.js +5 -5
- package/lib/_trim.js +5 -4
- package/lib/_typeOfList.js +22 -21
- package/lib/_uuids.js +30 -35
- package/lib/amostool.js +14 -64
- package/lib/array2tree.js +9 -10
- package/lib/arrayFilter.js +17 -20
- package/lib/arrayUtils.js +13 -11
- package/lib/browser/Cookie.js +34 -35
- package/lib/browser/indexDB.js +71 -82
- package/lib/browserSupport.js +76 -71
- package/lib/completeUnit.js +7 -4
- package/lib/consts.js +2 -1
- package/lib/dom/canvas2img.js +61 -73
- package/lib/dom/canvasTools.js +9 -14
- package/lib/dom/downloadFile.js +15 -12
- package/lib/dom/eventHelper.js +8 -6
- package/lib/dom/fileBlob.js +14 -14
- package/lib/dom/fileSaveAs.js +54 -61
- package/lib/dom/getFontSize.js +7 -10
- package/lib/dom/minfyImg.js +30 -25
- package/lib/encrypt/_base64.js +32 -25
- package/lib/encrypt/_md5.js +68 -31
- package/lib/encrypt/des.js +426 -363
- package/lib/extra/_common.js +119 -166
- package/lib/extra/filterNull.js +3 -2
- package/lib/extra/find.js +10 -11
- package/lib/extra/index.js +4 -3
- package/lib/extra/memo.js +18 -0
- package/lib/extra/pathToTree.js +48 -42
- package/lib/extra/pwdStrength.js +4 -2
- package/lib/extra/sortBy.js +28 -30
- package/lib/flat.js +15 -0
- package/lib/locationParams.js +94 -99
- package/lib/log.js +22 -25
- package/lib/math/_keyColor.js +3 -1
- package/lib/math/addition.js +9 -7
- package/lib/math/amountCase.js +8 -12
- package/lib/math/coinFormat.js +7 -5
- package/lib/math/colorUtil.js +78 -86
- package/lib/math/dateTime.js +76 -94
- package/lib/math/operations.js +33 -37
- package/lib/math/pwdStrength.js +4 -2
- package/lib/math/randomColor.js +17 -5
- package/lib/math/subtraction.js +10 -9
- package/lib/merged.js +9 -9
- package/lib/objectPath.js +88 -95
- package/lib/parseText.js +8 -7
- package/lib/png/Identicon.js +36 -38
- package/lib/png/pnglib.js +58 -32
- package/lib/png/randomPic.js +9 -12
- package/lib/positionFactory.js +25 -80
- package/lib/pwdPolicy.js +27 -31
- package/lib/qs/_assign.js +7 -5
- package/lib/qs/_merge.js +19 -28
- package/lib/qs/_tools.js +3 -2
- package/lib/qs/formats.js +6 -5
- package/lib/qs/index.js +4 -4
- package/lib/qs/parse.js +55 -50
- package/lib/qs/stringify.js +55 -77
- package/lib/qs/utils.js +69 -88
- package/lib/random.js +5 -4
- package/lib/shallowEqual.js +24 -34
- package/lib/store.js +93 -98
- package/lib/strUtils.js +51 -42
- package/lib/tableFilter.js +178 -169
- package/lib/throttleDebounce.js +18 -22
- package/lib/url/encodeUrl.js +5 -4
- package/lib/url/restfulUrl.js +8 -7
- package/lib/utils.js +168 -223
- package/lib/xss/htmlEncode.js +3 -2
- package/lib/xss/implementEncode.js +36 -37
- package/lib/xss/index.js +4 -3
- package/package.json +9 -8
package/.prettierignore
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
lib
|
|
1
|
+
node_modules
|
|
2
|
+
lib
|
package/.prettierrc
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"printWidth": 160,
|
|
3
|
-
"tabWidth": 2,
|
|
4
|
-
"useTabs": false,
|
|
5
|
-
"semi": true,
|
|
6
|
-
"singleQuote": true,
|
|
7
|
-
"parser": "babel",
|
|
8
|
-
"trailingComma": "none",
|
|
9
|
-
"bracketSpacing": true,
|
|
10
|
-
"jsxBracketSameLine": false,
|
|
11
|
-
"arrowParens": "avoid",
|
|
12
|
-
"requirePragma": false,
|
|
13
|
-
"proseWrap": "preserve",
|
|
14
|
-
"overrides": [
|
|
15
|
-
{
|
|
16
|
-
"files": ["*.json", ".eslintrc", ".tslintrc", ".prettierrc", ".tern-project", ".travis.yml"],
|
|
17
|
-
"options": {
|
|
18
|
-
"parser": "json",
|
|
19
|
-
"tabWidth": 2
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"files": "*.css",
|
|
24
|
-
"options": {
|
|
25
|
-
"parser": "css",
|
|
26
|
-
"tabWidth": 2
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"files": "*.{sass,scss}",
|
|
31
|
-
"options": {
|
|
32
|
-
"parser": "scss",
|
|
33
|
-
"tabWidth": 2
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"files": "*.less",
|
|
38
|
-
"options": {
|
|
39
|
-
"parser": "less",
|
|
40
|
-
"tabWidth": 2
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"files": "*.ts",
|
|
45
|
-
"options": {
|
|
46
|
-
"parser": "typescript"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"printWidth": 160,
|
|
3
|
+
"tabWidth": 2,
|
|
4
|
+
"useTabs": false,
|
|
5
|
+
"semi": true,
|
|
6
|
+
"singleQuote": true,
|
|
7
|
+
"parser": "babel",
|
|
8
|
+
"trailingComma": "none",
|
|
9
|
+
"bracketSpacing": true,
|
|
10
|
+
"jsxBracketSameLine": false,
|
|
11
|
+
"arrowParens": "avoid",
|
|
12
|
+
"requirePragma": false,
|
|
13
|
+
"proseWrap": "preserve",
|
|
14
|
+
"overrides": [
|
|
15
|
+
{
|
|
16
|
+
"files": ["*.json", ".eslintrc", ".tslintrc", ".prettierrc", ".tern-project", ".travis.yml"],
|
|
17
|
+
"options": {
|
|
18
|
+
"parser": "json",
|
|
19
|
+
"tabWidth": 2
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"files": "*.css",
|
|
24
|
+
"options": {
|
|
25
|
+
"parser": "css",
|
|
26
|
+
"tabWidth": 2
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"files": "*.{sass,scss}",
|
|
31
|
+
"options": {
|
|
32
|
+
"parser": "scss",
|
|
33
|
+
"tabWidth": 2
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"files": "*.less",
|
|
38
|
+
"options": {
|
|
39
|
+
"parser": "less",
|
|
40
|
+
"tabWidth": 2
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"files": "*.ts",
|
|
45
|
+
"options": {
|
|
46
|
+
"parser": "typescript"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
by ilex.h
|
|
4
4
|
|
|
5
|
+
docs: [docs](https://unpkg.com/amos-tool@latest/docs/index.html)
|
|
6
|
+
|
|
5
7
|
## useage
|
|
6
8
|
|
|
7
9
|
npm install --save amos-tool
|
|
@@ -276,6 +278,9 @@ const result2 = browserSupport(paramsList, limit);
|
|
|
276
278
|
Log.error()
|
|
277
279
|
Log.fatal()
|
|
278
280
|
|
|
281
|
+
// 展示 pkg 信息,不受 LogConfig 配置影响
|
|
282
|
+
Log.pkgInfo(name, version)
|
|
283
|
+
|
|
279
284
|
```
|
|
280
285
|
|
|
281
286
|
### store
|
package/apis/objectPath.md
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
# objectPath
|
|
2
|
-
|
|
3
|
-
## Usage
|
|
4
|
-
|
|
5
|
-
```js
|
|
6
|
-
var {objectPath} from 'amos-tool';
|
|
7
|
-
|
|
8
|
-
var obj = {
|
|
9
|
-
a: {
|
|
10
|
-
b: "d",
|
|
11
|
-
c: ["e", "f"],
|
|
12
|
-
'\u1200': 'unicode key',
|
|
13
|
-
'dot.dot': 'key'
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var objectPath = require("object-path");
|
|
18
|
-
|
|
19
|
-
//get deep property
|
|
20
|
-
objectPath.get(obj, "a.b"); //returns "d"
|
|
21
|
-
objectPath.get(obj, ["a", "dot.dot"]); //returns "key"
|
|
22
|
-
objectPath.get(obj, 'a.\u1200'); //returns "unicode key"
|
|
23
|
-
|
|
24
|
-
//get the first non-undefined value
|
|
25
|
-
objectPath.coalesce(obj, ['a.z', 'a.d', ['a','b']], 'default');
|
|
26
|
-
|
|
27
|
-
//empty a given path (but do not delete it) depending on their type,so it retains reference to objects and arrays.
|
|
28
|
-
//functions that are not inherited from prototype are set to null.
|
|
29
|
-
//object instances are considered objects and just own property names are deleted
|
|
30
|
-
objectPath.empty(obj, 'a.b'); // obj.a.b is now ''
|
|
31
|
-
objectPath.empty(obj, 'a.c'); // obj.a.c is now []
|
|
32
|
-
objectPath.empty(obj, 'a'); // obj.a is now {}
|
|
33
|
-
|
|
34
|
-
//works also with arrays
|
|
35
|
-
objectPath.get(obj, "a.c.1"); //returns "f"
|
|
36
|
-
objectPath.get(obj, ["a","c","1"]); //returns "f"
|
|
37
|
-
|
|
38
|
-
//can return a default value with get
|
|
39
|
-
objectPath.get(obj, ["a.c.b"], "DEFAULT"); //returns "DEFAULT", since a.c.b path doesn't exists, if omitted, returns undefined
|
|
40
|
-
|
|
41
|
-
//set
|
|
42
|
-
objectPath.set(obj, "a.h", "m"); // or objectPath.set(obj, ["a","h"], "m");
|
|
43
|
-
objectPath.get(obj, "a.h"); //returns "m"
|
|
44
|
-
|
|
45
|
-
//set will create intermediate object/arrays
|
|
46
|
-
objectPath.set(obj, "a.j.0.f", "m");
|
|
47
|
-
|
|
48
|
-
//will insert values in array
|
|
49
|
-
objectPath.insert(obj, "a.c", "m", 1); // obj.a.c = ["e", "m", "f"]
|
|
50
|
-
|
|
51
|
-
//push into arrays (and create intermediate objects/arrays)
|
|
52
|
-
objectPath.push(obj, "a.k", "o");
|
|
53
|
-
|
|
54
|
-
//ensure a path exists (if it doesn't, set the default value you provide)
|
|
55
|
-
objectPath.ensureExists(obj, "a.k.1", "DEFAULT");
|
|
56
|
-
var oldVal = objectPath.ensureExists(obj, "a.b", "DEFAULT"); // oldval === "d"
|
|
57
|
-
|
|
58
|
-
//deletes a path
|
|
59
|
-
objectPath.del(obj, "a.b"); // obj.a.b is now undefined
|
|
60
|
-
objectPath.del(obj, ["a","c",0]); // obj.a.c is now ['f']
|
|
61
|
-
|
|
62
|
-
//tests path existence
|
|
63
|
-
objectPath.has(obj, "a.b"); // true
|
|
64
|
-
objectPath.has(obj, ["a","d"]); // false
|
|
65
|
-
|
|
66
|
-
//bind object
|
|
67
|
-
var model = objectPath({
|
|
68
|
-
a: {
|
|
69
|
-
b: "d",
|
|
70
|
-
c: ["e", "f"]
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
//now any method from above is supported directly w/o passing an object
|
|
75
|
-
model.get("a.b"); //returns "d"
|
|
76
|
-
model.get(["a.c.b"], "DEFAULT"); //returns "DEFAULT"
|
|
77
|
-
model.del("a.b"); // obj.a.b is now undefined
|
|
78
|
-
model.has("a.b"); // false
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### How `object-path` deals with inherited properties
|
|
83
|
-
|
|
84
|
-
By default `object-path` will only access an object's own properties. Look at the following example:
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
var proto = {
|
|
88
|
-
notOwn: {prop: 'a'}
|
|
89
|
-
}
|
|
90
|
-
var obj = Object.create(proto);
|
|
91
|
-
|
|
92
|
-
//This will return undefined (or the default value you specified), because notOwn is
|
|
93
|
-
//an inherited property
|
|
94
|
-
objectPath.get(obj, 'notOwn.prop');
|
|
95
|
-
|
|
96
|
-
//This will set the property on the obj instance and not the prototype.
|
|
97
|
-
//In other words proto.notOwn.prop === 'a' and obj.notOwn.prop === 'b'
|
|
98
|
-
objectPath.set(obj, 'notOwn.prop', 'b');
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
To configure `object-path` to also deal with inherited properties, you need to create a new instance and specify
|
|
102
|
-
the `includeInheritedProps = true` in the options object:
|
|
103
|
-
|
|
104
|
-
```js
|
|
105
|
-
var objectPath = require("object-path");
|
|
106
|
-
var objectPathWithInheritedProps = objectPath.create({includeInheritedProps: true})
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Alternatively, `object-path` exposes an instance already configured to handle inherited properties (`objectPath.withInheritedProps`):
|
|
110
|
-
|
|
111
|
-
```js
|
|
112
|
-
var objectPath = require("object-path");
|
|
113
|
-
var objectPathWithInheritedProps = objectPath.withInheritedProps
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
Once you have the new instance, you can access inherited properties as you access other properties:
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
var proto = {
|
|
120
|
-
notOwn: {prop: 'a'}
|
|
121
|
-
}
|
|
122
|
-
var obj = Object.create(proto);
|
|
123
|
-
|
|
124
|
-
//This will return 'a'
|
|
125
|
-
objectPath.withInheritedProps.get(obj, 'notOwn.prop');
|
|
126
|
-
|
|
127
|
-
//This will set proto.notOwn.prop to 'b'
|
|
128
|
-
objectPath.set(obj, 'notOwn.prop', 'b');
|
|
129
|
-
```
|
|
1
|
+
# objectPath
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
var {objectPath} from 'amos-tool';
|
|
7
|
+
|
|
8
|
+
var obj = {
|
|
9
|
+
a: {
|
|
10
|
+
b: "d",
|
|
11
|
+
c: ["e", "f"],
|
|
12
|
+
'\u1200': 'unicode key',
|
|
13
|
+
'dot.dot': 'key'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var objectPath = require("object-path");
|
|
18
|
+
|
|
19
|
+
//get deep property
|
|
20
|
+
objectPath.get(obj, "a.b"); //returns "d"
|
|
21
|
+
objectPath.get(obj, ["a", "dot.dot"]); //returns "key"
|
|
22
|
+
objectPath.get(obj, 'a.\u1200'); //returns "unicode key"
|
|
23
|
+
|
|
24
|
+
//get the first non-undefined value
|
|
25
|
+
objectPath.coalesce(obj, ['a.z', 'a.d', ['a','b']], 'default');
|
|
26
|
+
|
|
27
|
+
//empty a given path (but do not delete it) depending on their type,so it retains reference to objects and arrays.
|
|
28
|
+
//functions that are not inherited from prototype are set to null.
|
|
29
|
+
//object instances are considered objects and just own property names are deleted
|
|
30
|
+
objectPath.empty(obj, 'a.b'); // obj.a.b is now ''
|
|
31
|
+
objectPath.empty(obj, 'a.c'); // obj.a.c is now []
|
|
32
|
+
objectPath.empty(obj, 'a'); // obj.a is now {}
|
|
33
|
+
|
|
34
|
+
//works also with arrays
|
|
35
|
+
objectPath.get(obj, "a.c.1"); //returns "f"
|
|
36
|
+
objectPath.get(obj, ["a","c","1"]); //returns "f"
|
|
37
|
+
|
|
38
|
+
//can return a default value with get
|
|
39
|
+
objectPath.get(obj, ["a.c.b"], "DEFAULT"); //returns "DEFAULT", since a.c.b path doesn't exists, if omitted, returns undefined
|
|
40
|
+
|
|
41
|
+
//set
|
|
42
|
+
objectPath.set(obj, "a.h", "m"); // or objectPath.set(obj, ["a","h"], "m");
|
|
43
|
+
objectPath.get(obj, "a.h"); //returns "m"
|
|
44
|
+
|
|
45
|
+
//set will create intermediate object/arrays
|
|
46
|
+
objectPath.set(obj, "a.j.0.f", "m");
|
|
47
|
+
|
|
48
|
+
//will insert values in array
|
|
49
|
+
objectPath.insert(obj, "a.c", "m", 1); // obj.a.c = ["e", "m", "f"]
|
|
50
|
+
|
|
51
|
+
//push into arrays (and create intermediate objects/arrays)
|
|
52
|
+
objectPath.push(obj, "a.k", "o");
|
|
53
|
+
|
|
54
|
+
//ensure a path exists (if it doesn't, set the default value you provide)
|
|
55
|
+
objectPath.ensureExists(obj, "a.k.1", "DEFAULT");
|
|
56
|
+
var oldVal = objectPath.ensureExists(obj, "a.b", "DEFAULT"); // oldval === "d"
|
|
57
|
+
|
|
58
|
+
//deletes a path
|
|
59
|
+
objectPath.del(obj, "a.b"); // obj.a.b is now undefined
|
|
60
|
+
objectPath.del(obj, ["a","c",0]); // obj.a.c is now ['f']
|
|
61
|
+
|
|
62
|
+
//tests path existence
|
|
63
|
+
objectPath.has(obj, "a.b"); // true
|
|
64
|
+
objectPath.has(obj, ["a","d"]); // false
|
|
65
|
+
|
|
66
|
+
//bind object
|
|
67
|
+
var model = objectPath({
|
|
68
|
+
a: {
|
|
69
|
+
b: "d",
|
|
70
|
+
c: ["e", "f"]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
//now any method from above is supported directly w/o passing an object
|
|
75
|
+
model.get("a.b"); //returns "d"
|
|
76
|
+
model.get(["a.c.b"], "DEFAULT"); //returns "DEFAULT"
|
|
77
|
+
model.del("a.b"); // obj.a.b is now undefined
|
|
78
|
+
model.has("a.b"); // false
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### How `object-path` deals with inherited properties
|
|
83
|
+
|
|
84
|
+
By default `object-path` will only access an object's own properties. Look at the following example:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
var proto = {
|
|
88
|
+
notOwn: {prop: 'a'}
|
|
89
|
+
}
|
|
90
|
+
var obj = Object.create(proto);
|
|
91
|
+
|
|
92
|
+
//This will return undefined (or the default value you specified), because notOwn is
|
|
93
|
+
//an inherited property
|
|
94
|
+
objectPath.get(obj, 'notOwn.prop');
|
|
95
|
+
|
|
96
|
+
//This will set the property on the obj instance and not the prototype.
|
|
97
|
+
//In other words proto.notOwn.prop === 'a' and obj.notOwn.prop === 'b'
|
|
98
|
+
objectPath.set(obj, 'notOwn.prop', 'b');
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
To configure `object-path` to also deal with inherited properties, you need to create a new instance and specify
|
|
102
|
+
the `includeInheritedProps = true` in the options object:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
var objectPath = require("object-path");
|
|
106
|
+
var objectPathWithInheritedProps = objectPath.create({includeInheritedProps: true})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Alternatively, `object-path` exposes an instance already configured to handle inherited properties (`objectPath.withInheritedProps`):
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
var objectPath = require("object-path");
|
|
113
|
+
var objectPathWithInheritedProps = objectPath.withInheritedProps
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Once you have the new instance, you can access inherited properties as you access other properties:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
var proto = {
|
|
120
|
+
notOwn: {prop: 'a'}
|
|
121
|
+
}
|
|
122
|
+
var obj = Object.create(proto);
|
|
123
|
+
|
|
124
|
+
//This will return 'a'
|
|
125
|
+
objectPath.withInheritedProps.get(obj, 'notOwn.prop');
|
|
126
|
+
|
|
127
|
+
//This will set proto.notOwn.prop to 'b'
|
|
128
|
+
objectPath.set(obj, 'notOwn.prop', 'b');
|
|
129
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -169,11 +169,14 @@ declare namespace LocationParam {
|
|
|
169
169
|
export function parse(paramString: string): object;
|
|
170
170
|
export function paramSearch(_name: string, target: string): void;
|
|
171
171
|
/**
|
|
172
|
-
* 获取 location 中的所有参数
|
|
172
|
+
* - 获取 location 中的所有参数
|
|
173
|
+
* - 对 location.href 进行查找,支持 hash 方式的路由
|
|
173
174
|
*/
|
|
174
175
|
export function getLocationParams(): object;
|
|
175
176
|
/**
|
|
176
|
-
* 获取 location
|
|
177
|
+
* - 获取 location 中的参数。
|
|
178
|
+
* - 采用 location.search 进行查找,因此,如果采用 react-router hash 方式,将无法获取到参数
|
|
179
|
+
* - why not support hash router? because in hash router location.search=''
|
|
177
180
|
* @param name
|
|
178
181
|
*/
|
|
179
182
|
export function getLocationParamByName(name: string): string | null;
|
|
@@ -567,7 +570,7 @@ export function objectValues(obj): any;
|
|
|
567
570
|
* @param obj 目标对象
|
|
568
571
|
* @param keys 需要删除的键
|
|
569
572
|
* @example
|
|
570
|
-
* omit({ name: 'ilex', age: 16 }, ['age']) // { name: 'ilex' }
|
|
573
|
+
* omit({ name: 'ilex', age: 16 }, ['age']); // { name: 'ilex' }
|
|
571
574
|
*/
|
|
572
575
|
export function omit(obj: object, keys: string | Array<String>): any;
|
|
573
576
|
|
|
@@ -576,7 +579,8 @@ export function omit(obj: object, keys: string | Array<String>): any;
|
|
|
576
579
|
* @param obj
|
|
577
580
|
* @param keys
|
|
578
581
|
* @example
|
|
579
|
-
*
|
|
582
|
+
* pick({ name: 'ilex', age: 16 }, ['age']); // { age: 16 }
|
|
583
|
+
* pick({ name: 'ilex', age: 16 }, ['']); // {}
|
|
580
584
|
*/
|
|
581
585
|
export function pick(obj: Object | Function, keys: string | Array<String>): Object;
|
|
582
586
|
/**
|
|
@@ -985,6 +989,12 @@ declare namespace utils {
|
|
|
985
989
|
* @return target
|
|
986
990
|
*/
|
|
987
991
|
export function mergeAll(targetAndSources: Array<any>, overwrite?: boolean): object | Array<any>;
|
|
992
|
+
/**
|
|
993
|
+
* 比较 objTarget 中的所有属性值,是否在 objSource 中相等
|
|
994
|
+
* @param objSource
|
|
995
|
+
* @param objTarget
|
|
996
|
+
*/
|
|
997
|
+
export function subObjectEqual(objSource: {}, objTarget: {}): Boolean;
|
|
988
998
|
}
|
|
989
999
|
|
|
990
1000
|
declare namespace throttleDebounce {
|
|
@@ -1060,3 +1070,12 @@ declare const arrayMove: {
|
|
|
1060
1070
|
// TODO: Remove this for the next major release
|
|
1061
1071
|
default: typeof arrayMove;
|
|
1062
1072
|
};
|
|
1073
|
+
|
|
1074
|
+
declare namespace flat {
|
|
1075
|
+
/**
|
|
1076
|
+
* 获取树结构数据 flat keys
|
|
1077
|
+
* @param item
|
|
1078
|
+
* @param options
|
|
1079
|
+
*/
|
|
1080
|
+
export function getTreeFlatKeys(item: Object | any[], options = { uniqueKey: 'key', childrenKey: 'children' }): String[] | Number[];
|
|
1081
|
+
}
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var amostool = require('./lib/amostool');
|
|
2
|
-
|
|
3
|
-
module.exports = amostool;
|
|
1
|
+
var amostool = require('./lib/amostool');
|
|
2
|
+
|
|
3
|
+
module.exports = amostool;
|
package/lib/_browser.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
|
|
2
3
|
var Browser = {
|
|
3
4
|
isFirefox: function() {
|
|
4
|
-
return "undefined" != typeof InstallTrigger
|
|
5
|
+
return "undefined" != typeof InstallTrigger;
|
|
5
6
|
},
|
|
6
7
|
isIE: function() {
|
|
7
|
-
return !!document.documentMode
|
|
8
|
+
return !!document.documentMode;
|
|
8
9
|
},
|
|
9
10
|
isEdge: function() {
|
|
10
|
-
return !Browser.isIE() && !!window.StyleMedia
|
|
11
|
+
return !Browser.isIE() && !!window.StyleMedia;
|
|
11
12
|
},
|
|
12
13
|
isChrome: function() {
|
|
13
|
-
return !!window.chrome && !!window.chrome.webstore
|
|
14
|
+
return !!window.chrome && !!window.chrome.webstore;
|
|
14
15
|
},
|
|
15
16
|
isSafari: function() {
|
|
16
|
-
return
|
|
17
|
+
return Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor") > 0 || -1 !== navigator.userAgent.toLowerCase().indexOf("safari");
|
|
17
18
|
},
|
|
18
19
|
wp: function() {
|
|
19
|
-
navigator.userAgent.match(/Windows Phone ([\d.]+)/)
|
|
20
|
+
navigator.userAgent.match(/Windows Phone ([\d.]+)/);
|
|
20
21
|
},
|
|
21
22
|
android: function() {
|
|
22
|
-
navigator.userAgent.match(/(Android);?[\s\/]+([\d.]+)?/)
|
|
23
|
+
navigator.userAgent.match(/(Android);?[\s\/]+([\d.]+)?/);
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
module.exports = Browser;
|
package/lib/_clone.js
CHANGED
|
@@ -1,74 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return (
|
|
5
|
-
return typeof e
|
|
6
|
-
} : function(e) {
|
|
7
|
-
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
|
|
8
|
-
})(e)
|
|
9
|
-
}
|
|
10
|
-
var findType = function(e) {
|
|
11
|
-
return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), findType = function(e) {
|
|
4
|
+
return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1];
|
|
12
5
|
};
|
|
13
6
|
|
|
14
7
|
function findAllType(e) {
|
|
15
8
|
switch (Object.prototype.toString.call(e)) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
case "[object Date]":
|
|
10
|
+
return "date";
|
|
11
|
+
|
|
12
|
+
case "[object RegExp]":
|
|
13
|
+
return "regexp";
|
|
14
|
+
|
|
15
|
+
case "[object Arguments]":
|
|
16
|
+
return "arguments";
|
|
17
|
+
|
|
18
|
+
case "[object Array]":
|
|
19
|
+
return "array";
|
|
20
|
+
|
|
21
|
+
case "[object Error]":
|
|
22
|
+
return "error";
|
|
26
23
|
}
|
|
27
|
-
return null === e ? "null" : void 0 === e ? "undefined" : e && 1 === e.nodeType ? "element" :
|
|
24
|
+
return null === e ? "null" : void 0 === e ? "undefined" : e && 1 === e.nodeType ? "element" : (e = e.valueOf ? e.valueOf() : Object.prototype.valueOf.apply(e),
|
|
25
|
+
(0, _typeof2.default)(e));
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
27
|
+
|
|
28
|
+
var simpleClone = function e(r) {
|
|
29
|
+
switch (findType(r)) {
|
|
30
|
+
case "Object":
|
|
31
|
+
var t = {};
|
|
32
|
+
for (var n in r) r.hasOwnProperty(n) && (t[n] = e(r[n]));
|
|
33
|
+
return t;
|
|
34
|
+
|
|
35
|
+
case "Array":
|
|
36
|
+
return r.slice();
|
|
37
|
+
}
|
|
38
|
+
return r;
|
|
39
|
+
}, clone = function(e) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(JSON.stringify(e, (function(e, r) {
|
|
42
|
+
return "function" == typeof r ? r.toString() : r;
|
|
43
|
+
})));
|
|
44
|
+
} catch (r) {
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
}, cloneAll = function e(r) {
|
|
48
|
+
switch (findAllType(r)) {
|
|
49
|
+
case "object":
|
|
50
|
+
var t = {};
|
|
51
|
+
return Object.keys(r).forEach((function(n) {
|
|
52
|
+
"$" !== n.charAt(0) && (t[n] = e(r[n]));
|
|
53
|
+
})), t;
|
|
54
|
+
|
|
55
|
+
case "element":
|
|
56
|
+
return r.cloneNode(!0);
|
|
57
|
+
|
|
58
|
+
case "array":
|
|
59
|
+
for (var n = new Array(r.length), o = 0, l = r.length; o < l; o++) n[o] = e(r[o]);
|
|
60
|
+
return n;
|
|
61
|
+
|
|
62
|
+
case "regexp":
|
|
63
|
+
var a = "";
|
|
64
|
+
return a += r.multiline ? "m" : "", a += r.global ? "g" : "", a += r.ignoreCase ? "i" : "",
|
|
65
|
+
new RegExp(r.source, a);
|
|
66
|
+
|
|
67
|
+
case "date":
|
|
68
|
+
return new Date(r.getTime());
|
|
69
|
+
|
|
70
|
+
default:
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
70
75
|
module.exports = {
|
|
71
76
|
simpleClone: simpleClone,
|
|
72
77
|
clone: clone,
|
|
73
78
|
cloneAll: cloneAll
|
|
74
|
-
};
|
|
79
|
+
};
|