light-h5-core-lib 2.8.1 → 2.8.2

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.
@@ -1,92 +1,81 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RandomNumUtil = void 0;
4
- /**
5
- * 随机数生成工具
6
- * @author aonaufly
7
- */
8
- var RandomNumUtil = /** @class */ (function () {
9
- function RandomNumUtil() {
10
- }
11
- /**
12
- * 获取一定范围的随机整数
13
- *
14
- * <b>( min ≤ r ≤ max )</b>
15
- *
16
- * @param min 最小数
17
- * @param max 最大数
18
- * @param isInt 是否返回整数
19
- */
20
- RandomNumUtil.randomNumBoth = function (min, max, isInt) {
21
- if (isInt === void 0) { isInt = true; }
22
- var Range = max - min;
23
- if (Range > 0.0) {
24
- var Rand = Math.random();
25
- var num = void 0;
26
- if (isInt) {
27
- num = min + Math.round(Rand * Range); //四舍五入
28
- }
29
- else {
30
- num = min + Rand * Range;
31
- }
32
- return num;
33
- }
34
- else {
35
- return isInt ? min : Math.round(min);
36
- }
37
- };
38
- /**
39
- * 打乱数组
40
- */
41
- RandomNumUtil.shuffleSort = function (arr) {
42
- var n = arr.length;
43
- var index;
44
- var temp;
45
- while (n--) {
46
- index = Math.floor(Math.random() * n);
47
- temp = arr[index];
48
- arr[index] = arr[n];
49
- arr[n] = temp;
50
- }
51
- };
52
- /**
53
- * 获得偏振系数
54
- * @param factor 偏振因子(>0
55
- * @param negativeIntRadio 负数的比率(> 0的整数)
56
- * @param positiveIntRadio 正数的比率 (>0的整数)
57
- * @return -factor 或者factor
58
- */
59
- RandomNumUtil.getPolarizationFactor = function (factor, negativeIntRadio, positiveIntRadio) {
60
- if (factor === void 0) { factor = 1; }
61
- if (negativeIntRadio === void 0) { negativeIntRadio = 1; }
62
- if (positiveIntRadio === void 0) { positiveIntRadio = 1; }
63
- var r = RandomNumUtil.randomNumWithRadio(0, 1, [negativeIntRadio, positiveIntRadio]);
64
- if (r == 0)
65
- return -1 * factor;
66
- return r * factor;
67
- };
68
- /**
69
- * 按照比率获得随机数(对于整数)
70
- * @param min 最小数
71
- * @param max 最大数
72
- * @param radioArr 比率
73
- */
74
- RandomNumUtil.randomNumWithRadio = function (min, max, radioArr) {
75
- var total = 0;
76
- var i;
77
- for (i = 0; i < radioArr.length; i++) {
78
- total += radioArr[i];
79
- }
80
- var r = RandomNumUtil.randomNumBoth(1, total, true);
81
- var target = 0;
82
- for (i = 0; i < radioArr.length; i++) {
83
- target += radioArr[i];
84
- if (r <= target) {
85
- return i + min;
86
- }
87
- }
88
- return max;
89
- };
90
- return RandomNumUtil;
91
- }());
92
- exports.RandomNumUtil = RandomNumUtil;
1
+ /**
2
+ * 随机数生成工具
3
+ * @author aonaufly
4
+ */
5
+ export class RandomNumUtil {
6
+ /**
7
+ * 获取一定范围的随机整数
8
+ *
9
+ * <b>( min ≤ r ≤ max )</b>
10
+ *
11
+ * @param min 最小数
12
+ * @param max 最大数
13
+ * @param isInt 是否返回整数
14
+ */
15
+ public static randomNumBoth(min: number, max: number, isInt: boolean = true): number {
16
+ const Range: number = max - min;
17
+ if (Range > 0.0) {
18
+ const Rand: number = Math.random();
19
+ let num: number;
20
+ if (isInt) {
21
+ num = min + Math.round(Rand * Range); //四舍五入
22
+ } else {
23
+ num = min + Rand * Range;
24
+ }
25
+ return num;
26
+ } else {
27
+ return isInt ? min : Math.round(min);
28
+ }
29
+ }
30
+
31
+ /**
32
+ * 打乱数组
33
+ */
34
+ public static shuffleSort<T>(arr: T[]): void {
35
+ let n: number = arr.length;
36
+ let index: number;
37
+ let temp: T;
38
+ while (n--) {
39
+ index = Math.floor(Math.random() * n);
40
+ temp = arr[index];
41
+ arr[index] = arr[n];
42
+ arr[n] = temp;
43
+ }
44
+ }
45
+
46
+ /**
47
+ * 获得偏振系数
48
+ * @param factor 偏振因子(>0)
49
+ * @param negativeIntRadio 负数的比率(> 0的整数)
50
+ * @param positiveIntRadio 正数的比率 (>0的整数)
51
+ * @return -factor 或者factor
52
+ */
53
+ public static getPolarizationFactor(factor: number = 1, negativeIntRadio: number = 1, positiveIntRadio: number = 1): number {
54
+ const r: number = RandomNumUtil.randomNumWithRadio(0, 1, [negativeIntRadio, positiveIntRadio]);
55
+ if (r == 0) return -1 * factor;
56
+ return r * factor;
57
+ }
58
+
59
+ /**
60
+ * 按照比率获得随机数(对于整数)
61
+ * @param min 最小数
62
+ * @param max 最大数
63
+ * @param radioArr 比率
64
+ */
65
+ public static randomNumWithRadio(min: number, max: number, radioArr: number[]): number {
66
+ let total: number = 0;
67
+ let i: number;
68
+ for (i = 0; i < radioArr.length; i++) {
69
+ total += radioArr[i];
70
+ }
71
+ const r: number = RandomNumUtil.randomNumBoth(1, total, true);
72
+ let target: number = 0;
73
+ for (i = 0; i < radioArr.length; i++) {
74
+ target += radioArr[i];
75
+ if (r <= target) {
76
+ return i + min;
77
+ }
78
+ }
79
+ return max;
80
+ }
81
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 解码
3
+ * @author Aonaufly
4
+ */
5
+ export class SelfDecrypt {
6
+ private static b64Decode(b64: string): Uint8Array {
7
+ // 浏览器安全解码,自动补 =
8
+ const s: string = b64.replace(/[^A-Za-z0-9+/]/g, '');
9
+ const bin: string = atob(s);
10
+ return new Uint8Array(bin.length).map((_, i) => bin.charCodeAt(i));
11
+ }
12
+
13
+ private static b64Encode(bytes: Uint8Array): string {
14
+ const bin: string = String.fromCharCode(...bytes);
15
+ return btoa(bin);
16
+ }
17
+
18
+ private static xorBytes(bytes: Uint8Array, key: string): Uint8Array {
19
+ const k: Uint8Array = new TextEncoder().encode(key);
20
+ return bytes.map((b, i) => b ^ k[i % k.length]);
21
+ }
22
+
23
+ /**
24
+ * 解码
25
+ */
26
+ public static decryptBase64(b64: string, key: string): string {
27
+ const cipher: Uint8Array = SelfDecrypt.b64Decode(b64);
28
+ const plain: Uint8Array = SelfDecrypt.xorBytes(cipher, key);
29
+ return new TextDecoder().decode(plain);
30
+ }
31
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * 字符串工具
3
+ * @author aonaufly
4
+ */
5
+ export class StringUtil {
6
+ /**
7
+ * 字符串的格式化 , 使用 {index = 0}的模式
8
+ * @param str 源字符串
9
+ * @param args 填充参数
10
+ */
11
+ public static format(str: string, ...args: any): string {
12
+ if (!args || args.length == 0) return str;
13
+ for (let i: number = 0, j: number = args.length; i < j; i++) {
14
+ str = str.replace(`{${i}}`, args[i]);
15
+ }
16
+ return str;
17
+ }
18
+
19
+ /**
20
+ * 将字符串中所有的\/替换成/
21
+ */
22
+ public static replaceBackslash(input: string): string {
23
+ // 使用正则表达式替换所有的 \\/ 为 /
24
+ return input.replace(/\\\//g, '/');
25
+ }
26
+
27
+ private static code2utf8(uni: number): string {
28
+ let uni2: string = uni.toString(2);
29
+ if (uni < 128) {
30
+ return uni.toString(16);
31
+ } else if (uni < 2048) {
32
+ uni2 = ("00000000000000000" + uni2).slice(-11);
33
+ const s1 = parseInt("110" + uni2.substring(0, 5), 2);
34
+ const s2 = parseInt("10" + uni2.substring(5), 2);
35
+ return s1.toString(16) + "," + s2.toString(16);
36
+ } else {
37
+ uni2 = ("00000000000000000" + uni2).slice(-16);
38
+ const s1 = parseInt("1110" + uni2.substring(0, 4), 2);
39
+ const s2 = parseInt("10" + uni2.substring(4, 10), 2);
40
+ const s3 = parseInt("10" + uni2.substring(10), 2);
41
+ return s1.toString(16) + "," + s2.toString(16) + "," + s3.toString(16);
42
+ }
43
+ }
44
+
45
+ /**
46
+ * 将字符串转化成UTF8的Buffer
47
+ * @param str 字符串
48
+ */
49
+ public static string2UTF8Buffer(str: string): ArrayBuffer {
50
+ let val: string = "";
51
+ for (let i: number = 0; i < str.length; i++) {
52
+ val += "," + StringUtil.code2utf8(str.charCodeAt(i));
53
+ }
54
+ val += ",00";
55
+ // 将16进制转化为ArrayBuffer
56
+ return new Uint8Array(
57
+ val.match(/[\da-f]{2}/gi).map((h) => {
58
+ return parseInt(h, 16);
59
+ })
60
+ ).buffer;
61
+ }
62
+
63
+ // /**
64
+ // * 将buffer转化成UTF8
65
+ // * @param buffer
66
+ // */
67
+ // public static buffer2UTF8String(buffer: ArrayBuffer): string {
68
+ // const encodedString: string = String.fromCharCode.apply(null, new Uint8Array(buffer));
69
+ // // const decodedString: string = decodeURIComponent(escape(atob(encodedString)));
70
+ // return encodedString;
71
+ // }
72
+ /* 将buffer转化成UTF8
73
+ * @param buffer
74
+ */
75
+ public static buffer2UTF8String = (buffer: ArrayBuffer) => {
76
+ const uint8Array = new Uint8Array(buffer);
77
+ const data = uint8Array.reduce(
78
+ (acc, i) => (acc += String.fromCharCode.apply(null, [i])),
79
+ ""
80
+ );
81
+ return data;
82
+ };
83
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 唯一ID生成器
3
+ * @author Aonaufly
4
+ */
5
+ export class UniqueIDUtil {
6
+ /**生成唯一ID值*/
7
+ public static getUniqueId(): string {
8
+ return new Date().getTime() + Math.random().toString(36).substring(2);
9
+ }
10
+ /**生成复合的Key值*/
11
+ public static getCompositeKey(key: string | number, uniqueId: string): string {
12
+ return `${key}-id:${uniqueId}`;
13
+ }
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "light-h5-core-lib",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "light core lib",
5
5
  "main": "./LightCore.js",
6
6
  "types": "./type/index.d.ts",
@@ -0,0 +1,69 @@
1
+ import { IClear } from "../common/base/IClear";
2
+
3
+ /**
4
+ * 对象池(泛型)
5
+ * @author Aonaufly
6
+ */
7
+ export class PoolObj<T> implements IClear {
8
+ private _pool: T[];
9
+ private _cap: number;
10
+ /**
11
+ * @param cap 容量(容积)
12
+ */
13
+ public constructor(cap: number = 5) {
14
+ this._cap = cap;
15
+ this._pool = [];
16
+ }
17
+
18
+ public put(obj: T): boolean {
19
+ if (!obj || this._pool.length >= this._cap) return false;
20
+ this._pool.push(obj);
21
+ return true;
22
+ }
23
+
24
+ public one(): T {
25
+ if (this._pool.length == 0) return null;
26
+ return this._pool.shift();
27
+ }
28
+
29
+ /**
30
+ * 获取容量(容积)
31
+ */
32
+ public get cap(): number {
33
+ return this._cap;
34
+ }
35
+
36
+ /**
37
+ * 获取当前数量(已经保存的元素个数)
38
+ */
39
+ public get size(): number {
40
+ if (!this._pool) return 0;
41
+ return this._pool.length;
42
+ }
43
+
44
+ /**
45
+ * 清理对象池
46
+ */
47
+ public clear(): void {
48
+ if (!this._pool) return;
49
+ if (this._pool.length == 0) return;
50
+ let obj: any;
51
+ for (let i: number = 0, j: number = this._pool.length; i < j; i++) {
52
+ obj = this._pool[i];
53
+ if (obj.destroy) {
54
+ obj.destroy();
55
+ } else if (obj.onDestroy) {
56
+ obj.onDestroy();
57
+ }
58
+ obj = null;
59
+ }
60
+ this._pool.length = 0;
61
+ }
62
+
63
+ public destroy(isCleared?: boolean): void {
64
+ if (!isCleared) {
65
+ this.clear();
66
+ }
67
+ this._pool && (this._pool = null);
68
+ }
69
+ }
package/type/index.d.ts CHANGED
@@ -272,7 +272,6 @@ export declare class MD5 extends BaseSingleton<MD5> {
272
272
  md5_ii(a: any, b: any, c: any, d: any, x: any, s: any, t: any): number;
273
273
  safe_add(x: any, y: any): number;
274
274
  bit_rol(num: any, cnt: any): number;
275
- selfDecrypt(data: string, secretKey: string): string;
276
275
  }
277
276
  /**
278
277
  * 异步处理工具
@@ -319,5 +318,18 @@ export declare class NumberUtil {
319
318
  */
320
319
  static getProtoNum(data: any, key: string, defaultValue?: number): number;
321
320
  }
321
+ /**
322
+ * 解码
323
+ * @author Aonaufly
324
+ */
325
+ export declare class SelfDecrypt {
326
+ private static b64Decode;
327
+ private static b64Encode;
328
+ private static xorBytes;
329
+ /**
330
+ * 解码
331
+ */
332
+ static decryptBase64(b64: string, key: string): string;
333
+ }
322
334
 
323
335
  export {};
package/LightCore.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NumberUtil = exports.BooleanUtil = exports.Crc32Util = exports.PromiseUtil = exports.BeizerUtil = exports.UniqueIDUtil = exports.StringUtil = exports.RandomNumUtil = exports.FloatDigitUtil = exports.DateUtil = exports.BitUtil = exports.MD5 = exports.BaseSingleton = exports.PoolObj = void 0;
7
- var PoolObj_1 = require("./pool/PoolObj");
8
- Object.defineProperty(exports, "PoolObj", { enumerable: true, get: function () { return PoolObj_1.PoolObj; } });
9
- var BaseSingleton_1 = require("./common/base/BaseSingleton");
10
- Object.defineProperty(exports, "BaseSingleton", { enumerable: true, get: function () { return BaseSingleton_1.BaseSingleton; } });
11
- var BitUtil_1 = require("./common/util/BitUtil");
12
- Object.defineProperty(exports, "BitUtil", { enumerable: true, get: function () { return BitUtil_1.BitUtil; } });
13
- var DateUtil_1 = require("./common/util/DateUtil");
14
- Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return DateUtil_1.DateUtil; } });
15
- var FloatDigitUtil_1 = require("./common/util/FloatDigitUtil");
16
- Object.defineProperty(exports, "FloatDigitUtil", { enumerable: true, get: function () { return FloatDigitUtil_1.FloatDigitUtil; } });
17
- var RandomNumUtil_1 = require("./common/util/RandomNumUtil");
18
- Object.defineProperty(exports, "RandomNumUtil", { enumerable: true, get: function () { return RandomNumUtil_1.RandomNumUtil; } });
19
- var StringUtil_1 = require("./common/util/StringUtil");
20
- Object.defineProperty(exports, "StringUtil", { enumerable: true, get: function () { return StringUtil_1.StringUtil; } });
21
- var UniqueIDUtil_1 = require("./common/util/UniqueIDUtil");
22
- Object.defineProperty(exports, "UniqueIDUtil", { enumerable: true, get: function () { return UniqueIDUtil_1.UniqueIDUtil; } });
23
- var BeizerUtil_1 = require("./common/util/BeizerUtil");
24
- Object.defineProperty(exports, "BeizerUtil", { enumerable: true, get: function () { return BeizerUtil_1.BeizerUtil; } });
25
- var MD5_1 = require("./common/md5/MD5");
26
- Object.defineProperty(exports, "MD5", { enumerable: true, get: function () { return MD5_1.MD5; } });
27
- var PromiseUtil_1 = __importDefault(require("./common/util/PromiseUtil"));
28
- exports.PromiseUtil = PromiseUtil_1.default;
29
- var Crc32Util_1 = __importDefault(require("./common/util/Crc32Util"));
30
- exports.Crc32Util = Crc32Util_1.default;
31
- var BooleanUtil_1 = require("./common/util/BooleanUtil");
32
- Object.defineProperty(exports, "BooleanUtil", { enumerable: true, get: function () { return BooleanUtil_1.BooleanUtil; } });
33
- var NumberUtil_1 = require("./common/util/NumberUtil");
34
- Object.defineProperty(exports, "NumberUtil", { enumerable: true, get: function () { return NumberUtil_1.NumberUtil; } });
35
- module.exports = {
36
- PoolObj: PoolObj_1.PoolObj,
37
- BaseSingleton: BaseSingleton_1.BaseSingleton,
38
- MD5: MD5_1.MD5,
39
- BitUtil: BitUtil_1.BitUtil,
40
- DateUtil: DateUtil_1.DateUtil,
41
- FloatDigitUtil: FloatDigitUtil_1.FloatDigitUtil,
42
- RandomNumUtil: RandomNumUtil_1.RandomNumUtil,
43
- StringUtil: StringUtil_1.StringUtil,
44
- UniqueIDUtil: UniqueIDUtil_1.UniqueIDUtil,
45
- BeizerUtil: BeizerUtil_1.BeizerUtil,
46
- PromiseUtil: PromiseUtil_1.default,
47
- Crc32Util: Crc32Util_1.default,
48
- BooleanUtil: BooleanUtil_1.BooleanUtil,
49
- NumberUtil: NumberUtil_1.NumberUtil,
50
- };
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseSingleton = void 0;
4
- /**
5
- * 泛型单例基类
6
- * @author Aonaufly
7
- */
8
- var BaseSingleton = /** @class */ (function () {
9
- function BaseSingleton() {
10
- }
11
- BaseSingleton.getInstance = function (c) {
12
- if (this._instance == null) {
13
- this._instance = new c();
14
- this._instance.ctor();
15
- }
16
- return this._instance;
17
- };
18
- /**
19
- * 相当于构造函数
20
- */
21
- BaseSingleton.prototype.ctor = function () {
22
- };
23
- BaseSingleton.prototype.destroy = function () {
24
- BaseSingleton._instance = null;
25
- };
26
- BaseSingleton._instance = null;
27
- return BaseSingleton;
28
- }());
29
- exports.BaseSingleton = BaseSingleton;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BeizerUtil = void 0;
4
- /**
5
- * 贝塞尔曲线运动
6
- * @author Aonaufly
7
- */
8
- var BeizerUtil = /** @class */ (function () {
9
- function BeizerUtil() {
10
- }
11
- //#region 获得当前坐标
12
- /**
13
- * 获得当前坐标
14
- * @param timer 时间[0,1]
15
- * @returns
16
- */
17
- BeizerUtil.getPosition = function (points, timer) {
18
- var x = 0, y = 0;
19
- var bezier;
20
- for (var i = 0, n = points.length; i < n; i++) {
21
- bezier =
22
- Math.min(Math.pow(1 - timer, n - i - 1) * Math.pow(timer, i)) *
23
- BeizerUtil.calculationC(i, n);
24
- x += points[i].x * bezier;
25
- y += points[i].y * bezier;
26
- }
27
- return { x: x, y: y };
28
- };
29
- //#endregion
30
- //region 获得路线的长度
31
- BeizerUtil.distance = function (p1, p2) {
32
- var dx = p2.x - p1.x;
33
- var dy = p2.y - p1.y;
34
- return Math.sqrt(dx * dx + dy * dy);
35
- };
36
- /**
37
- * 获得整个路线的长度
38
- * @param precision 精确度(微积分方案)
39
- */
40
- BeizerUtil.getLength = function (points, precision) {
41
- if (precision === void 0) { precision = 100; }
42
- var length = 0;
43
- var point1;
44
- var point2;
45
- for (var t = 0; t < 1; t += 1 / precision) {
46
- point1 = BeizerUtil.getBezierPoint(points, t);
47
- point2 = BeizerUtil.getBezierPoint(points, t + 1 / precision);
48
- length += BeizerUtil.distance(point1, point2);
49
- }
50
- return length;
51
- };
52
- BeizerUtil.calculationC = function (i, n) {
53
- return (BeizerUtil.factorial(n - 1) /
54
- (BeizerUtil.factorial(i) * BeizerUtil.factorial(n - 1 - i)));
55
- };
56
- BeizerUtil.factorial = function (num) {
57
- if (num < 0) {
58
- return 1;
59
- }
60
- else if (num === 0 || num === 1) {
61
- return 1;
62
- }
63
- else {
64
- return num * BeizerUtil.factorial(num - 1);
65
- }
66
- };
67
- BeizerUtil.getBezierPoint = function (points, t) {
68
- if (points.length === 1) {
69
- return points[0];
70
- }
71
- var nextPoints = [];
72
- var x;
73
- var y;
74
- for (var i = 0; i < points.length - 1; i++) {
75
- x = (1 - t) * points[i].x + t * points[i + 1].x;
76
- y = (1 - t) * points[i].y + t * points[i + 1].y;
77
- nextPoints.push({ x: x, y: y });
78
- }
79
- return BeizerUtil.getBezierPoint(nextPoints, t);
80
- };
81
- return BeizerUtil;
82
- }());
83
- exports.BeizerUtil = BeizerUtil;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BooleanUtil = void 0;
4
- /**
5
- * Bool类型处理
6
- * @author Aonaufly
7
- */
8
- var BooleanUtil = /** @class */ (function () {
9
- function BooleanUtil() {
10
- }
11
- /**
12
- * 获得Proto中的Bool值
13
- */
14
- BooleanUtil.getProtoBool = function (data, key, defaultValue) {
15
- if (defaultValue === void 0) { defaultValue = false; }
16
- if (key in data) {
17
- return data[key];
18
- }
19
- return defaultValue;
20
- };
21
- return BooleanUtil;
22
- }());
23
- exports.BooleanUtil = BooleanUtil;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Crc32验证工具
5
- * @author Aonaufly
6
- */
7
- var Crc32Util = /** @class */ (function () {
8
- function Crc32Util() {
9
- }
10
- /**
11
- * Crc32 number
12
- */
13
- Crc32Util.getCrc32Number = function (str, crc) {
14
- if (crc === void 0) { crc = 0; }
15
- var n = 0;
16
- var x;
17
- crc = crc ^ (-1);
18
- for (var i = 0, iTop = str.length; i < iTop; i++) {
19
- n = (crc ^ str.charCodeAt(i)) & 0xFF;
20
- x = "0x" + Crc32Util.table.substr(n * 9, 8);
21
- crc = (crc >>> 8) ^ x;
22
- }
23
- return crc ^ (-1);
24
- };
25
- /**
26
- * Crc32 string
27
- */
28
- Crc32Util.getCrc32String = function (str, crc) {
29
- if (crc === void 0) { crc = 0; }
30
- return Crc32Util.getCrc32Number(str, crc).toString(16);
31
- };
32
- Crc32Util.table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
33
- return Crc32Util;
34
- }());
35
- exports.default = Crc32Util;