amos-tool 1.6.10 → 1.6.12
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 +2 -2
- package/docs/global.html +2809 -774
- package/docs/index.html +2 -2
- package/index.d.ts +82 -0
- package/lib/algorithm/index.js +7 -0
- package/lib/algorithm/is.js +65 -0
- package/lib/algorithm/rank.js +84 -0
- package/lib/amostool.js +4 -2
- package/lib/arrayUtils.js +38 -4
- package/lib/math/divide.js +17 -0
- package/lib/utils.js +9 -0
- package/package.json +1 -1
package/docs/index.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
<input type="text" id="nav-search" placeholder="Search" />
|
|
31
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><li data-type='method'><a href="Logger.html#pkgWarn">pkgWarn</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#isGIF">isGIF</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#toRealSize">toRealSize</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>
|
|
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><li data-type='method'><a href="Logger.html#pkgWarn">pkgWarn</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#contains">contains</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#hasOwnProp">hasOwnProp</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#isBaseNaN">isBaseNaN</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#isCollection">isCollection</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#isENumber">isENumber</a></li><li><a href="global.html#isFloat">isFloat</a></li><li><a href="global.html#isGIF">isGIF</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#isInteger">isInteger</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#isnan">isnan</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#MAX_LENGTH">MAX_LENGTH</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#ranks">ranks</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#toRealSize">toRealSize</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>
|
|
33
33
|
</nav>
|
|
34
34
|
|
|
35
35
|
<div id="main">
|
|
@@ -793,7 +793,7 @@ convert2BMP(canvas, width, height)</p>
|
|
|
793
793
|
<br class="clear">
|
|
794
794
|
|
|
795
795
|
<footer>
|
|
796
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> on
|
|
796
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.6</a> on Thu May 23 2024 21:25:31 GMT+0800 (GMT+08:00) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
797
797
|
</footer>
|
|
798
798
|
|
|
799
799
|
<script>prettyPrint();</script>
|
package/index.d.ts
CHANGED
|
@@ -733,6 +733,71 @@ export function trim(str: string | null | undefined): string;
|
|
|
733
733
|
export function array2tree(data, filterFn, options): Array<any>;
|
|
734
734
|
export function arrayFilter(data, options): Array<any>;
|
|
735
735
|
|
|
736
|
+
declare namespace arrayUtils {
|
|
737
|
+
/** 数组交集 */
|
|
738
|
+
export function arrayIntersection(first: [], ...args): [];
|
|
739
|
+
/**
|
|
740
|
+
* array to object
|
|
741
|
+
* @param source
|
|
742
|
+
* @param options
|
|
743
|
+
*/
|
|
744
|
+
export function arrayToObject(source: [], options: { plainObjects: Boolean }): {};
|
|
745
|
+
/**
|
|
746
|
+
* 数组去重和排序
|
|
747
|
+
* @param source 原始数组
|
|
748
|
+
* @param compareFn 排序方法
|
|
749
|
+
*/
|
|
750
|
+
export function deduplicateAndSort(source: [], compareFn: (a: T, b: T) => number): [];
|
|
751
|
+
/**
|
|
752
|
+
* 通过索引删除数组指定位置的数据。
|
|
753
|
+
*
|
|
754
|
+
* 如果 index 是数组,执行时会先进行去重,然后升序处理
|
|
755
|
+
* @param source
|
|
756
|
+
* @param index 数组索引(下标)
|
|
757
|
+
*/
|
|
758
|
+
export function removeByIndex(source: [], index: Number | Number[]): [];
|
|
759
|
+
/**
|
|
760
|
+
* 计算数组的 秩
|
|
761
|
+
* @param numbers
|
|
762
|
+
* @see https://support.minitab.com/zh-cn/minitab/help-and-how-to/statistics/nonparametrics/how-to/kruskal-wallis-test/methods-and-formulas/methods-and-formulas/#average-rank
|
|
763
|
+
*/
|
|
764
|
+
export function calculateRanks(numbers: []): [];
|
|
765
|
+
/**
|
|
766
|
+
* 要将两个二维数组按照主对角线方向合并
|
|
767
|
+
* @param arr1
|
|
768
|
+
* @param arr2
|
|
769
|
+
* @example
|
|
770
|
+
* const array1 = [[1, 2], [3, 4]];
|
|
771
|
+
* const array2 = [[5, 6], [7, 8]];
|
|
772
|
+
* merge2DArraysDiagonally(array1, array2); // 输出: [[1, 2, 5, 6], [3, 4, 7, 8]]
|
|
773
|
+
*/
|
|
774
|
+
export function merge2DArraysDiagonally(arr1: T[][], arr2: T[][]): T[][];
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare namespace algor {
|
|
778
|
+
/**
|
|
779
|
+
* Computes the sample ranks for the values of an array-like object.
|
|
780
|
+
* @see https://support.minitab.com/zh-cn/minitab/help-and-how-to/statistics/nonparametrics/how-to/mann-whitney-test/methods-and-formulas/methods-and-formulas/
|
|
781
|
+
* @param x data array
|
|
782
|
+
* @param options options object
|
|
783
|
+
* @param options.method [options.method='average'] method name determining how ties are treated
|
|
784
|
+
* @param options.missing [options.missing='last'] determines where missing values go (`first`,`last`, or `remove`)
|
|
785
|
+
* @param options.missing [options.encoding=[null,NaN]] array of values encoding missing values
|
|
786
|
+
* @example
|
|
787
|
+
* ranks( [ 1.1, 2.0, 3.5, 0.0, 2.4 ] ); // [ 2, 3, 5, 1, 4 ]
|
|
788
|
+
* ranks( [ 21.6, 12.5, 8.91, 4.0, 1.8, 1.0, 1.0, 0.8, 2.35, 4.4, 3.8, 7.4, 4.3, 19.05, 36.2 ] ); // [ 14, 12, 11, 7, 4, 2.5, 2.5, 1, 5, 9, 6, 10, 8, 13, 15 ]
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* // Ties are averaged:
|
|
792
|
+
* ranks( [ 2, 2, 1, 4, 3 ] ); // [ 2.5, 2.5, 1, 5, 4 ]
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* // Missing values are placed last:
|
|
796
|
+
* ranks( [ null, 2, 2, 1, 4, 3, NaN, NaN ] ); // [ 6, 2.5, 2.5, 1, 5, 4, 7 ,8 ]
|
|
797
|
+
*/
|
|
798
|
+
export function ranks(x: Array<Number>, options: { method: String, missing: String, encoding?: [] }): [];
|
|
799
|
+
}
|
|
800
|
+
|
|
736
801
|
/**
|
|
737
802
|
* check browser support
|
|
738
803
|
*
|
|
@@ -840,6 +905,18 @@ export function subtraction(arg1, arg2): number;
|
|
|
840
905
|
* accMul(0.5679, 100.2); // 57
|
|
841
906
|
*/
|
|
842
907
|
export function accMul(arg1: Number, arg2: Number, fix = 0): number;
|
|
908
|
+
/**
|
|
909
|
+
* 小数除法
|
|
910
|
+
* @param arg1 被乘数(接受小数和整数)
|
|
911
|
+
* @param arg2 乘数(接受小数和整数)
|
|
912
|
+
* @param fix 乘积保留几位(接受正负整数以及0)
|
|
913
|
+
* @returns {Number}
|
|
914
|
+
* @example
|
|
915
|
+
* accDivide(56, 100); // 0.56
|
|
916
|
+
* accDivide(5679, 100, 2); // 56.79
|
|
917
|
+
* accDivide(5679, 100.2, 2); // 56.68
|
|
918
|
+
*/
|
|
919
|
+
export function accDivide(arg1: Number, arg2: Number, fix = 0): number;
|
|
843
920
|
|
|
844
921
|
/**
|
|
845
922
|
* 将数值格式化成金额形式
|
|
@@ -1021,6 +1098,11 @@ declare namespace utils {
|
|
|
1021
1098
|
* @param {*} value
|
|
1022
1099
|
*/
|
|
1023
1100
|
export function isNumber(value: any): boolean;
|
|
1101
|
+
/**
|
|
1102
|
+
* 支持 string 类型的科学计数 number 校验
|
|
1103
|
+
* @param value
|
|
1104
|
+
*/
|
|
1105
|
+
export function isENumber(value: any): boolean;
|
|
1024
1106
|
export function isFloat(value: any): boolean;
|
|
1025
1107
|
export function isOpacity(value: any): boolean;
|
|
1026
1108
|
export function toFloat(value: any): number;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), MAX_LENGTH = 9007199254740991;
|
|
4
|
+
|
|
5
|
+
function isInteger(e) {
|
|
6
|
+
return Math.floor(e) === e;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isCollection(e) {
|
|
10
|
+
return "object" === (0, _typeof2.default)(e) && null !== e && "number" == typeof e.length && isInteger(e.length) && e.length >= 0 && e.length <= MAX_LENGTH;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isString(e) {
|
|
14
|
+
return "string" == typeof e;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isBaseNaN(e) {
|
|
18
|
+
return e != e || isNaN(e);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isNumber(e) {
|
|
22
|
+
return "object" === (0, _typeof2.default)(e) ? e instanceof Number : "number" == typeof e;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isnan(e) {
|
|
26
|
+
return isNumber(e) && isBaseNaN(e.valueOf());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function contains(e, r, n) {
|
|
30
|
+
var t, i, o;
|
|
31
|
+
if (!isCollection(e) && !isString(e)) throw new TypeError("invalid argument. First argument must be array-like. Value: '".concat(e, "'"));
|
|
32
|
+
if (arguments.length < 2) throw new Error("insufficient arguments. Must provide a search value.");
|
|
33
|
+
if (arguments.length > 2) {
|
|
34
|
+
if (!isInteger(n)) throw new TypeError("invalid argument. Third argument must be an integer. Value: '".concat(n, "'."));
|
|
35
|
+
(i = n) < 0 && (i = 0);
|
|
36
|
+
} else i = 0;
|
|
37
|
+
if (isString(e)) {
|
|
38
|
+
if (!isString(r)) throw new TypeError("invalid argument. Second argument must be a string. Value: '".concat(r, "'."));
|
|
39
|
+
return -1 !== e.indexOf(r, i);
|
|
40
|
+
}
|
|
41
|
+
if (t = e.length, isnan(r)) {
|
|
42
|
+
for (o = i; o < t; o++) if (isnan(e[o])) return !0;
|
|
43
|
+
return !1;
|
|
44
|
+
}
|
|
45
|
+
for (o = i; o < t; o++) if (e[o] === r) return !0;
|
|
46
|
+
return !1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var isArray = Array.isArray || function(e) {
|
|
50
|
+
return "[object Array]" === Object.prototype.toString.call(e);
|
|
51
|
+
}, has = Object.prototype.hasOwnProperty;
|
|
52
|
+
|
|
53
|
+
function hasOwnProp(e, r) {
|
|
54
|
+
return null != e && has.call(e, r);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
MAX_LENGTH: MAX_LENGTH,
|
|
59
|
+
isInteger: isInteger,
|
|
60
|
+
isCollection: isCollection,
|
|
61
|
+
isString: isString,
|
|
62
|
+
contains: contains,
|
|
63
|
+
isArray: isArray,
|
|
64
|
+
hasOwnProp: hasOwnProp
|
|
65
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")), _require = require("./is"), isCollection = _require.isCollection, contains = _require.contains, isArray = _require.isArray, hasOwnProp = _require.hasOwnProp, METHODS = [ "min", "max", "average", "dense", "ordinal" ], MISSING = [ "last", "first", "remove" ];
|
|
4
|
+
|
|
5
|
+
function validate(e, r) {
|
|
6
|
+
if (!isObject(r)) return new TypeError("invalid argument. Options argument must be an object. Value: '".concat(r, "'."));
|
|
7
|
+
if (hasOwnProp(r, "encoding") && (e.encoding = r.encoding, !isArray(e.encoding))) return new TypeError("invalid option. " % s(_templateObject || (_templateObject = (0,
|
|
8
|
+
_taggedTemplateLiteral2.default)([ " option must be an array. Option: 'encoding=", "'." ])), e.encoding));
|
|
9
|
+
if (hasOwnProp(r, "method") && (e.method = r.method, !isString(e.method) || !contains(METHODS, e.method))) {
|
|
10
|
+
var n = "invalid option. `method` option must be one of the following: `min, max, average, dense, ordinal`. Option: " + e.method + " .";
|
|
11
|
+
return new TypeError(n);
|
|
12
|
+
}
|
|
13
|
+
if (hasOwnProp(r, "missing") && (e.missing = r.missing, !isString(e.missing) || !contains(MISSING, e.missing))) {
|
|
14
|
+
var i = "invalid option. missing option must be one of the following: `last,first,remove`. Option: " + e.missing + " .";
|
|
15
|
+
return new TypeError(i);
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isMissing(e, r) {
|
|
21
|
+
var n, i, t;
|
|
22
|
+
for (n = e.length, i = new Array(n), t = 0; t < n; t++) i[t] = contains(r, e[t]);
|
|
23
|
+
return i;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function sum(e) {
|
|
27
|
+
var r, n, i;
|
|
28
|
+
for (r = e.length, n = 0, i = 0; i < r; i++) n += e[i];
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function compareFunction(e, r) {
|
|
33
|
+
return e < r ? -1 : e > r ? 1 : 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function order(e) {
|
|
37
|
+
var r, n;
|
|
38
|
+
for (r = new Array(e.length), n = 0; n < e.length; n++) r[n] = n;
|
|
39
|
+
return r.sort((function(r, n) {
|
|
40
|
+
return compareFunction(e[r], e[n]);
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ranks(e, r) {
|
|
45
|
+
var n, i, t, o, a, s, l, u, g, m, c, f, d, h, p, v, w, b;
|
|
46
|
+
if (!isCollection(e)) throw new TypeError("invalid argument. First argument must be an array-like object. Value: '".concat(e, "'."));
|
|
47
|
+
if (d = {}, arguments.length > 1 && (p = validate(d, r))) throw p;
|
|
48
|
+
for (c = d.method || "average", s = d.encoding || [ null, NaN ], g = d.missing || "last",
|
|
49
|
+
v = e.length, h = [], w = 0; w < v; w++) contains(s, e[w]) || h.push(e[w]);
|
|
50
|
+
if (n = isMissing(e, s), v = h.length, o = 0, f = new Array(v), u = order(h), "ordinal" === c) for (w = 0; w < v; w++) f[u[w]] = w + 1; else for (i = 0,
|
|
51
|
+
w = 0; w < v; w++) if (l = w + 1, w === v - 1 || h[u[w]] !== h[u[l]]) {
|
|
52
|
+
switch (c) {
|
|
53
|
+
case "min":
|
|
54
|
+
m = l - i;
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case "max":
|
|
58
|
+
m = l;
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case "dense":
|
|
62
|
+
m = l - i - o, o += i;
|
|
63
|
+
break;
|
|
64
|
+
|
|
65
|
+
case "average":
|
|
66
|
+
default:
|
|
67
|
+
m = l - .5 * i;
|
|
68
|
+
}
|
|
69
|
+
for (b = w - i; b < l; b++) f[u[b]] = m;
|
|
70
|
+
i = 0;
|
|
71
|
+
} else i += 1;
|
|
72
|
+
if ("first" === g) {
|
|
73
|
+
for (t = sum(n), b = 1, a = new Array(n.length), w = 0; w < n.length; w++) n[w] ? (a[w] = b,
|
|
74
|
+
b += 1) : a[w] = f.shift() + t;
|
|
75
|
+
return a;
|
|
76
|
+
}
|
|
77
|
+
if ("last" === g) {
|
|
78
|
+
for (a = new Array(n.length), w = 0; w < n.length; w++) n[w] ? a[w] = w + f.length + 1 : a[w] = f.shift();
|
|
79
|
+
return a;
|
|
80
|
+
}
|
|
81
|
+
return f;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = ranks;
|
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"), 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");
|
|
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"), accDivide = require("./math/divide"), qs = require("./qs"), encodeUrl = require("./url/encodeUrl"), restfulUrl = require("./url/restfulUrl"), positionFactory = require("./positionFactory"), throttleDebounce = require("./throttleDebounce"), checkFlash = require("./_flashSupport"), algor = require("./algorithm");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
Base64: Base64,
|
|
@@ -64,6 +64,7 @@ module.exports = {
|
|
|
64
64
|
addition: addition,
|
|
65
65
|
subtraction: subtraction,
|
|
66
66
|
accMul: accMul,
|
|
67
|
+
accDivide: accDivide,
|
|
67
68
|
coinFormat: coinFormat,
|
|
68
69
|
dateTime: dateTime,
|
|
69
70
|
qs: qs,
|
|
@@ -71,5 +72,6 @@ module.exports = {
|
|
|
71
72
|
restfulUrl: restfulUrl,
|
|
72
73
|
positionFactory: positionFactory,
|
|
73
74
|
throttleDebounce: throttleDebounce,
|
|
74
|
-
checkFlash: checkFlash
|
|
75
|
+
checkFlash: checkFlash,
|
|
76
|
+
algor: algor
|
|
75
77
|
};
|
package/lib/arrayUtils.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var deepCopy = require("./_deepCopy")
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")), deepCopy = require("./_deepCopy"), utils = require("./utils"), arrayUtils = {
|
|
6
4
|
arrayIntersection: function() {
|
|
7
5
|
if (arguments.length > 0) {
|
|
8
6
|
for (var r = deepCopy(arguments[0]), e = 1; e < arguments.length; e++) {
|
|
@@ -18,5 +16,41 @@ module.exports = {
|
|
|
18
16
|
arrayToObject: function(r, e) {
|
|
19
17
|
for (var t = e && e.plainObjects ? Object.create(null) : {}, n = 0; n < r.length; ++n) void 0 !== r[n] && (t[n] = r[n]);
|
|
20
18
|
return t;
|
|
19
|
+
},
|
|
20
|
+
merge2DArraysDiagonally: function(r, e) {
|
|
21
|
+
for (var t = [], n = Math.max(r.length, e.length), u = 0; u < n; u++) {
|
|
22
|
+
var a = r[u] || [], o = e[u] || [];
|
|
23
|
+
t[u] = [].concat((0, _toConsumableArray2.default)(a), (0, _toConsumableArray2.default)(o));
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
},
|
|
27
|
+
deduplicateAndSort: function(r, e) {
|
|
28
|
+
var t = (0, _toConsumableArray2.default)(new Set(r));
|
|
29
|
+
return t.sort(e), t;
|
|
30
|
+
},
|
|
31
|
+
removeByIndex: function(r, e) {
|
|
32
|
+
if (utils.isNumber(e)) r.splice(e, 1); else if (utils.isArray(e)) for (var t = arrayUtils.deduplicateAndSort(e, (function(r, e) {
|
|
33
|
+
return r - e;
|
|
34
|
+
})), n = 0; n < t.length; n++) {
|
|
35
|
+
var u = t[n] - n;
|
|
36
|
+
u < r.length && r.splice(u, 1);
|
|
37
|
+
}
|
|
38
|
+
return r;
|
|
39
|
+
},
|
|
40
|
+
calculateRanks: function(r) {
|
|
41
|
+
for (var e = {}, t = r.slice().sort((function(r, e) {
|
|
42
|
+
return r - e;
|
|
43
|
+
})), n = 1, u = t[0], a = 0; a < t.length; a++) {
|
|
44
|
+
var o = t[a];
|
|
45
|
+
o !== u && (n = a + 1, u = o), e[o] ? (e[o].count++, e[o].sum += n) : e[o] = {
|
|
46
|
+
count: 1,
|
|
47
|
+
sum: n
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return r.map((function(r) {
|
|
51
|
+
return e[r] ? e[r].sum / e[r].count : void 0;
|
|
52
|
+
}));
|
|
21
53
|
}
|
|
22
|
-
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = arrayUtils;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var pow = function(t) {
|
|
4
|
+
return Math.pow(10, t);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
module.exports = function(t, r) {
|
|
8
|
+
var e = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 0, n = 0, o = 0, l = t.toString(), u = r.toString();
|
|
9
|
+
try {
|
|
10
|
+
n = l.split(".")[1].length;
|
|
11
|
+
} catch (t) {}
|
|
12
|
+
try {
|
|
13
|
+
o = u.split(".")[1].length;
|
|
14
|
+
} catch (t) {}
|
|
15
|
+
var c = Number(l.replace(".", "")), i = Number(u.replace(".", "")), a = c / i * pow(o - n);
|
|
16
|
+
return null != e && e > 0 && (a = a.toFixed(e)), Number(a);
|
|
17
|
+
};
|
package/lib/utils.js
CHANGED
|
@@ -12,6 +12,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
12
12
|
if (isObject(e)) return !1;
|
|
13
13
|
var t = /^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/.test(e), n = "number" == typeof e && !isNaN(e);
|
|
14
14
|
return t || n;
|
|
15
|
+
}, isENumber = function(e) {
|
|
16
|
+
if ("number" == typeof e) return !0;
|
|
17
|
+
if (isNumber(e)) return !0;
|
|
18
|
+
if (isString(e) && (e.indexOf("e") > -1 || e.indexOf("E") > -1)) {
|
|
19
|
+
var t = Number(e);
|
|
20
|
+
return isNumber(t);
|
|
21
|
+
}
|
|
22
|
+
return !1;
|
|
15
23
|
}, isFloat = function(e) {
|
|
16
24
|
return /^-?\d+(\.\d+)?$/.test(e);
|
|
17
25
|
}, isOpacity = function(e) {
|
|
@@ -267,6 +275,7 @@ module.exports = {
|
|
|
267
275
|
isBoolean: isBoolean,
|
|
268
276
|
isFunction: isFunction,
|
|
269
277
|
isNumber: isNumber,
|
|
278
|
+
isENumber: isENumber,
|
|
270
279
|
isFloat: isFloat,
|
|
271
280
|
isOpacity: isOpacity,
|
|
272
281
|
toFloat: toFloat,
|