amos-tool 1.5.1 → 1.5.3
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/docs/Logger.html +6 -2
- package/docs/global.html +839 -124
- package/docs/index.html +6 -2
- package/index.d.ts +58 -0
- package/lib/_pickBy.js +13 -0
- package/lib/amostool.js +3 -1
- package/lib/dom/escapeHtml.js +37 -0
- package/lib/locationParams.js +75 -46
- package/lib/parseText.js +3 -3
- package/lib/png/pnglib.js +1 -1
- package/lib/utils.js +29 -2
- package/package.json +2 -3
package/docs/index.html
CHANGED
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
|
|
28
28
|
<nav >
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<input type="text" id="nav-search" placeholder="Search" />
|
|
31
|
+
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Logger.html">Logger</a><ul class='methods'><li data-type='method'><a href="Logger.html#pkgInfo">pkgInfo</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#_boost">_boost</a></li><li><a href="global.html#_defaultBrowsers">_defaultBrowsers</a></li><li><a href="global.html#_muiltBrowsers">_muiltBrowsers</a></li><li><a href="global.html#advancePolicy">advancePolicy</a></li><li><a href="global.html#alphaHexMap">alphaHexMap</a></li><li><a href="global.html#amosCookie">amosCookie</a></li><li><a href="global.html#array2tree">array2tree</a></li><li><a href="global.html#arrayFilter">arrayFilter</a></li><li><a href="global.html#beautifyRoutes">beautifyRoutes</a></li><li><a href="global.html#browserSupport">browserSupport</a></li><li><a href="global.html#bt4ToHex">bt4ToHex</a></li><li><a href="global.html#byteToString">byteToString</a></li><li><a href="global.html#calcBrowserVersion">calcBrowserVersion</a></li><li><a href="global.html#checkFlash">checkFlash</a></li><li><a href="global.html#clone">clone</a></li><li><a href="global.html#colorKeyWordsHexStr">colorKeyWordsHexStr</a></li><li><a href="global.html#completeUnit">completeUnit</a></li><li><a href="global.html#customEqual">customEqual</a></li><li><a href="global.html#debounce">debounce</a></li><li><a href="global.html#deepCopy">deepCopy</a></li><li><a href="global.html#deepEqual">deepEqual</a></li><li><a href="global.html#DesUtils">DesUtils</a></li><li><a href="global.html#divide">divide</a></li><li><a href="global.html#drawPolygon">drawPolygon</a></li><li><a href="global.html#enc">enc</a></li><li><a href="global.html#encodeLen">encodeLen</a></li><li><a href="global.html#encodeNumber">encodeNumber</a></li><li><a href="global.html#eq">eq</a></li><li><a href="global.html#fieldContentRegExp">fieldContentRegExp</a></li><li><a href="global.html#fileSizeToByte">fileSizeToByte</a></li><li><a href="global.html#fileterAllMatchedData">fileterAllMatchedData</a></li><li><a href="global.html#filterAllCheckedData">filterAllCheckedData</a></li><li><a href="global.html#filterChilds">filterChilds</a></li><li><a href="global.html#filterTreeLevel">filterTreeLevel</a></li><li><a href="global.html#genBitmapImage">genBitmapImage</a></li><li><a href="global.html#generateKeys">generateKeys</a></li><li><a href="global.html#getFileExtension">getFileExtension</a></li><li><a href="global.html#getKeyBytes">getKeyBytes</a></li><li><a href="global.html#getTreeFlatKeys">getTreeFlatKeys</a></li><li><a href="global.html#gradientColor">gradientColor</a></li><li><a href="global.html#has">has</a></li><li><a href="global.html#hasOwnProperty">hasOwnProperty</a></li><li><a href="global.html#hexToBt4">hexToBt4</a></li><li><a href="global.html#imageCompress">imageCompress</a></li><li><a href="global.html#isArray">isArray</a></li><li><a href="global.html#isBoolean">isBoolean</a></li><li><a href="global.html#isBuiltInObject">isBuiltInObject</a></li><li><a href="global.html#isDom">isDom</a></li><li><a href="global.html#isElement">isElement</a></li><li><a href="global.html#isEmpty">isEmpty</a></li><li><a href="global.html#isEmptyObject">isEmptyObject</a></li><li><a href="global.html#isFloat">isFloat</a></li><li><a href="global.html#isHexColor">isHexColor</a></li><li><a href="global.html#isImageSrc">isImageSrc</a></li><li><a href="global.html#isInputEqual">isInputEqual</a></li><li><a href="global.html#isJson">isJson</a></li><li><a href="global.html#isKeyColor">isKeyColor</a></li><li><a href="global.html#isKeyInObject">isKeyInObject</a></li><li><a href="global.html#isNil">isNil</a></li><li><a href="global.html#isNull">isNull</a></li><li><a href="global.html#isNullOrUndefined">isNullOrUndefined</a></li><li><a href="global.html#isNumber">isNumber</a></li><li><a href="global.html#isObject">isObject</a></li><li><a href="global.html#isOnlyObject">isOnlyObject</a></li><li><a href="global.html#isOpacity">isOpacity</a></li><li><a href="global.html#isOwnKeyInObject">isOwnKeyInObject</a></li><li><a href="global.html#isPromise">isPromise</a></li><li><a href="global.html#isRgbColor">isRgbColor</a></li><li><a href="global.html#isUndefined">isUndefined</a></li><li><a href="global.html#isUrl">isUrl</a></li><li><a href="global.html#isValidDate">isValidDate</a></li><li><a href="global.html#keyColorToHex">keyColorToHex</a></li><li><a href="global.html#Log">Log</a></li><li><a href="global.html#merge">merge</a></li><li><a href="global.html#mergeAll">mergeAll</a></li><li><a href="global.html#mod">mod</a></li><li><a href="global.html#multiply">multiply</a></li><li><a href="global.html#normalPolicy">normalPolicy</a></li><li><a href="global.html#null2default">null2default</a></li><li><a href="global.html#objRGB2str">objRGB2str</a></li><li><a href="global.html#parse">parse</a></li><li><a href="global.html#pathToTree">pathToTree</a></li><li><a href="global.html#plus">plus</a></li><li><a href="global.html#PNGlib">PNGlib</a></li><li><a href="global.html#Queue">Queue</a></li><li><a href="global.html#random">random</a></li><li><a href="global.html#randomInt">randomInt</a></li><li><a href="global.html#recursive">recursive</a></li><li><a href="global.html#recursiveGen">recursiveGen</a></li><li><a href="global.html#rgb2object">rgb2object</a></li><li><a href="global.html#saveAsImage">saveAsImage</a></li><li><a href="global.html#serialize">serialize</a></li><li><a href="global.html#shallowEqual">shallowEqual</a></li><li><a href="global.html#simpleEqual">simpleEqual</a></li><li><a href="global.html#simpleThrottle">simpleThrottle</a></li><li><a href="global.html#slpitArray">slpitArray</a></li><li><a href="global.html#some">some</a></li><li><a href="global.html#stringIsJson">stringIsJson</a></li><li><a href="global.html#strToBt">strToBt</a></li><li><a href="global.html#subObjectEqual">subObjectEqual</a></li><li><a href="global.html#subtract">subtract</a></li><li><a href="global.html#throttle">throttle</a></li><li><a href="global.html#toHexAlphaColor">toHexAlphaColor</a></li><li><a href="global.html#toHexColor">toHexColor</a></li><li><a href="global.html#toRGBcolor">toRGBcolor</a></li><li><a href="global.html#toStringHexColor">toStringHexColor</a></li><li><a href="global.html#transformColor">transformColor</a></li><li><a href="global.html#useMd5Policy">useMd5Policy</a></li><li><a href="global.html#useMd5Policy2">useMd5Policy2</a></li><li><a href="global.html#utils">utils</a></li><li><a href="global.html#values">values</a></li></ul>
|
|
31
33
|
</nav>
|
|
32
34
|
|
|
33
35
|
<div id="main">
|
|
@@ -783,13 +785,15 @@ convert2BMP(canvas, width, height)</p>
|
|
|
783
785
|
<br class="clear">
|
|
784
786
|
|
|
785
787
|
<footer>
|
|
786
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> on
|
|
788
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> on Thu Mar 16 2023 10:03:24 GMT+0800 (GMT+08:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
787
789
|
</footer>
|
|
788
790
|
|
|
789
791
|
<script>prettyPrint();</script>
|
|
790
792
|
<script src="scripts/polyfill.js"></script>
|
|
791
793
|
<script src="scripts/linenumber.js"></script>
|
|
792
794
|
|
|
795
|
+
<script src="scripts/search.js" defer></script>
|
|
796
|
+
|
|
793
797
|
|
|
794
798
|
|
|
795
799
|
</body>
|
package/index.d.ts
CHANGED
|
@@ -252,8 +252,52 @@ declare namespace LocationParam {
|
|
|
252
252
|
* completeParam({ token: 'xxddf', id: null }, '/main/sub', true); // `/main/sub?token=xxddf&id=`
|
|
253
253
|
* // 使用 location.href, 传入两个参数,强制转化 null 值
|
|
254
254
|
* completeParam({ token: 'xxddf', id: null }, true); // `http://localhost:8080/aaa?token=xxddf&id=`
|
|
255
|
+
*
|
|
256
|
+
* // 叠加值,该方法只会叠加参数,如果需要更新已有字段,以及叠加参数,可以使用 `changeParam`
|
|
257
|
+
* completeParam({ token: 'aa-bb-cc', id: '654321' }, 'a/b/c?token=aaa&id=bcdef'); // `a/b/c?token=aaa&id=bcdef&token=aa-bb-cc&id=654321`
|
|
255
258
|
*/
|
|
256
259
|
export function completeParam(param: Object, url: string, forceCast: Boolean): string;
|
|
260
|
+
/**
|
|
261
|
+
* 替换 url 参数。如果url中无指定的参数,则自动追加。
|
|
262
|
+
*
|
|
263
|
+
* 自动将对象中的 undefined 值,转化为 ''。null 值则直接返回 null 字符串。
|
|
264
|
+
*
|
|
265
|
+
* params 参数中的数据格式,建议调用处统一处理为 string 格式。内部仅统一处理 undefined 和 {} 格式。
|
|
266
|
+
* @param href 需要替换参数的 url。为空字符串则直接返回 href
|
|
267
|
+
* @param params 参数对象。为空对象,则直接返回 href。
|
|
268
|
+
* @example
|
|
269
|
+
* // 无参数,自动追加
|
|
270
|
+
* changeParam('a/b/d/g', { a: 1, b: 2, c: 3 }); // 'a/b/d/g?a=1&b=2&c=3'
|
|
271
|
+
* // 更新已有参数的值
|
|
272
|
+
* changeParam('a/b/d/g?a=aa&b=bb&c=cc', { a: 1, b: 2, c: 3 }); // 'a/b/d/g?a=1&b=2&c=3'
|
|
273
|
+
* // url 中无参数 d,自动追加参数
|
|
274
|
+
* changeParam('a/b/d/g?a=aa&b=bb&c=cc', { a: 1, b: 2, c: 3, d: 5 }); // 'a/b/d/g?a=1&b=2&c=3&d=5'
|
|
275
|
+
* // undefined 值转化为 ''
|
|
276
|
+
* changeParam('a/b/d/g', { a: 1, b: 2, c: undefined }); // 'a/b/d/g?a=1&b=2&c='
|
|
277
|
+
* // null 值转化为 'null'
|
|
278
|
+
* changeParam('a/b/d/g', { a: 1, b: null, c: undefined }); // 'a/b/d/g?a=1&b=null&c='
|
|
279
|
+
* // [] 和 {} 值。最好不要给参数中传入 {} 值
|
|
280
|
+
* changeParam('a/b/d/g', { a: { m: 3 }, b: [1,2] }); // a/b/d/g?a={"m":3}&b=1,2
|
|
281
|
+
*/
|
|
282
|
+
export function changeParam(href: String, params: Object): String;
|
|
283
|
+
/**
|
|
284
|
+
* encode 参数中的值
|
|
285
|
+
* @param param
|
|
286
|
+
* @param keys 需要执行 encode 的字段
|
|
287
|
+
* @param processor 自定义 encode 方法,默认采用 `encodeURIComponent`
|
|
288
|
+
* @example
|
|
289
|
+
* encodeParam({ name: 'ilex', email: 'aa@qq.com' }, 'email'); // { name: 'ilex', email: 'aa%40qq.com' }
|
|
290
|
+
* encodeParam({ info: { hobby: 'coding', phone: '155666688881' } }, 'info'); // { info: '%7B%22hobby%22%3A%22coding%22%2C%22phone%22%3A%22155666688881%22%7D' }
|
|
291
|
+
* encodeParam({ split: [1,2,3] }, 'split'); // { split: '%5B1%2C2%2C3%5D' }
|
|
292
|
+
* encodeParam({ star: 18 }, 'star', v => v * 2); // { star: 36 }
|
|
293
|
+
*/
|
|
294
|
+
export function encodeParam(param: {}, keys: String | String[], processor: (arg) => String): {};
|
|
295
|
+
/**
|
|
296
|
+
* 更新浏览器地址栏地址
|
|
297
|
+
* @param param
|
|
298
|
+
* @param href 指定的地址,如果不指定,则采用 location.href
|
|
299
|
+
*/
|
|
300
|
+
export function replaceUrl(param: Object, href?: String): void;
|
|
257
301
|
export type LocationSearch = { init(): void; getValue(key: string): string; getParameters(): Array<any> };
|
|
258
302
|
export type LSFN = { getValue(): string; getParameters(): Array<any> };
|
|
259
303
|
}
|
|
@@ -643,6 +687,15 @@ export function omit(obj: object, keys: string | Array<String>): any;
|
|
|
643
687
|
* pick({ name: 'ilex', age: 16 }, ['']); // {}
|
|
644
688
|
*/
|
|
645
689
|
export function pick(obj: Object | Function, keys: string | Array<String>): Object;
|
|
690
|
+
/**
|
|
691
|
+
* 从指定的 obj 中获取 满足 judge(key, value) 组成新的对象
|
|
692
|
+
*
|
|
693
|
+
* @param obj
|
|
694
|
+
* @param judge
|
|
695
|
+
* @example
|
|
696
|
+
* pickBy({ a: 1, b: 2, c: 'ray' }, (key, value) => typeof value === 'number')
|
|
697
|
+
*/
|
|
698
|
+
export function pickBy(obj: Object | Function, judge: (key, value) => Boolean): Object;
|
|
646
699
|
/**
|
|
647
700
|
* 将数据转化为json
|
|
648
701
|
* @param data
|
|
@@ -990,6 +1043,11 @@ declare namespace utils {
|
|
|
990
1043
|
* @returns boolean true 是 false不是
|
|
991
1044
|
*/
|
|
992
1045
|
export function isJson(obj: any): boolean;
|
|
1046
|
+
|
|
1047
|
+
export function isSymbol(obj: any): boolean;
|
|
1048
|
+
export function isNullOrUndefined(obj: any): boolean;
|
|
1049
|
+
export function isDate(obj: any): boolean;
|
|
1050
|
+
|
|
993
1051
|
/**
|
|
994
1052
|
* 判断string能否被转成json
|
|
995
1053
|
* 参数 str 如果不是 string 则直接返回 false
|
package/lib/_pickBy.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _utils = require("./utils");
|
|
4
|
+
|
|
5
|
+
module.exports = function(t, r) {
|
|
6
|
+
if (!_utils.isObject(t)) return {};
|
|
7
|
+
var i = {};
|
|
8
|
+
if (_utils.isFunction(r)) for (var e = Object.keys(t), u = 0, s = e.length; u < s; u++) {
|
|
9
|
+
var n = e[u];
|
|
10
|
+
r(n, t[n]) && (i[n] = t[n]);
|
|
11
|
+
}
|
|
12
|
+
return i;
|
|
13
|
+
};
|
package/lib/amostool.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var Base64 = require("./encrypt/_base64"), MD5 = require("./encrypt/_md5"), DES = require("./encrypt/des"), Browser = require("./_browser"), cloneTools = require("./_clone"), amosCookie = require("./_cookie"), deepCopy = require("./_deepCopy"), deepEqual = require("./_deepEqual"), _fastDeepEqual = require("./_fastDeepEqual"), funcThrottle = require("./_funcThrottle"), isNode = require("./_isnode"), List = require("./_list"), _objectAssign = require("./_object.assign"), _objectEntries = require("./_object.entries"), _objectValues = require("./_object.values"), omit = require("./_omit"), pick = require("./_pick"), parseJson = require("./_parseJson"), Queue = require("./_queue"), shallowCopy = require("./_shallowCopy"), stringify = require("./_stringify"), supportWs = require("./_supportWs"), trim = require("./_trim"), UUID = require("./_uuids"), array2tree = require("./array2tree"), arrayFilter = require("./arrayFilter"), arrayUtils = require("./arrayUtils"), browserSupport = require("./browserSupport"), completeUnit = require("./completeUnit"), consts = require("./consts"), flat = require("./flat"), LocationParam = require("./locationParams"), Log = require("./log"), merged = require("./merged"), objectPath = require("./objectPath"), parseText = require("./parseText"), pwdPolicy = require("./pwdPolicy"), random = require("./random"), shallowEqual = require("./shallowEqual"), Store = require("./store"), strUtils = require("./strUtils"), tableFilter = require("./tableFilter"), utils = require("./utils"), canvas2img = require("./dom/canvas2img"), canvasTools = require("./dom/canvasTools"), downloadFile = require("./dom/downloadFile"), eventHelper = require("./dom/eventHelper"), fileBlob = require("./dom/fileBlob"), fileSaveAs = require("./dom/fileSaveAs"), getFontSize = require("./dom/getFontSize"), minfyImg = require("./dom/minfyImg"), addition = require("./math/addition"), amountCase = require("./math/amountCase"), coinFormat = require("./math/coinFormat"), colorUtil = require("./math/colorUtil"), dateTime = require("./math/dateTime"), pwdStrength = require("./math/pwdStrength"), randomColor = require("./math/randomColor"), subtraction = require("./math/subtraction"), accMul = require("./math/mul"), qs = require("./qs"), encodeUrl = require("./url/encodeUrl"), restfulUrl = require("./url/restfulUrl"), positionFactory = require("./positionFactory"), throttleDebounce = require("./throttleDebounce"), checkFlash = require("./_flashSupport");
|
|
3
|
+
var Base64 = require("./encrypt/_base64"), MD5 = require("./encrypt/_md5"), DES = require("./encrypt/des"), Browser = require("./_browser"), cloneTools = require("./_clone"), amosCookie = require("./_cookie"), deepCopy = require("./_deepCopy"), deepEqual = require("./_deepEqual"), _fastDeepEqual = require("./_fastDeepEqual"), funcThrottle = require("./_funcThrottle"), isNode = require("./_isnode"), List = require("./_list"), _objectAssign = require("./_object.assign"), _objectEntries = require("./_object.entries"), _objectValues = require("./_object.values"), omit = require("./_omit"), pick = require("./_pick"), pickBy = require("./_pickBy"), parseJson = require("./_parseJson"), Queue = require("./_queue"), shallowCopy = require("./_shallowCopy"), stringify = require("./_stringify"), supportWs = require("./_supportWs"), trim = require("./_trim"), UUID = require("./_uuids"), array2tree = require("./array2tree"), arrayFilter = require("./arrayFilter"), arrayUtils = require("./arrayUtils"), browserSupport = require("./browserSupport"), completeUnit = require("./completeUnit"), consts = require("./consts"), flat = require("./flat"), LocationParam = require("./locationParams"), Log = require("./log"), merged = require("./merged"), objectPath = require("./objectPath"), parseText = require("./parseText"), pwdPolicy = require("./pwdPolicy"), random = require("./random"), shallowEqual = require("./shallowEqual"), Store = require("./store"), strUtils = require("./strUtils"), tableFilter = require("./tableFilter"), utils = require("./utils"), canvas2img = require("./dom/canvas2img"), canvasTools = require("./dom/canvasTools"), downloadFile = require("./dom/downloadFile"), escapeHtml = require("./dom/escapeHtml"), eventHelper = require("./dom/eventHelper"), fileBlob = require("./dom/fileBlob"), fileSaveAs = require("./dom/fileSaveAs"), getFontSize = require("./dom/getFontSize"), minfyImg = require("./dom/minfyImg"), addition = require("./math/addition"), amountCase = require("./math/amountCase"), coinFormat = require("./math/coinFormat"), colorUtil = require("./math/colorUtil"), dateTime = require("./math/dateTime"), pwdStrength = require("./math/pwdStrength"), randomColor = require("./math/randomColor"), subtraction = require("./math/subtraction"), accMul = require("./math/mul"), qs = require("./qs"), encodeUrl = require("./url/encodeUrl"), restfulUrl = require("./url/restfulUrl"), positionFactory = require("./positionFactory"), throttleDebounce = require("./throttleDebounce"), checkFlash = require("./_flashSupport");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
Base64: Base64,
|
|
@@ -20,6 +20,7 @@ module.exports = {
|
|
|
20
20
|
objectValues: _objectValues,
|
|
21
21
|
omit: omit,
|
|
22
22
|
pick: pick,
|
|
23
|
+
pickBy: pickBy,
|
|
23
24
|
parseJson: parseJson,
|
|
24
25
|
Queue: Queue,
|
|
25
26
|
shallowCopy: shallowCopy,
|
|
@@ -50,6 +51,7 @@ module.exports = {
|
|
|
50
51
|
canvas2img: canvas2img,
|
|
51
52
|
canvasTools: canvasTools,
|
|
52
53
|
downloadFile: downloadFile,
|
|
54
|
+
escapeHtml: escapeHtml,
|
|
53
55
|
eventHelper: eventHelper,
|
|
54
56
|
fileBlob: fileBlob,
|
|
55
57
|
fileSaveAs: fileSaveAs,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var matchHtmlRegExp = /["'&<>]/;
|
|
4
|
+
|
|
5
|
+
module.exports = function(e) {
|
|
6
|
+
var t, a = "" + e, r = matchHtmlRegExp.exec(a);
|
|
7
|
+
if (!r) return a;
|
|
8
|
+
var c = "", s = 0, n = 0;
|
|
9
|
+
for (s = r.index; s < a.length; s++) {
|
|
10
|
+
switch (a.charCodeAt(s)) {
|
|
11
|
+
case 34:
|
|
12
|
+
t = """;
|
|
13
|
+
break;
|
|
14
|
+
|
|
15
|
+
case 38:
|
|
16
|
+
t = "&";
|
|
17
|
+
break;
|
|
18
|
+
|
|
19
|
+
case 39:
|
|
20
|
+
t = "'";
|
|
21
|
+
break;
|
|
22
|
+
|
|
23
|
+
case 60:
|
|
24
|
+
t = "<";
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
case 62:
|
|
28
|
+
t = ">";
|
|
29
|
+
break;
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
n !== s && (c += a.substring(n, s)), n = s + 1, c += t;
|
|
35
|
+
}
|
|
36
|
+
return n !== s ? c + a.substring(n, s) : c;
|
|
37
|
+
};
|
package/lib/locationParams.js
CHANGED
|
@@ -5,13 +5,13 @@ var utils = require("./utils"), _LSFN = function() {
|
|
|
5
5
|
return function() {
|
|
6
6
|
var n = window.location.search;
|
|
7
7
|
if (utils.isEmpty(n)) throw new Error("the [window.location.search] not empty!");
|
|
8
|
-
var
|
|
9
|
-
utils.isNull(
|
|
8
|
+
var i = n.length > 1 ? n.substring(1) : null;
|
|
9
|
+
utils.isNull(i) || (t = [].slice.call(i.split("&")));
|
|
10
10
|
}(), {
|
|
11
11
|
getValue: function(n) {
|
|
12
12
|
t.forEach((function(t) {
|
|
13
|
-
var
|
|
14
|
-
if (
|
|
13
|
+
var i = t.split("=");
|
|
14
|
+
if (i[0] === n) return i[1];
|
|
15
15
|
}));
|
|
16
16
|
},
|
|
17
17
|
getParameters: function() {
|
|
@@ -32,8 +32,8 @@ var utils = require("./utils"), _LSFN = function() {
|
|
|
32
32
|
},
|
|
33
33
|
getValue: function(t) {
|
|
34
34
|
_LocationSearch._keyValuePairs.forEach((function(n) {
|
|
35
|
-
var
|
|
36
|
-
if (
|
|
35
|
+
var i = n.split("=");
|
|
36
|
+
if (i[0] === t) return i[1];
|
|
37
37
|
}));
|
|
38
38
|
},
|
|
39
39
|
getParameters: function() {
|
|
@@ -44,21 +44,21 @@ var utils = require("./utils"), _LSFN = function() {
|
|
|
44
44
|
}
|
|
45
45
|
}, LocationParam = {
|
|
46
46
|
parse: function(t) {
|
|
47
|
-
var n, e,
|
|
47
|
+
var n, i, e, r, o;
|
|
48
48
|
t || (t = window.location.search);
|
|
49
|
-
var a = {},
|
|
50
|
-
if (!utils.isEmpty(t) && t.length > 1) for (
|
|
51
|
-
|
|
49
|
+
var a = {}, s = [];
|
|
50
|
+
if (!utils.isEmpty(t) && t.length > 1) for (r = 0, o = (s = t.slice(1 + t.indexOf("?"), t.length).split("&")).length; r < o; r++) n = (i = (i = s[r]).split("="))[0],
|
|
51
|
+
e = i[1], n in a ? (utils.isArray(a[n]) || (a[n] = [ a[n] ]), a[n].push(decodeURIComponent(e))) : a[n] = decodeURIComponent(e);
|
|
52
52
|
return a;
|
|
53
53
|
},
|
|
54
54
|
paramSearch: function(t, n) {
|
|
55
55
|
if (utils.isUndefined(n) || utils.isNull(n)) {
|
|
56
56
|
if (n = window.location.search, utils.isUndefined(t) || utils.isNull(t)) {
|
|
57
|
-
for (var
|
|
58
|
-
var
|
|
59
|
-
1 ===
|
|
57
|
+
for (var i = n.substr(1, n.length - 1).split("&"), e = {}, r = 0; r < i.length; r++) {
|
|
58
|
+
var o = i[r].split("=");
|
|
59
|
+
1 === o.length ? e[o[0]] = "" : 2 === o.length ? e[o[0]] = decodeURIComponent(o[1]) : console.log("there is something wrong when use [paramSearch]!");
|
|
60
60
|
}
|
|
61
|
-
return
|
|
61
|
+
return e;
|
|
62
62
|
}
|
|
63
63
|
try {
|
|
64
64
|
var a = new RegExp(t + "=([^&]+)?");
|
|
@@ -69,54 +69,83 @@ var utils = require("./utils"), _LSFN = function() {
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
getLocationParams: function() {
|
|
72
|
-
var t, n,
|
|
73
|
-
if (!utils.isEmpty(
|
|
74
|
-
var
|
|
75
|
-
if (
|
|
76
|
-
n =
|
|
72
|
+
var t, n, i = {}, e = window.location.href;
|
|
73
|
+
if (!utils.isEmpty(e)) {
|
|
74
|
+
var r = e.indexOf("?");
|
|
75
|
+
if (r < -1) console.log("the location.href is invalid!"); else for (var o = (e = e.substr(r + 1)).split("&"), a = 0; a < o.length; a++) (r = o[a].indexOf("=")) > 0 && (t = o[a].substring(0, r),
|
|
76
|
+
n = o[a].substr(r + 1), i[t] = decodeURIComponent(n));
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return i;
|
|
79
79
|
},
|
|
80
80
|
getLocationParamByName: function(t) {
|
|
81
|
-
var n = new RegExp("(^|&?)".concat(t, "=([^&]*)(&|$)")),
|
|
82
|
-
return null !=
|
|
81
|
+
var n = new RegExp("(^|&?)".concat(t, "=([^&]*)(&|$)")), i = window.location.search.substr(1).match(n);
|
|
82
|
+
return null != i ? decodeURIComponent(i[2]) : null;
|
|
83
83
|
},
|
|
84
84
|
getParameter: function(t, n) {
|
|
85
|
-
var
|
|
86
|
-
return
|
|
85
|
+
var i = new RegExp("(\\?|#|&)" + n + "=([^&#]*)(&|#|$)"), e = t.match(i);
|
|
86
|
+
return e ? e[2] : "";
|
|
87
87
|
},
|
|
88
88
|
extractParam: function(t, n) {
|
|
89
89
|
if (!t) return null;
|
|
90
|
-
var
|
|
91
|
-
return utils.isNil(
|
|
90
|
+
var i = new RegExp("(^|&?)".concat(n, "=([^&]*)(&|$)")), e = t.substr(1).match(i);
|
|
91
|
+
return utils.isNil(e) ? null : decodeURIComponent(e[2]);
|
|
92
92
|
},
|
|
93
93
|
extractParams: function(t) {
|
|
94
|
-
var n,
|
|
95
|
-
if (!utils.isEmpty(
|
|
96
|
-
var
|
|
97
|
-
if (
|
|
98
|
-
|
|
94
|
+
var n, i, e = {}, r = t || window.location.href;
|
|
95
|
+
if (!utils.isEmpty(r)) {
|
|
96
|
+
var o = r.indexOf("?");
|
|
97
|
+
if (o < -1) console.log("the location.href is invalid!"); else for (var a = (r = r.substr(o + 1)).split("&"), s = 0; s < a.length; s++) (o = a[s].indexOf("=")) > 0 && (n = a[s].substring(0, o),
|
|
98
|
+
i = a[s].substr(o + 1), e[n] = decodeURIComponent(i));
|
|
99
99
|
}
|
|
100
|
-
return
|
|
100
|
+
return e;
|
|
101
101
|
},
|
|
102
102
|
extractParamAll: function(t) {
|
|
103
|
-
var n,
|
|
104
|
-
if (!utils.isEmpty(
|
|
105
|
-
var a =
|
|
106
|
-
if (a < -1) console.log("the location.href is invalid!"); else for (var
|
|
107
|
-
|
|
103
|
+
var n, i, e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1], r = {}, o = t || window.location.href;
|
|
104
|
+
if (!utils.isEmpty(o)) {
|
|
105
|
+
var a = o.indexOf("?");
|
|
106
|
+
if (a < -1) console.log("the location.href is invalid!"); else for (var s = (o = o.substr(a + 1)).split("&"), l = 0; l < s.length; l++) (a = s[l].indexOf("=")) > 0 && (n = s[l].substring(0, a),
|
|
107
|
+
i = s[l].substr(a + 1), r[n] = e ? decodeURIComponent(i) : i);
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return r;
|
|
110
110
|
},
|
|
111
|
-
completeParam: function(t, n,
|
|
112
|
-
var
|
|
113
|
-
1 ===
|
|
114
|
-
n = window.location.href), utils.isUndefined(
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
return
|
|
111
|
+
completeParam: function(t, n, i) {
|
|
112
|
+
var e = arguments;
|
|
113
|
+
1 === e.length ? n || (n = window.location.href) : 2 === e.length && utils.isBoolean(n) && (i = n,
|
|
114
|
+
n = window.location.href), utils.isUndefined(i) && (i = !1), n || (n = window.location.href);
|
|
115
|
+
var r = (Object.keys(t) || []).reduce((function(n, e) {
|
|
116
|
+
var r = t[e];
|
|
117
|
+
return i && (utils.isNull(r) || utils.isUndefined(r)) && (r = ""), n += "&".concat(e, "=").concat(r);
|
|
118
118
|
}), "");
|
|
119
|
-
return
|
|
119
|
+
return r ? (r = r.slice(1), -1 !== n.indexOf("?") ? n.endsWith("?") ? "".concat(n).concat(r) : "".concat(n, "&").concat(r) : "".concat(n, "?").concat(r)) : n;
|
|
120
|
+
},
|
|
121
|
+
changeParam: function(t, n) {
|
|
122
|
+
if (!t || utils.isEmpty(n)) return t;
|
|
123
|
+
var i = t;
|
|
124
|
+
return Object.keys(n).forEach((function(t) {
|
|
125
|
+
var e = n[t];
|
|
126
|
+
utils.isUndefined(e) ? e = "" : utils.isArray(e) || utils.isObject(e) && (e = JSON.stringify(e)),
|
|
127
|
+
i = function(t, n, i) {
|
|
128
|
+
var e = n + "=([^&]*)", r = n + "=" + i;
|
|
129
|
+
if (t.match(e)) {
|
|
130
|
+
var o = new RegExp("(".concat(n, "=)([^&]*)"), "gi");
|
|
131
|
+
return t.replace(o, r);
|
|
132
|
+
}
|
|
133
|
+
return t.match("[?]") ? t + "&" + r : t + "?" + r;
|
|
134
|
+
}(i, t, e);
|
|
135
|
+
})), i;
|
|
136
|
+
},
|
|
137
|
+
encodeParam: function(t, n, i) {
|
|
138
|
+
if (utils.isNil(n) || !utils.isObject(t)) return t;
|
|
139
|
+
utils.isString(n) && (n = [ n ]);
|
|
140
|
+
for (var e = utils.clone(t), r = 0, o = n.length; r < o; r++) {
|
|
141
|
+
var a = n[r];
|
|
142
|
+
utils.isNil(e[a]) || (i ? e[a] = i(e[a]) : utils.isString(e[a]) ? e[a] = encodeURIComponent(e[a]) : (utils.isOnlyObject(e[a]) || utils.isArray(e[a])) && (e[a] = encodeURIComponent(JSON.stringify(e[a]))));
|
|
143
|
+
}
|
|
144
|
+
return e;
|
|
145
|
+
},
|
|
146
|
+
replaceUrl: function(t, n) {
|
|
147
|
+
var i = n || location.href;
|
|
148
|
+
i = LocationParam.changeParam(i, t), location.replace(i);
|
|
120
149
|
},
|
|
121
150
|
LocationSearch: _LocationSearch,
|
|
122
151
|
LSFN: _LSFN
|
package/lib/parseText.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require("./utils"), defaultRE = /\{((?:.|\n)+?)\}/g;
|
|
4
4
|
|
|
5
|
-
module.exports = function(e, t, u) {
|
|
6
|
-
return
|
|
7
|
-
return utils.isUndefined(t[
|
|
5
|
+
module.exports = function(e, i, t, u) {
|
|
6
|
+
return t || (t = defaultRE), e && e.replace ? e.replace(t, (function(e, t) {
|
|
7
|
+
return utils.isUndefined(i[t]) ? !utils.isUndefined(i[t]) || utils.isUndefined(u) && "" !== u ? e : u : i[t];
|
|
8
8
|
})) : e;
|
|
9
9
|
};
|
package/lib/png/pnglib.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @version 1.0
|
|
7
7
|
* @author Robert Eisele <robert@xarg.org>
|
|
8
8
|
* @copyright Copyright (c) 2010, Robert Eisele
|
|
9
|
-
* @
|
|
9
|
+
* @see http://www.xarg.org/2010/03/generate-client-side-png-files-using-javascript/
|
|
10
10
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
|
|
11
11
|
*
|
|
12
12
|
*/ function write(t, i) {
|
package/lib/utils.js
CHANGED
|
@@ -37,7 +37,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
37
37
|
return void 0 === e;
|
|
38
38
|
}, isNil = function(e) {
|
|
39
39
|
return null == e;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function isNullOrUndefined(e) {
|
|
43
|
+
return null == e;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var isEmptyObject = function(e) {
|
|
41
47
|
if (e) for (var t in e) if (hasOwnProperty.call(e, t)) return !1;
|
|
42
48
|
return !0;
|
|
43
49
|
}, has = function(e, t) {
|
|
@@ -87,6 +93,14 @@ var null2default = function(e) {
|
|
|
87
93
|
return "object" === (0, _typeof2.default)(e) && "[object object]" === toString.call(e).toLowerCase() && !e.length;
|
|
88
94
|
};
|
|
89
95
|
|
|
96
|
+
function isSymbol(e) {
|
|
97
|
+
return "symbol" === (0, _typeof2.default)(e);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isDate(e) {
|
|
101
|
+
return "[object Date]" === toString.call(e);
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
function _isJSON(e) {
|
|
91
105
|
return !!isString(e) && (e = e.replace(/\s/g, "").replace(/\n|\r/, ""), /^\{(.*?)\}$/.test(e) ? /"(.*?)":(.*?)/g.test(e) : !!/^\[(.*?)\]$/.test(e) && e.replace(/^\[/, "").replace(/\]$/, "").replace(/},{/g, "}\n{").split(/\n/).map((function(e) {
|
|
92
106
|
return _isJSON(e);
|
|
@@ -227,6 +241,15 @@ function isPromise(e) {
|
|
|
227
241
|
return !isNull(e) && "object" === (0, _typeof2.default)(e) && (e instanceof Promise || "[object Promise]" === toString.call(e) || e.then && isFunction(e.then));
|
|
228
242
|
}
|
|
229
243
|
|
|
244
|
+
function slpitArray(e, t) {
|
|
245
|
+
var n = e.length, r = [];
|
|
246
|
+
if (t <= n) for (var i = Math.ceil(n / t), o = 0; o < t; o++) {
|
|
247
|
+
var s = e.slice(o * i, o * i + i);
|
|
248
|
+
r.push(s);
|
|
249
|
+
} else r.push(e.slice());
|
|
250
|
+
return r;
|
|
251
|
+
}
|
|
252
|
+
|
|
230
253
|
module.exports = {
|
|
231
254
|
isString: isString,
|
|
232
255
|
isArray: isArray,
|
|
@@ -241,6 +264,7 @@ module.exports = {
|
|
|
241
264
|
isNull: isNull,
|
|
242
265
|
isUndefined: isUndefined,
|
|
243
266
|
isNil: isNil,
|
|
267
|
+
isNullOrUndefined: isNullOrUndefined,
|
|
244
268
|
has: has,
|
|
245
269
|
values: values,
|
|
246
270
|
noop: noop,
|
|
@@ -254,6 +278,8 @@ module.exports = {
|
|
|
254
278
|
isBuiltInObject: isBuiltInObject,
|
|
255
279
|
null2default: null2default,
|
|
256
280
|
isJson: isJson,
|
|
281
|
+
isSymbol: isSymbol,
|
|
282
|
+
isDate: isDate,
|
|
257
283
|
stringIsJson: stringIsJson,
|
|
258
284
|
isKeyInObject: isKeyInObject,
|
|
259
285
|
isOwnKeyInObject: isOwnKeyInObject,
|
|
@@ -272,5 +298,6 @@ module.exports = {
|
|
|
272
298
|
merge: merge,
|
|
273
299
|
mergeAll: mergeAll,
|
|
274
300
|
subObjectEqual: subObjectEqual,
|
|
275
|
-
isPromise: isPromise
|
|
301
|
+
isPromise: isPromise,
|
|
302
|
+
slpitArray: slpitArray
|
|
276
303
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amos-tool",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "amos ui tool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -31,8 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"types": "index.d.ts",
|
|
33
33
|
"homepage": "",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
},
|
|
34
|
+
"dependencies": {},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"assert": "^1.4.1",
|
|
38
37
|
"chai": "~3.4.1",
|